# HG changeset patch # User Pierre-Yves David # Date 1499765083 -7200 # Node ID 7fbb7a5d359f9e1fd4c0737025818ef41fc07834 # Parent 69fe16428b0f12915a88f7eadf35b3c5499a1f80 uncommit: expose the feature with a '--extract' to amend The name of the "uncommit" feature have been an ongoing issue, but no better name have been found in the past year. We try another approach by exposing the 'uncommit' feature directly in `hg amend`. The command will not be able to do both operation a the same time (add new change to the commit + extract should change, but this is already the case with the two command today. diff -r 69fe16428b0f -r 7fbb7a5d359f README --- a/README Tue Jul 11 12:00:45 2017 +0200 +++ b/README Tue Jul 11 11:24:43 2017 +0200 @@ -124,6 +124,8 @@ 6.6.0 - in progress ------------------- + - amend: add a --extract flag to move change back to the working copy + (same as uncommit, but accessible through the amend commit) - topic: add a 't0' to access the root of a topic while keeping it active, - topic: allow 'hg prev' to me move to 't0', - topic: add a config option to enforce topic on new commit diff -r 69fe16428b0f -r 7fbb7a5d359f hgext3rd/evolve/evocommands.py --- a/hgext3rd/evolve/evocommands.py Tue Jul 11 12:00:45 2017 +0200 +++ b/hgext3rd/evolve/evocommands.py Tue Jul 11 11:24:43 2017 +0200 @@ -82,7 +82,9 @@ 'amend|refresh', [('A', 'addremove', None, _('mark new/missing files as added/removed before committing')), + ('a', 'all', False, _("match all files")), ('e', 'edit', False, _('invoke editor on commit messages')), + ('', 'extract', False, _('extract changes from the commit to the working copy')), ('', 'close-branch', None, _('mark a branch as closed, hiding it from the branch list')), ('s', 'secret', None, _('use the secret phase for committing')), @@ -98,17 +100,31 @@ If you don't specify -m, the parent's message will be reused. + If --extra is specified, the behavior of `hg amend` is reversed: Changes + to selected files in the checked out revision appear again as uncommitted + changed in the working directory. + Returns 0 on success, 1 if nothing changed. """ opts = opts.copy() - edit = opts.pop('edit', False) - log = opts.get('logfile') - opts['amend'] = True - if not (edit or opts['message'] or log): - opts['message'] = repo['.'].description() - _resolveoptions(ui, opts) - _alias, commitcmd = cmdutil.findcmd('commit', commands.table) - return commitcmd[0](ui, repo, *pats, **opts) + if opts.get('extract'): + if opts.pop('interactive', False): + msg = _('not support for --interactive with --extract yet') + raise error.Abort(msg) + return uncommit(ui, repo, *pats, **opts) + else: + if opts.pop('all', False): + # add an include for all + include = list(opts.get('include')) + include.append('re:.*') + edit = opts.pop('edit', False) + log = opts.get('logfile') + opts['amend'] = True + if not (edit or opts['message'] or log): + opts['message'] = repo['.'].description() + _resolveoptions(ui, opts) + _alias, commitcmd = cmdutil.findcmd('commit', commands.table) + return commitcmd[0](ui, repo, *pats, **opts) def _touchedbetween(repo, source, dest, match=None): touched = set() diff -r 69fe16428b0f -r 7fbb7a5d359f tests/test-amend.t --- a/tests/test-amend.t Tue Jul 11 12:00:45 2017 +0200 +++ b/tests/test-amend.t Tue Jul 11 11:24:43 2017 +0200 @@ -132,13 +132,19 @@ If you don't specify -m, the parent's message will be reused. + If --extra is specified, the behavior of 'hg amend' is reversed: Changes + to selected files in the checked out revision appear again as uncommitted + changed in the working directory. + Returns 0 on success, 1 if nothing changed. options ([+] can be repeated): -A --addremove mark new/missing files as added/removed before committing + -a --all match all files -e --edit invoke editor on commit messages + --extract extract changes from the commit to the working copy --close-branch mark a branch as closed, hiding it from the branch list -s --secret use the secret phase for committing diff -r 69fe16428b0f -r 7fbb7a5d359f tests/test-uncommit.t --- a/tests/test-uncommit.t Tue Jul 11 12:00:45 2017 +0200 +++ b/tests/test-uncommit.t Tue Jul 11 11:24:43 2017 +0200 @@ -397,3 +397,64 @@ date: Thu Jan 01 00:22:17 1970 +0000 summary: to-uncommit + +test the `hg amend --extract` entry point + + $ hg status --change . + M j + M o + A e + A ff + A h + A k + A l + R c + R f + R g + R m + R n + $ hg status + M d + A aa + R b + $ hg amend --extract j + $ hg status --change . + M o + A e + A ff + A h + A k + A l + R c + R f + R g + R m + R n + $ hg status + M d + M j + A aa + R b + +(with all) + + $ hg amend --extract --all + new changeset is empty + (use 'hg prune .' to remove it) + $ hg status --change . + $ hg status + M d + M j + M o + A aa + A e + A ff + A h + A k + A l + R b + R c + R f + R g + R m + R n