[PATCH 3 of 5] memctx: add _manifest implementation that computes the filenode
Sean Farley
sean.michael.farley at gmail.com
Fri Jun 13 18:56:04 CDT 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1401397979 18000
# Thu May 29 16:12:59 2014 -0500
# Node ID 8bc35c83920f4a20a1de3e020662d73fa949c0a3
# Parent 2c35a9d4b14a62fa13cc2f3a06a4a729a90ed85f
memctx: add _manifest implementation that computes the filenode
This is an initial implementation of having a manifest for memctx that computes
the hash in the same way that filenodes are computed elsewhere.
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -11,10 +11,11 @@ import mdiff, error, util, scmutil, subr
import match as matchmod
import os, errno, stat
import obsolete as obsmod
import repoview
import fileset
+import revlog
propertycache = util.propertycache
class basectx(object):
"""A basectx object represents the common logic for its children:
@@ -1585,10 +1586,31 @@ class memctx(committablectx):
def commit(self):
"""commit context to the repo"""
return self._repo.commitctx(self)
+ @propertycache
+ def _manifest(self):
+ """generate a manifest based on the return values of filectxfn"""
+
+ # keep this simple for now; just worry about p1
+ pctx = self._parents[0]
+ man = pctx.manifest().copy()
+
+ for f, fnode in man.iteritems():
+ p1node = nullid
+ p2node = nullid
+ p = pctx[f].parents()
+ if len(p) > 0:
+ p1node = p[0].node()
+ if len(p) > 1:
+ p2node = p[1].node()
+ man[f] = revlog.hash(self[f].data(), p1node, p2node)
+
+ return man
+
+
class memfilectx(committablefilectx):
"""memfilectx represents an in-memory file to commit.
See memctx and commitablefilectx for more details.
"""
More information about the Mercurial-devel
mailing list