[PATCH] amend: add keep parameter to cmdutil.amend

Durham Goode durham at fb.com
Thu May 2 19:26:44 CDT 2013

# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1367539398 25200
#      Thu May 02 17:03:18 2013 -0700
# Node ID 6406230e4a8ae8ebc412621c86ab464092d99653
# Parent  a047d5348816e0aa561c072cdd603e0933d520b5
amend: add keep parameter to cmdutil.amend

An extension I'm working on wants to use cmdutil.amend without it stripping
the original revisions. This change adds an optional flag to allow that.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1611,7 +1611,7 @@
     return commitfunc(ui, repo, message,
                       scmutil.match(repo[None], pats, opts), opts)
-def amend(ui, repo, commitfunc, old, extra, pats, opts):
+def amend(ui, repo, commitfunc, old, extra, pats, opts, keep=False):
     ui.note(_('amending changeset %s\n') % old)
     base = old.p1()
@@ -1786,7 +1786,11 @@
             if node:
                 ui.note(_('stripping intermediate changeset %s\n') % ctx)
             ui.note(_('stripping amended changeset %s\n') % old)
-            repair.strip(ui, repo, old.node(), topic='amend-backup')
+            if not keep:
+                repair.strip(ui, repo, old.node(), topic='amend-backup')
+            elif node:
+                # strip only the temporary commit
+                repair.strip(ui, repo, node, backup='none')
         if newid is None:

More information about the Mercurial-devel mailing list