Bug 910658 - Add "qnew = -U" to defaults section in mach mercurial-setup; r=gps
authorJonas Finnemann Jensen <jopsen@gmail.com>
Wed, 04 Sep 2013 15:32:00 -0700
changeset 145539 d9ad02ac2fcb9371aa177112c50d9058ca4cee79
parent 145538 45097bc3a57898f22a4f3b74f8f8cf7511f5d0a4
child 145540 0016284ded203e24f5fcad2cf9277e1c9477435f
push id33314
push usergszorc@mozilla.com
push dateThu, 05 Sep 2013 00:14:13 +0000
treeherdermozilla-inbound@d9ad02ac2fcb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs910658
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 910658 - Add "qnew = -U" to defaults section in mach mercurial-setup; r=gps DONTBUILD (NPOTB)
tools/mercurial/hgsetup/config.py
tools/mercurial/hgsetup/wizard.py
--- a/tools/mercurial/hgsetup/config.py
+++ b/tools/mercurial/hgsetup/config.py
@@ -1,15 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this,
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 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'
 HG_FINGERPRINT = '10:78:e8:57:2d:95:de:7c:de:90:bd:22:e1:38:17:67:c5:a7:9c:14'
 
 
 class MercurialConfig(object):
     """Interface for manipulating a Mercurial config file."""
@@ -110,8 +111,35 @@ class MercurialConfig(object):
 
         if value:
             self._c['mqext']['mqcommit'] = 'auto'
         else:
             try:
                 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']
+
+
--- a/tools/mercurial/hgsetup/wizard.py
+++ b/tools/mercurial/hgsetup/wizard.py
@@ -66,16 +66,22 @@ your mq patch queue.
 
 QIMPORTBZ_INFO = '''
 The qimportbz extension
 (https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz) makes it possible to
 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!
 '''.strip()
 
 
 class MercurialSetupWizard(object):
     """Command-line wizard to help users configure Mercurial."""
@@ -199,16 +205,24 @@ class MercurialSetupWizard(object):
             if update_qimportbz:
                 self.update_mercurial_repo(
                     hg,
                     'https://hg.mozilla.org/users/robarnold_cmu.edu/qimportbz',
                     os.path.join(self.ext_dir, 'qimportbz'),
                     '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()
         c.write(b)
         new_lines = [line.rstrip() for line in b.getvalue().splitlines()]
         old_lines = []
 
         if os.path.exists(config_path):