changeset 219:cfdab01ca8a0

evolve-amend: properly handle amending file renames and additions.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 02 May 2012 14:08:21 +0200
parents ace5608350b6
children ff3158d0d7e8
files hgext/evolve.py tests/test-evolve.t
diffstat 2 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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'
--- 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