# HG changeset patch # User Pierre-Yves David # Date 1335960501 -7200 # Node ID cfdab01ca8a08e5af747e3031031770bc2085189 # Parent ace5608350b61dd794f86b7e72f5d57aa1fe4d51 evolve-amend: properly handle amending file renames and additions. diff -r ace5608350b6 -r cfdab01ca8a0 hgext/evolve.py --- a/hgext/evolve.py Thu Apr 26 16:49:15 2012 +0200 +++ b/hgext/evolve.py Wed May 02 14:08:21 2012 +0200 @@ -17,8 +17,9 @@ from mercurial import commands from mercurial import bookmarks from mercurial import phases +from mercurial import commands from mercurial import context -from mercurial import commands +from mercurial import copies from mercurial import util from mercurial.i18n import _ from mercurial.commands import walkopts, commitopts, commitopts2, logopts @@ -69,6 +70,11 @@ files = set(old.files()) for u in updates: files.update(u.files()) + + # Recompute copies (avoid recording a -> b -> a) + copied = copies.pathcopies(base, head) + + # prune files which were reverted by the updates def samefile(f): if f in head.manifest(): @@ -76,8 +82,7 @@ if f in base.manifest(): b = base.filectx(f) return (a.data() == b.data() - and a.flags() == b.flags() - and a.renamed() == b.renamed()) + and a.flags() == b.flags()) else: return False else: @@ -87,7 +92,13 @@ headmf = head.manifest() def filectxfn(repo, ctx, path): if path in headmf: - return head.filectx(path) + fctx = head[path] + flags = fctx.flags() + mctx = context.memfilectx(fctx.path(), fctx.data(), + islink='l' in flags, + isexec='x' in flags, + copied=copied.get(path)) + return mctx raise IOError() if commitopts.get('message') and commitopts.get('logfile'): raise util.Abort(_('options --message and --logfile are mutually' diff -r ace5608350b6 -r cfdab01ca8a0 tests/test-evolve.t --- a/tests/test-evolve.t Thu Apr 26 16:49:15 2012 +0200 +++ b/tests/test-evolve.t Wed May 02 14:08:21 2012 +0200 @@ -297,6 +297,20 @@ $ hg mv A B $ echo '.' >> B $ hg amend -m 'add B' + $ hg verify + checking changesets + checking manifests + crosschecking files in changesets and manifests + checking files + 3 files, 4 changesets, 4 total revisions + $ hg --config extensions.hgext.mq= strip 'extinct()' + saved backup bundle to $TESTTMP/alpha/.hg/strip-backup/e87767087a57-backup.hg + $ hg verify + checking changesets + checking manifests + crosschecking files in changesets and manifests + checking files + 2 files, 2 changesets, 2 total revisions $ cd .. Clone just this branch