compat: avoid using configoveride
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 25 Jul 2017 05:14:37 +0200
changeset 2795 0dc119ed06b4
parent 2794 5595fb96d922
child 2796 0fd701dbfcc6
compat: avoid using configoveride This not supported before mercurial 4.1.
hgext3rd/evolve/__init__.py
hgext3rd/topic/__init__.py
--- a/hgext3rd/evolve/__init__.py	Tue Jul 25 04:19:55 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Tue Jul 25 05:14:37 2017 +0200
@@ -2018,11 +2018,14 @@
         target, bookmark = _findprevtarget(repo, displayer,
                                            opts.get('move_bookmark'), topic)
         if target is not None:
-            overrides = {}
-            if topic and _getcurrenttopic(repo) != _gettopic(target):
-                overrides[('_internal', 'keep-topic')] = 'yes'
-            with repo.ui.configoverride(overrides, source='topic-extension'):
+            backup = repo.ui.backupconfig('_internal', 'keep-topic')
+            try:
+                if topic and _getcurrenttopic(repo) != _gettopic(target):
+                    repo.ui.setconfig('_internal', 'keep-topic', 'yes',
+                                      source='topic-extension')
                 _prevupdate(repo, displayer, target, bookmark, dryrunopt)
+            finally:
+                repo.ui.restoreconfig(backup)
             return 0
         else:
             return 1
--- a/hgext3rd/topic/__init__.py	Tue Jul 25 04:19:55 2017 +0200
+++ b/hgext3rd/topic/__init__.py	Tue Jul 25 05:14:37 2017 +0200
@@ -656,11 +656,14 @@
 def checkt0(orig, ui, repo, node=None, rev=None, *args, **kwargs):
 
     thezeros = set(['t0', 'b0'])
-    overrides = {}
-    if node in thezeros or rev in thezeros:
-        overrides[('_internal', 'keep-topic')] = 'yes'
-    with repo.ui.configoverride(overrides, source='topic-extension'):
+    backup = repo.ui.backupconfig('_internal', 'keep-topic')
+    try:
+        if node in thezeros or rev in thezeros:
+            repo.ui.setconfig('_internal', 'keep-topic', 'yes',
+                              source='topic-extension')
         return orig(ui, repo, node, rev, *args, **kwargs)
+    finally:
+        repo.ui.restoreconfig(backup)
 
 def _fixrebase(loaded):
     if not loaded: