topic: use ui.configoverride() instead of ui.backupconfig()
ui.configoverride() was added in hg 4.1. util.nullcontextmanager() was
added in hg 4.4.
--- a/hgext3rd/topic/__init__.py Mon Dec 09 10:33:48 2019 -0800
+++ b/hgext3rd/topic/__init__.py Mon Dec 09 10:28:58 2019 -0800
@@ -385,14 +385,14 @@
return caps
def commit(self, *args, **kwargs):
- backup = self.ui.backupconfig(b'ui', b'allowemptycommit')
- try:
- if self.currenttopic != self[b'.'].topic():
- # bypass the core "nothing changed" logic
- self.ui.setconfig(b'ui', b'allowemptycommit', True)
+ configoverride = util.nullcontextmanager()
+ if self.currenttopic != self[b'.'].topic():
+ # bypass the core "nothing changed" logic
+ configoverride = self.ui.configoverride({
+ (b'ui', b'allowemptycommit'): True
+ })
+ with configoverride:
return super(topicrepo, self).commit(*args, **kwargs)
- finally:
- self.ui.restoreconfig(backup)
def commitctx(self, ctx, *args, **kwargs):
topicfilter = topicmap.topicfilter(self.filtername)