configwizard: prompt to configure wip (
bug 1277406); r=glob
Should be a straight port.
MozReview-Commit-ID: 5HVm5WiMTXW
--- a/hgext/configwizard/__init__.py
+++ b/hgext/configwizard/__init__.py
@@ -89,16 +89,41 @@ Newer versions of Mercurial have built-i
filesystem watching services to make common operations faster.
This integration is STRONGLY RECOMMENDED when using the Firefox
repository.
Please upgrade to Mercurial 3.8+ so this feature is available.
'''.lstrip()
+WIP_INFO = '''
+It is common to want a quick view of changesets that are in progress.
+
+The ``hg wip`` command provides such 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 (Yn)? $$ &Yes $$ &No
+'''.lstrip()
+
FIREFOXTREE_INFO = '''
The firefoxtree extension makes interacting with the multiple Firefox
repositories easier:
* Aliases for common trees are pre-defined. e.g. `hg pull central`
* Pulling from known Firefox trees will create "remote refs" appearing as
tags. e.g. pulling from fx-team will produce a "fx-team" tag.
* The `hg fxheads` command will list the heads of all pulled Firefox repos
@@ -184,16 +209,17 @@ command = cmdutil.command(cmdtable)
wizardsteps = {
'hgversion',
'username',
'diff',
'color',
'historyediting',
'fsmonitor',
+ 'wip',
'firefoxtree',
'codereview',
'pushtotry',
'configchange',
}
@command('configwizard', [
('s', 'statedir', '', _('directory to store state')),
@@ -230,16 +256,19 @@ def configwizard(ui, repo, statedir=None
_promptnativeextension(ui, cw, 'color', 'Enable color output to your terminal')
if 'historyediting' in runsteps:
_checkhistoryediting(ui, cw)
if 'fsmonitor' in runsteps:
_checkfsmonitor(ui, cw, hgversion)
+ if 'wip' in runsteps:
+ _checkwip(ui, cw)
+
if 'firefoxtree' in runsteps:
_promptvctextension(ui, cw, 'firefoxtree', FIREFOXTREE_INFO)
if 'codereview' in runsteps:
_checkcodereview(ui, cw)
if 'pushtotry' in runsteps:
_promptvctextension(ui, cw, 'push-to-try', PUSHTOTRY_INFO)
@@ -404,16 +433,57 @@ def _checkfsmonitor(ui, cw, hgversion):
# Mercurial 3.8+ has fsmonitor built-in.
if hgversion >= (3, 8, 0):
_promptnativeextension(ui, cw, 'fsmonitor', FSMONITOR_INFO)
else:
ui.write(FSMONITOR_NOT_AVAILABLE)
+def _checkwip(ui, cw):
+ havewip = ui.hasconfig('alias', 'wip')
+
+ if not havewip and ui.promptchoice(WIP_INFO):
+ return
+
+ # The wip configuration changes over time. Ensure it is up to date.
+ cw.c.setdefault('alias', {})
+ cw.c.setdefault('revsetalias', {})
+ cw.c.setdefault('templates', {})
+
+ cw.c['alias']['wip'] = 'log --graph --rev=wip --template=wip'
+
+ cw.c['revsetalias']['wip'] = ('('
+ 'parents(not public()) '
+ 'or not public() '
+ 'or . '
+ 'or (head() and branch(default))'
+ ') and (not obsolete() or unstable()^) '
+ 'and not closed()')
+
+ cw.c['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.tag", if(fxheads," {fxheads}"))} '
+ '{label("log.bookmark", if(bookmarks," {bookmarks}"))}'
+ '\\n'
+ # first line of commit message
+ '{label(ifcontains(rev, revset("."), "desc.here"),desc|firstline)}'
+ "'"
+ )
+
+
def _checkcodereview(ui, cw):
# We don't check for bzexport if reviewboard is enabled because
# bzexport is legacy.
if ui.hasconfig('extensions', 'reviewboard'):
return
if ui.promptchoice('Will you be submitting commits to Mozilla (Yn)? $$ &Yes $$ &No'):
return
--- a/hgext/configwizard/hgsetup/config.py
+++ b/hgext/configwizard/hgsetup/config.py
@@ -39,45 +39,8 @@ class MercurialConfig(object):
"""
if not path:
path = ''
if 'extensions' not in self._c:
self._c['extensions'] = {}
self._c['extensions'][name] = path
-
- 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.tag", if(fxheads," {fxheads}"))} '
- '{label("log.bookmark", if(bookmarks," {bookmarks}"))}'
- '\\n'
- # first line of commit message
- '{label(ifcontains(rev, revset("."), "desc.here"),desc|firstline)}'
- "'"
- )
--- a/hgext/configwizard/hgsetup/wizard.py
+++ b/hgext/configwizard/hgsetup/wizard.py
@@ -27,41 +27,16 @@ from .config import (
ParseException,
)
FINISHED = '''
Your Mercurial should now be properly configured and recommended extensions
should be up to date!
'''.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 = '''
@@ -98,20 +73,16 @@ class MercurialSetupWizard(object):
hg = get_hg_path()
config_path = config_file(config_paths)
self.updater.update_all()
hg_version = get_hg_version(hg)
- if not c.have_wip():
- if self._prompt_yn(WIP_INFO):
- c.install_wip_alias()
-
# Look for and clean up old extensions.
for ext in {'bzexport', 'qimportbz', 'mqext'}:
path = os.path.join(self.ext_dir, ext)
if os.path.exists(path):
if self._prompt_yn('Would you like to remove the old and no '
'longer referenced repository at %s' % path):
print('Cleaning up old repository: %s' % path)
shutil.rmtree(path)
new file mode 100644
--- /dev/null
+++ b/hgext/configwizard/tests/test-wip.t
@@ -0,0 +1,91 @@
+ $ . $TESTDIR/hgext/configwizard/tests/helpers.sh
+
+Rejecting wip doesn't install it
+
+ $ hg --config ui.interactive=true --config configwizard.steps=wip,configchange configwizard << EOF
+ >
+ > n
+ > EOF
+ This wizard will guide you through configuring Mercurial for an optimal
+ experience contributing to Mozilla projects.
+
+ The wizard makes no changes without your permission.
+
+ To begin, press the enter/return key.
+ <RETURN>
+ It is common to want a quick view of changesets that are in progress.
+
+ The ``hg wip`` command provides such 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 (Yn)? n
+
+wip enabled when requested
+
+ $ hg --config configwizard.steps=wip,configchange configwizard
+ This wizard will guide you through configuring Mercurial for an optimal
+ experience contributing to Mozilla projects.
+
+ The wizard makes no changes without your permission.
+
+ To begin, press the enter/return key.
+ <RETURN>
+ It is common to want a quick view of changesets that are in progress.
+
+ The ``hg wip`` command provides such 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 (Yn)? y
+ Your config file needs updating.
+ Would you like to see a diff of the changes first (Yn)? y
+ --- hgrc.old
+ +++ hgrc.new
+ @@ -0,0 +1,6 @@
+ +[alias]
+ +wip = log --graph --rev=wip --template=wip
+ +[revsetalias]
+ +wip = (parents(not public()) or not public() or . or (head() and branch(default))) and (not obsolete() or unstable()^) and not closed()
+ +[templates]
+ +wip = '{label("log.branch", branches)} {label("changeset.{phase}", rev)}{label("changeset.{phase}", ":")}{label("changeset.{phase}", short(node))} {label("grep.user", author|user)}{label("log.tag", if(tags," {tags}"))}{label("log.tag", if(fxheads," {fxheads}"))} {label("log.bookmark", if(bookmarks," {bookmarks}"))}\n{label(ifcontains(rev, revset("."), "desc.here"),desc|firstline)}'
+
+ Write changes to hgrc file (Yn)? y
+
+ $ cat .hgrc
+ [alias]
+ wip = log --graph --rev=wip --template=wip
+ [revsetalias]
+ wip = (parents(not public()) or not public() or . or (head() and branch(default))) and (not obsolete() or unstable()^) and not closed()
+ [templates]
+ wip = '{label("log.branch", branches)} {label("changeset.{phase}", rev)}{label("changeset.{phase}", ":")}{label("changeset.{phase}", short(node))} {label("grep.user", author|user)}{label("log.tag", if(tags," {tags}"))}{label("log.tag", if(fxheads," {fxheads}"))} {label("log.bookmark", if(bookmarks," {bookmarks}"))}\n{label(ifcontains(rev, revset("."), "desc.here"),desc|firstline)}'