Skip to content

Commit

Permalink
configwizard: enable the absorb extension on 4.8+ (bug 1504765); r=sh…
Browse files Browse the repository at this point in the history
…eehan

Let's lump it in with other history editing extensions.

Differential Revision: https://phabricator.services.mozilla.com/D11513

--HG--
extra : moz-landing-system : lando
  • Loading branch information
indygreg committed Nov 9, 2018
1 parent 773c0e8 commit dcc39ea
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 7 deletions.
35 changes: 32 additions & 3 deletions hgext/configwizard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,32 @@
Would you like to activate push-to-try (Yn)? $$ &Yes $$ &No
'''.strip()

HISTORY_EDITING_INFO = '''
Various extensions provide functionality to rewrite repository history. These
enable more powerful - and often more productive - workflows.
If history rewriting is enabled, the following extensions will be enabled:
absorb
`hg absorb` automatically squashes/folds uncommitted changes in the working
directory into the appropriate previous changeset. Learn more at
https://gregoryszorc.com/blog/2018/11/05/absorbing-commit-changes-in-mercurial-4.8/.
histedit
`hg histedit` allows interactive editing of previous changesets. It presents
you a list of changesets and allows you to pick actions to perform on each
changeset. Actions include reordering changesets, dropping changesets,
folding multiple changesets together, and editing the commit message for
a changeset.
rebase
`hg rebase` allows re-parenting changesets from one "branch" of a DAG
to another. The command is typically used to "move" changesets based on
an older changeset to be based on the newest changeset.
Would you like to enable these history editing extensions (Yn)? $$ &Yes $$ &No
'''.strip()


EVOLVE_INFO_WARNING = '''
The evolve extension is an experimental extension for faster and
Expand Down Expand Up @@ -459,7 +485,7 @@ def configwizard(ui, repo, statedir=None, **opts):
_checkcurses(ui, cw)

if 'historyediting' in runsteps:
_checkhistoryediting(ui, cw)
_checkhistoryediting(ui, cw, hgversion)

if 'evolve' in runsteps:
_checkevolve(ui, cw, hgversion)
Expand Down Expand Up @@ -787,13 +813,16 @@ def _checkcurses(ui, cw):
cw.c['ui']['interface'] = 'curses'


def _checkhistoryediting(ui, cw):
def _checkhistoryediting(ui, cw, hg_version):
extensions = {'histedit', 'rebase'}

if hg_version >= (4, 8, 0):
extensions.add('absorb')

if all(ui.hasconfig('extensions', e) for e in extensions):
return

if ui.promptchoice('Enable history rewriting commands (Yn)? $$ &Yes $$ &No'):
if uipromptchoice(ui, HISTORY_EDITING_INFO):
return

if 'extensions' not in cw.c:
Expand Down
67 changes: 63 additions & 4 deletions hgext/configwizard/tests/test-historyediting.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,44 @@ Rejecting history editing doesn't enable extensions
To begin, press the enter/return key.
<RETURN>
Enable history rewriting commands (Yn)? n
Various extensions provide functionality to rewrite repository history. These
enable more powerful - and often more productive - workflows.
If history rewriting is enabled, the following extensions will be enabled:
absorb
`hg absorb` automatically squashes/folds uncommitted changes in the working
directory into the appropriate previous changeset. Learn more at
https://gregoryszorc.com/blog/2018/11/05/absorbing-commit-changes-in-mercurial-4.8/.
histedit
`hg histedit` allows interactive editing of previous changesets. It presents
you a list of changesets and allows you to pick actions to perform on each
changeset. Actions include reordering changesets, dropping changesets,
folding multiple changesets together, and editing the commit message for
a changeset.
rebase
`hg rebase` allows re-parenting changesets from one "branch" of a DAG
to another. The command is typically used to "move" changesets based on
an older changeset to be based on the newest changeset.
Would you like to enable these history editing extensions (Yn)? n
No prompt if extensions already enabled
#if hg48
$ hg --config configwizard.steps=historyediting --config extensions.absorb= --config extensions.histedit= --config extensions.rebase= 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>
#else
$ hg --config configwizard.steps=historyediting --config extensions.histedit= --config extensions.rebase= configwizard
This wizard will guide you through configuring Mercurial for an optimal
experience contributing to Mozilla projects.
Expand All @@ -27,7 +60,9 @@ No prompt if extensions already enabled
To begin, press the enter/return key.
<RETURN>
histedit and rebase enabled when appropriate
#endif
absorb, histedit, and rebase enabled when appropriate
$ hg --config configwizard.steps=historyediting,configchange configwizard
This wizard will guide you through configuring Mercurial for an optimal
Expand All @@ -37,19 +72,43 @@ histedit and rebase enabled when appropriate
To begin, press the enter/return key.
<RETURN>
Enable history rewriting commands (Yn)? y
Various extensions provide functionality to rewrite repository history. These
enable more powerful - and often more productive - workflows.
If history rewriting is enabled, the following extensions will be enabled:
absorb
`hg absorb` automatically squashes/folds uncommitted changes in the working
directory into the appropriate previous changeset. Learn more at
https://gregoryszorc.com/blog/2018/11/05/absorbing-commit-changes-in-mercurial-4.8/.
histedit
`hg histedit` allows interactive editing of previous changesets. It presents
you a list of changesets and allows you to pick actions to perform on each
changeset. Actions include reordering changesets, dropping changesets,
folding multiple changesets together, and editing the commit message for
a changeset.
rebase
`hg rebase` allows re-parenting changesets from one "branch" of a DAG
to another. The command is typically used to "move" changesets based on
an older changeset to be based on the newest changeset.
Would you like to enable these history editing extensions (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,3 @@
@@ -0,0 +1,* @@ (glob)
+[extensions]
+absorb = (hg48 !)
+histedit =
+rebase =
Write changes to hgrc file (Yn)? y
$ cat .hgrc
[extensions]
absorb = (hg48 !)
histedit =
rebase =

0 comments on commit dcc39ea

Please sign in to comment.