Bug 1231192 - Offer to install `hg wip`; r=smacleod
authorGregory Szorc <gps@mozilla.com>
Mon, 07 Dec 2015 13:22:49 -0800
changeset 275974 4b0aa51b8b602b349f149c156d92c0561318bec2
parent 275973 6791163296c13a7dc22b776fb08975026bdedeba
child 275975 093210ae72ecead5c6c9387da8ca87a4883d2f0a
push id69001
push userbind-autoland@mozilla.com
push dateWed, 09 Dec 2015 15:34:52 +0000
treeherdermozilla-inbound@093210ae72ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmacleod
bugs1231192
milestone45.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 1231192 - Offer to install `hg wip`; r=smacleod
tools/mercurial/hgsetup/config.py
tools/mercurial/hgsetup/wizard.py
--- a/tools/mercurial/hgsetup/config.py
+++ b/tools/mercurial/hgsetup/config.py
@@ -219,8 +219,44 @@ class MercurialConfig(object):
 
         # bundleclone is redundant with clonebundles. Remove it if it
         # is installed.
         ext = self._c.get('extensions', {})
         try:
             del ext['bundleclone']
         except KeyError:
             pass
+
+    def have_wip(self):
+        return 'wip' in self._c.get('alias', {})
+
+    def install_wip_alias(self):
+        """hg wip shows a concise view of work in progress."""
+        alias = self._c.setdefault('alias', {})
+        alias['wip'] = 'log --graph --rev=wip --template=wip'
+
+        revsetalias = self._c.setdefault('revsetalias', {})
+        revsetalias['wip'] = ('('
+                'parents(not public()) '
+                'or not public() '
+                'or . '
+                'or (head() and branch(default))'
+            ') and (not obsolete() or unstable()^) '
+            'and not closed()')
+
+        templates = self._c.setdefault('templates', {})
+        templates['wip'] = ("'"
+            # prefix with branch name
+            '{label("log.branch", branches)} '
+            # rev:node
+            '{label("changeset.{phase}", rev)}'
+            '{label("changeset.{phase}", ":")}'
+            '{label("changeset.{phase}", short(node))} '
+            # just the username part of the author, for brevity
+            '{label("grep.user", author|user)}'
+            # tags and bookmarks
+            '{label("log.tag", if(tags," {tags}"))} '
+            '{label("log.bookmark", if(bookmarks," {bookmarks}"))}'
+            '\\n'
+            # first line of commit message
+            '{label(ifcontains(rev, revset("."), "desc.here"),desc|firstline)}'
+            "'"
+        )
--- a/tools/mercurial/hgsetup/wizard.py
+++ b/tools/mercurial/hgsetup/wizard.py
@@ -227,16 +227,41 @@ The bundleclone extension makes cloning 
 
 We highly recommend you activate this extension.
 
 (Relevant config option: extensions.bundleclone)
 
 Would you like to activate bundleclone
 '''.strip()
 
+WIP_INFO = '''
+It is common to want a quick view of changesets that are in progress.
+
+The ``hg wip`` command provides should a view.
+
+Example Usage:
+
+  $ hg wip
+  o   4084:fcfa34d0387b dminor  @
+  |  mozreview: use repository name when displaying treeherder results (bug 1230548) r=mcote
+  | @   4083:786baf6d476a gps
+  | |  mozreview: create child review requests from batch API
+  | o   4082:3f100fa4a94f gps
+  | |  mozreview: copy more read-only processing code; r?smacleod
+  | o   4081:939417680cbe gps
+  |/   mozreview: add web API to submit an entire series of commits (bug 1229468); r?smacleod
+
+(Not shown are the colors that help denote the state each changeset
+is in.)
+
+(Relevant config options: alias.wip, revsetalias.wip, templates.wip)
+
+Would you like to install the `hg wip` alias?
+'''.strip()
+
 FILE_PERMISSIONS_WARNING = '''
 Your hgrc file is currently readable by others.
 
 Sensitive information such as your Bugzilla credentials could be
 stolen if others have access to this file/machine.
 '''.strip()
 
 MULTIPLE_VCT = '''
@@ -375,16 +400,20 @@ class MercurialSetupWizard(object):
                 c.activate_clonebundles()
                 print('Enabled the clonebundles feature.\n')
         elif hg_version >= BUNDLECLONE_MINIMUM_VERSION:
             self.prompt_external_extension(c, 'bundleclone', BUNDLECLONE_INFO)
 
         if hg_version >= PUSHTOTRY_MINIMUM_VERSION:
             self.prompt_external_extension(c, 'push-to-try', PUSHTOTRY_INFO)
 
+        if not c.have_wip():
+            if self._prompt_yn(WIP_INFO):
+                c.install_wip_alias()
+
         if 'mq' in c.extensions:
             self.prompt_external_extension(c, 'mqext', MQEXT_INFO)
 
             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.ensure_mqext_autocommit_mq()
                     print('Configured mqext to auto-commit.\n')