Commits

Pierre-Yves David  committed cfdab01

evolve-amend: properly handle amending file renames and additions.

  • Participants
  • Parent commits ace5608

Comments (0)

Files changed (2)

File hgext/evolve.py

 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
         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():
                 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:
         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'

File tests/test-evolve.t

   $ 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