From: Anthony Towns <aj@azure.humbug.org.au>
Date: Fri, 21 Mar 2008 20:07:40 +0000 (+0000)
Subject: always prompt to commit edits
X-Git-Tag: debian-r/squeeze~1543^2~2
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=738b9f6a08d6369a17a8f5de18e26ea5b8bd1c70;p=dak.git

always prompt to commit edits
some display tidying
---

diff --git a/dak/transitions.py b/dak/transitions.py
index 15aef62e..121edc2f 100755
--- a/dak/transitions.py
+++ b/dak/transitions.py
@@ -67,7 +67,7 @@ def init():
 ################################################################################
 
 def usage (exit_code=0):
-    print """Usage: edit_transitions [OPTION]...
+    print """Usage: transitions [OPTION]...
 Update and check the release managers transition file.
 transitions.
 
@@ -185,33 +185,42 @@ def edit_transitions():
 
         if test == None:
             # Edit is broken
-            answer = "XXX"
-            prompt = "Broken edit: [E]dit again, Drop changes?"
-
-            while prompt.find(answer) == -1:
-                answer = daklib.utils.our_raw_input(prompt)
-                if answer == "":
-                    answer = "E"
-                answer = answer[:1].upper()
-
-            if answer == 'E':
-                continue
-            elif answer == 'D':
-                os.unlink(edit_file)
-                print "OK, discarding changes"
-                sys.exit(0)
-        else:
-            # No problems in loading the new file, jump out of the while loop
+	    print "Edit was unparsable."
+            prompt = "[E]dit again, Drop changes?"
+	    default = "E"
+	else:
+	    print "Edit looks okay.\n"
+            print "------------------------------------------------------------------------"
+            transition_info(test)
+
+	    prompt = "[S]ave, Edit again, Drop changes?"
+	    default = "S"
+
+        answer = "XXX"
+        while prompt.find(answer) == -1:
+            answer = daklib.utils.our_raw_input(prompt)
+            if answer == "":
+                answer = default
+            answer = answer[:1].upper()
+
+        if answer == 'E':
+            continue
+        elif answer == 'D':
+            os.unlink(edit_file)
+            print "OK, discarding changes"
+            sys.exit(0)
+        elif answer == 'S':
+            # Ready to save
             break
+	else:
+	    print "You pressed something you shouldn't have :("
+	    sys.exit(1)
 
     # We seem to be done and also have a working file. Copy over.
     write_transitions_from_file(edit_file)
     os.unlink(edit_file)
 
-    # Before we finish print out transition info again
-    print "\n\n------------------------------------------------------------------------"
-    print "Edit done, file saved, currently defined transitions:\n"
-    transition_info(load_transitions(trans_file))
+    print "Transitions file updated."
 
 ################################################################################
 
@@ -281,8 +290,7 @@ def check_transitions(transitions):
 ################################################################################
 
 def print_info(trans, source, expected, rm, reason, packages):
-        print """
-Looking at transition: %s
+        print """Looking at transition: %s
  Source:      %s
  New Version: %s
  Responsible: %s