diff --git a/tools/mercurial/hgsetup/config.py b/tools/mercurial/hgsetup/config.py index b5b20ef50d2e5ab5f2fb8f74a1bb4cf4d47b3d7f..650d5a6cb2ac847738e3ce69fbcd9962d4f5a2e7 100644 --- a/tools/mercurial/hgsetup/config.py +++ b/tools/mercurial/hgsetup/config.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals from configobj import ConfigObj +import re BUGZILLA_FINGERPRINT = '45:77:35:fd:6f:2c:1c:c2:90:4b:f7:b4:4d:60:c6:97:c5:5c:47:27' @@ -115,3 +116,30 @@ class MercurialConfig(object): del self._c['mqext']['mqcommit'] except KeyError: pass + + + def have_qnew_currentuser_default(self): + if 'defaults' not in self._c: + return False + d = self._c['defaults'] + if 'qnew' not in d: + return False + argv = d['qnew'].split(' ') + for arg in argv: + if arg == '--currentuser' or re.match("-[^-]*U.*", arg): + return True + return False + + def ensure_qnew_currentuser_default(self): + if self.have_qnew_currentuser_default(): + return + if 'defaults' not in self._c: + self._c['defaults'] = {} + + d = self._c['defaults'] + if 'qnew' not in d: + d['qnew'] = '-U' + else: + d['qnew'] = '-U ' + d['qnew'] + + diff --git a/tools/mercurial/hgsetup/wizard.py b/tools/mercurial/hgsetup/wizard.py index 979ebfb191af7641342551ee0c1e55e4a0e8e918..6317e5834b4653ede538598daf5825e899b9739a 100644 --- a/tools/mercurial/hgsetup/wizard.py +++ b/tools/mercurial/hgsetup/wizard.py @@ -71,6 +71,12 @@ import patches from Bugzilla using a friendly bz:// URL handler. e.g. |hg qimport bz://123456|. '''.strip() +QNEWCURRENTUSER_INFO = ''' +The mercurial queues command |hg qnew|, which creates new patches in your patch +queue does not set patch author information by default. Author information +should be included when uploading for review. +'''.strip() + FINISHED = ''' Your Mercurial should now be properly configured and recommended extensions should be up to date! @@ -204,6 +210,14 @@ class MercurialSetupWizard(object): 'default', 'Ensuring qimportbz extension is up to date...') + if not c.have_qnew_currentuser_default(): + print(QNEWCURRENTUSER_INFO) + if self._prompt_yn('Would you like qnew to set patch author by ' + 'default'): + c.ensure_qnew_currentuser_default() + print('Configured qnew to set patch author by default.') + print('') + c.add_mozilla_host_fingerprints() b = StringIO()