D639: amend: use context manager for config override

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Sep 7 10:54:41 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5dc6ac6555e6: amend: use context manager for config override (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D639?vs=1636&id=1661

REVISION DETAIL
  https://phab.mercurial-scm.org/D639

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -35,7 +35,6 @@
     obsolete,
     patch,
     pathutil,
-    phases,
     pycompat,
     registrar,
     revlog,
@@ -3162,16 +3161,13 @@
             # This not what we expect from amend.
             return old.node()
 
-        ph = repo.ui.config('phases', 'new-commit', phases.draft)
-        try:
-            if opts.get('secret'):
-                commitphase = 'secret'
-            else:
-                commitphase = old.phase()
-            repo.ui.setconfig('phases', 'new-commit', commitphase, 'amend')
+        if opts.get('secret'):
+            commitphase = 'secret'
+        else:
+            commitphase = old.phase()
+        overrides = {('phases', 'new-commit'): commitphase}
+        with ui.configoverride(overrides, 'amend'):
             newid = repo.commitctx(new)
-        finally:
-            repo.ui.setconfig('phases', 'new-commit', ph, 'amend')
 
         # Reroute the working copy parent to the new changeset
         repo.setparents(newid, nullid)



To: martinvonz, #hg-reviewers, singhsrb
Cc: singhsrb, mercurial-devel


More information about the Mercurial-devel mailing list