[PATCH 6 of 6] commit: add option to amend the working dir parent
Matt Mackall
mpm at selenic.com
Thu Mar 8 20:07:31 UTC 2012
On Tue, 2012-03-06 at 18:44 +0200, Idan Kamara wrote:
> + # First, do a regular commit to record all changes in the working
> + # directory (if there are any)
> + node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
> + ctx = repo[node]
> + base = old.p1()
> +
> + # Participating changesets:
> + #
> + # node/ctx o - new (intermediate) commit that contains changes from
> + # | working dir to go into amending commit (or a workingctx
> + # | if there were no changes)
> + # |
> + # old o - changeset to amend
> + # |
> + # base o - parent of amending changeset
This seems overcomplicated. Can't we simply do the equivalent of:
debugsetparents <parents of commit to amend>
commit -m <old commit message> # snapshot the current state
strip -r <old commit>
> + # If old had a copy/move X -> Y and now we have Y -> Z,
> + # we want Z's rename to point to X
> + r = fctx.renamed()
> + if r:
> + ofctx = old.filectx(r[0])
> + rr = ofctx.renamed()
> + if rr:
> + fctx.renamed = lambda: rr
> + return fctx
Please take a look at copies.pathcopies(), which will do the right thing
for chaining the copies in old.p1 -> old -> current. Graft and rebase
use the help function scmutil.duplicatecopies() to fixup the dirstate,
which probably also applies here.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list