evolve: use ui.configoverride() instead of ui.backupconfig()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 09 Dec 2019 10:33:48 -0800
changeset 5006 93014d9726d5
parent 5005 e66ba12e5db3
child 5007 de0151ba3e46
evolve: use ui.configoverride() instead of ui.backupconfig() ui.configoverride() was added in hg 4.1.
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Mon Dec 09 10:43:04 2019 -0800
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Dec 09 10:33:48 2019 -0800
@@ -1022,16 +1022,14 @@
         del extra[b'branch']
     extra[b'rebase_source'] = orig.hex()
 
-    backup = repo.ui.backupconfig(b'phases', b'new-commit')
-    try:
-        targetphase = max(orig.phase(), phases.draft)
-        repo.ui.setconfig(b'phases', b'new-commit', targetphase, b'evolve')
+    targetphase = max(orig.phase(), phases.draft)
+    configoverride = repo.ui.configoverride({
+        (b'phases', b'new-commit'): targetphase
+    }, source=b'evolve')
+    with configoverride:
         # Commit might fail if unresolved files exist
-        nodenew = repo.commit(text=commitmsg, user=orig.user(),
-                              date=orig.date(), extra=extra)
-    finally:
-        repo.ui.restoreconfig(backup)
-    return nodenew
+        return repo.commit(text=commitmsg, user=orig.user(),
+                           date=orig.date(), extra=extra)
 
 def _finalizerelocate(repo, orig, dest, nodenew, tr, category, evolvestate):
     destbookmarks = repo.nodebookmarks(dest.node())