diff --git a/tools/mercurial/hgsetup/config.py b/tools/mercurial/hgsetup/config.py index 14a981d54e18..9ee9c505f2db 100644 --- a/tools/mercurial/hgsetup/config.py +++ b/tools/mercurial/hgsetup/config.py @@ -121,17 +121,18 @@ class MercurialConfig(object): d['showfunc'] = 1 d['unified'] = 8 - def autocommit_mq(self, value=True): + def have_mqext_autocommit_mq(self): + if 'mqext' not in self._c: + return False + v = self._c['mqext'].get('mqcommit') + return v == 'auto' or v == 'yes' + + def ensure_mqext_autocommit_mq(self): + if self.have_mqext_autocommit_mq(): + return if 'mqext' not in self._c: self._c['mqext'] = {} - - if value: - self._c['mqext']['mqcommit'] = 'auto' - else: - try: - del self._c['mqext']['mqcommit'] - except KeyError: - pass + self._c['mqext']['mqcommit'] = 'auto' def have_qnew_currentuser_default(self): if 'defaults' not in self._c: diff --git a/tools/mercurial/hgsetup/wizard.py b/tools/mercurial/hgsetup/wizard.py index 45ae2025d8d1..7931b5662b18 100644 --- a/tools/mercurial/hgsetup/wizard.py +++ b/tools/mercurial/hgsetup/wizard.py @@ -169,9 +169,11 @@ class MercurialSetupWizard(object): os.path.join(self.ext_dir, 'mqext'), 'default', 'Ensuring mqext extension is up to date...') + + if 'mqext' in c.extensions and not c.have_mqext_autocommit_mq(): if self._prompt_yn('Would you like to configure mqext to ' 'automatically commit changes as you modify patches'): - c.autocommit_mq(True) + c.ensure_mqext_autocommit_mq() print('Configured mqext to auto-commit.\n') self.prompt_external_extension(c, 'qimportbz', QIMPORTBZ_INFO)