diff mercurial/localrepo.py @ 42620:d98ec36be808

convert: add a config option to help doing identity hg->hg conversion I want to change the computation of the list of files modified by a commit. In principle, this would simply change a cache. But since this information is stored in commits rather than a cache, changing it means changing commit hashes (going forward). Some users rely on the convert extension from hg to hg not changing hashes when nothing changes (usually). Allow these users to preserve hashes despite changes to the changelog files computation by reusing these files lists when the manifest is unchanged (since these files list are derived from the manifest). Differential Revision: https://phab.mercurial-scm.org/D6643
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Sat, 13 Jul 2019 23:45:32 -0400
parents 904e0da2e195
children 99ebde4fec99
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Jul 02 12:55:51 2019 -0400
+++ b/mercurial/localrepo.py	Sat Jul 13 23:45:32 2019 -0400
@@ -2578,7 +2578,7 @@
         return ret
 
     @unfilteredmethod
-    def commitctx(self, ctx, error=False):
+    def commitctx(self, ctx, error=False, origctx=None):
         """Add a new revision to current repository.
         Revision information is passed via the context argument.
 
@@ -2586,6 +2586,12 @@
         modified/added/removed files. On merge, it may be wider than the
         ctx.files() to be committed, since any file nodes derived directly
         from p1 or p2 are excluded from the committed ctx.files().
+
+        origctx is for convert to work around the problem that bug
+        fixes to the files list in changesets change hashes. For
+        convert to be the identity, it can pass an origctx and this
+        function will use the same files list when it makes sense to
+        do so.
         """
 
         p1, p2 = ctx.p1(), ctx.p2()
@@ -2701,6 +2707,9 @@
                 filesadded = filesadded or None
                 filesremoved = filesremoved or None
 
+            if origctx and origctx.manifestnode() == mn:
+                files = origctx.files()
+
             # update changelog
             self.ui.note(_("committing changelog\n"))
             self.changelog.delayupdate(tr)