[PATCH 3 of 5 V2] memctx: create a filectxfn if it is not callable
Sean Farley
sean.michael.farley at gmail.com
Wed Aug 6 18:20:24 CDT 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1406334961 18000
# Fri Jul 25 19:36:01 2014 -0500
# Node ID e0a761486fd816bb7baab8645f6c44c64e0489ef
# Parent 28eed68e6f02e5a7ac85e8bab0fbcaf59f8a2408
memctx: create a filectxfn if it is not callable
This will allow future patches to construct a memctx based on another context
or any other store-type object.
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -1596,10 +1596,24 @@ class memctx(committablectx):
files = sorted(set(files))
self._status = [files, [], [], [], []]
self._filectxfn = filectxfn
self.substate = {}
+ # if store is not callable, wrap it in a function
+ if not callable(filectxfn):
+ def getfilectx(repo, memctx, path):
+ fctx = filectxfn[path]
+ # this is weird but apparently we only keep track of one parent
+ # (why not only store that instead of a tuple?)
+ copied = fctx.renamed()
+ if copied:
+ copied = copied[0]
+ return memfilectx(repo, path, fctx.data(),
+ islink=fctx.islink(), isexec=fctx.isexec(),
+ copied=copied, memctx=memctx)
+ self._filectxfn = getfilectx
+
self._extra = extra and extra.copy() or {}
if self._extra.get('branch', '') == '':
self._extra['branch'] = 'default'
if editor:
More information about the Mercurial-devel
mailing list