Mercurial > evolve
changeset 5007:de0151ba3e46
topic: use ui.configoverride() instead of ui.backupconfig()
ui.configoverride() was added in hg 4.1. util.nullcontextmanager() was
added in hg 4.4.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 09 Dec 2019 10:28:58 -0800 |
parents | 93014d9726d5 |
children | 848ca807f83a |
files | hgext3rd/topic/__init__.py |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)