hgext3rd/evolve/evocommands.py
changeset 2730 7fbb7a5d359f
parent 2729 69fe16428b0f
child 2752 4457aa1d81aa
--- 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()