[PATCH 1 of 2] localrepo: reuse commit of parent filectx entries without rehashing

Mads Kiilerich mads at kiilerich.com
Thu Mar 19 11:53:33 CDT 2015


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1426782977 -3600
#      Thu Mar 19 17:36:17 2015 +0100
# Branch stable
# Node ID b446163ce0c69e748e8e51b2261540fcb0fc5bba
# Parent  6136704b975df292819647ba8ac46209487fbc46
localrepo: reuse commit of parent filectx entries without rehashing

It is currently only amend and debugbuilddag that will pass a filectx to
localrepo._filecommit. Amend will usually not hit the case where a the filectx
is a parent that just can be reused. Future convert changes will use it more.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1169,11 +1169,15 @@ class localrepository(object):
         """
 
         fname = fctx.path()
-        text = fctx.data()
-        flog = self.file(fname)
         fparent1 = manifest1.get(fname, nullid)
         fparent2 = manifest2.get(fname, nullid)
+        if isinstance(fctx, context.filectx):
+            node = fctx.filenode()
+            if node in [fparent1, fparent2]:
+                self.ui.debug('reusing %s filelog entry\n' % fname)
+                return node
 
+        flog = self.file(fname)
         meta = {}
         copy = fctx.renamed()
         if copy and copy[0] != fname:
@@ -1235,6 +1239,7 @@ class localrepository(object):
                 fparent2 = nullid
 
         # is the file changed?
+        text = fctx.data()
         if fparent2 != nullid or flog.cmp(fparent1, text) or meta:
             changelist.append(fname)
             return flog.add(text, meta, tr, linkrev, fparent1, fparent2)


More information about the Mercurial-devel mailing list