evolve: use ui.configoverride() instead of ui.backupconfig()
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 09 Dec 2019 10:36:11 -0800
changeset 5009 0ab3b94562ab
parent 5008 848ca807f83a
child 5010 effce0a1f5bd
child 5224 0a6aee4b4947
evolve: use ui.configoverride() instead of ui.backupconfig() ui.configoverride() was added in hg 4.1. util.nullcontextmanager() was added in hg 4.4.
hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py	Mon Dec 09 10:31:34 2019 -0800
+++ b/hgext3rd/evolve/__init__.py	Mon Dec 09 10:36:11 2019 -0800
@@ -1026,15 +1026,14 @@
         target, bookmark = _findprevtarget(repo, displayer,
                                            opts.get('move_bookmark'), topic)
         if target is not None:
-            backup = repo.ui.backupconfig(b'_internal', b'keep-topic')
-            try:
-                if topic and _getcurrenttopic(repo) != _gettopic(target):
-                    repo.ui.setconfig(b'_internal', b'keep-topic', b'yes',
-                                      source=b'topic-extension')
+            configoverride = util.nullcontextmanager()
+            if topic and _getcurrenttopic(repo) != _gettopic(target):
+                configoverride = repo.ui.configoverride({
+                    (b'_internal', b'keep-topic'): b'yes'
+                }, source=b'topic-extension')
+            with configoverride:
                 _prevupdate(repo, displayer, target, bookmark, dryrunopt,
                             mergeopt)
-            finally:
-                repo.ui.restoreconfig(backup)
             return 0
         else:
             return 1