diff hgext/evolve.py @ 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 69a37d56c7fb
children 5a17c0d41a00
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'