cmdrewrite: rename variable and move it closer to where it is used
authorAnton Shestakov <av6@dwimlabs.net>
Thu, 13 Sep 2018 00:04:17 +0800
changeset 4108 ef3c9ecb8099
parent 4095 aabf436c11cb
child 4110 b3b861a7f6f7
cmdrewrite: rename variable and move it closer to where it is used Renaming to satisfy pep8-naming linter plugin, which complained on this variable because all-uppercase names are reserved for constants, and constants need to be module-level. This variable is not a good choice for moving up to the module level because it's used only in one place. Additionally, let's have it closer to the place it's actually used to potentially avoid an extra call to _() function (however cheap it may be).
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Sep 04 19:30:19 2018 +0800
+++ b/hgext3rd/evolve/cmdrewrite.py	Thu Sep 13 00:04:17 2018 +0800
@@ -186,7 +186,6 @@
         lockmod.release(lock, wlock)
 
 def _editandapply(ui, repo, pats, old, p1, fp, diffopts):
-    RETRYCHOICE = _('try to fix the patch (yn)?$$ &Yes $$ &No')
     newnode = None
     while newnode is None:
         fp.seek(0)
@@ -220,7 +219,8 @@
             defaultchoice = 0 # yes
             if not ui.interactive:
                 defaultchoice = 1 # no
-            if ui.promptchoice(RETRYCHOICE, default=defaultchoice):
+            retrychoice = _('try to fix the patch (yn)?$$ &Yes $$ &No')
+            if ui.promptchoice(retrychoice, default=defaultchoice):
                 raise error.Abort(_("Could not apply amended path"))
             else:
                 # consider a third choice where we restore the original patch