Upcoming commits will introduce reverting lines and hunks. They also
need to prompt the user for confirmation. Put the dialog creation in its
separate function so the same code won't be repeated again and again.

Signed-off-by: Pratyush Yadav <m...@yadavpratyush.com>
---
 lib/index.tcl | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/lib/index.tcl b/lib/index.tcl
index b588db1..cb7f74a 100644
--- a/lib/index.tcl
+++ b/lib/index.tcl
@@ -388,6 +388,18 @@ proc do_add_all {} {
        add_helper [mc "Adding all changed files"] $paths
 }
 
+proc revert_dialog {query} {
+       return [tk_dialog \
+               .confirm_revert \
+               "[appname] ([reponame])" \
+               "$query" \
+               question \
+               1 \
+               [mc "Do Nothing"] \
+               [mc "Revert Changes"] \
+               ]
+}
+
 proc revert_helper {txt paths} {
        global file_states current_diff_path
 
@@ -430,17 +442,12 @@ proc revert_helper {txt paths} {
                set query [mc "Revert changes in these %i files?" $n]
        }
 
-       set reply [tk_dialog \
-               .confirm_revert \
-               "[appname] ([reponame])" \
-               "$query
+       set query "$query
+
+[mc "Any unstaged changes will be permanently lost by the revert."]"
+
+       set reply [revert_dialog $query]
 
-[mc "Any unstaged changes will be permanently lost by the revert."]" \
-               question \
-               1 \
-               [mc "Do Nothing"] \
-               [mc "Revert Changes"] \
-               ]
        if {$reply == 1} {
                checkout_index \
                        $txt \
-- 
2.21.0

Reply via email to