Submitter | Durham Goode |
---|---|
Date | May 3, 2013, 12:26 a.m. |
Message ID | <6406230e4a8ae8ebc412.1367540804@dev350.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/1536/ |
State | Changes Requested, archived |
Headers | show |
Comments
On Thu, May 02, 2013 at 05:26:44PM -0700, Durham Goode wrote: > # HG changeset patch > # User Durham Goode <durham@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. What kind of usage can that be ? This probably deserve a test if you want it to keep it working.
On 5/3/13 1:07 AM, "Pierre-Yves David" <pierre-yves.david@logilab.fr> wrote: >On Thu, May 02, 2013 at 05:26:44PM -0700, Durham Goode wrote: >> # HG changeset patch >> # User Durham Goode <durham@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. > >What kind of usage can that be ? > >This probably deserve a test if you want it to keep it working. It's for an amend extension that lets you amend commit's with children. So I want to leave the old commit alive after the amend. I didn't feel this was worth bloating the tests with, especially since there is no core-mercurial user facing way of executing this code at the moment. If that means the code shouldn't be in mercurial at all, I can probably find a hacky way to do it purely in the extension.
Patch
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') finally: if newid is None: repo.dirstate.invalidate()