Bug 962327 - Update when reusing existing bug, r=ted
authorSteve Fink <sfink@mozilla.com>
Tue, 28 Jan 2014 19:02:08 -0800
changeset 131 3420668a4f37
parent 130 c604ded99c59
child 132 f1b2724ebc97
push id62
push usersfink@mozilla.com
push dateFri, 31 Jan 2014 20:16:46 +0000
reviewersted
bugs962327
Bug 962327 - Update when reusing existing bug, r=ted
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -575,30 +575,32 @@ def fill_values(values, ui, api_server, 
 
     if 'ATTACHMENT_DESCRIPTION' in values:
         if values['ATTACHMENT_DESCRIPTION'] in [None, '<required>']:
             values['ATTACHMENT_DESCRIPTION'] = ui.prompt(_("Patch description:"), default=values['ATTACHMENT_FILENAME'])
 
     return values
 
 
-def update_patch(ui, repo, rev, bug, update, rename, interactive):
-    update_patch = update if update is not None else ui.configbool("bzexport", "update-patch", False)
-    rename_patch = rename if rename is not None else ui.configbool("bzexport", "rename-patch", False)
-
+def update_patch(ui, repo, rev, bug, update_patch, rename_patch, interactive):
     q = repo.mq
     try:
         rev = q.lookup(rev)
     except util.error.Abort:
         # If the patch is not coming from mq, don't complain that the name is not found
         update_patch = False
         rename_patch = False
 
-    if update_patch or rename_patch:
-        if interactive and ui.prompt(_("Update patch name/description (y/n)?")) != 'y':
+    todo = []
+    if rename_patch:
+        todo.append("name")
+    if update_patch:
+        todo.append("description")
+    if todo:
+        if interactive and ui.prompt("Update patch " + " and ".join(todo) + " (y/n)?") != 'y':
             ui.write(_("Exiting without updating patch\n"))
             return
 
     if rename_patch:
         newname = str("bug-%s-%s" % (bug, re.sub(r'^bug-\d+-', '', rev)))
         if newname != rev:
             try:
                 mq.rename(ui, repo, rev, newname)
@@ -956,18 +958,28 @@ def bzexport(ui, repo, *args, **opts):
     if len(cc) > 0:
         for user in cc:
             ui.write("CC'ing %s\n" % user)
     if len(feedback) > 0:
         for user in feedback:
             ui.write("Requesting feedback from %s\n" % user)
 
     if not opts['no_update']:
-        update = opts['update'] or opts['new']
-        rename = opts['update']
+        if opts['update']:
+            update = True
+        elif opts['new']:
+            update = ui.configbool("bzexport", "update-patch", True)
+        else:
+            update = ui.configbool("bzexport", "update-patch", False)
+
+        if opts['update']:
+            rename = opts['update']
+        else:
+            rename = ui.configbool("bzexport", "rename-patch", False)
+
         newname = update_patch(ui, repo, rev, bug, update, rename, opts['interactive'])
         if filename == rev:
             filename = newname
 
     if opts['interactive'] and ui.prompt(_("Attach patch (y/n)?")) != 'y':
         ui.write(_("Exiting without creating attachment\n"))
         return