##// END OF EJS Templates
memctx: refactor inline getfilectx into convenience method...
Sean Farley -
r32763:34be21aa default
parent child Browse files
Show More
@@ -2041,6 +2041,25 b' def makecachingfilectxfn(func):'
2041
2041
2042 return getfilectx
2042 return getfilectx
2043
2043
2044 def memfilefromctx(ctx):
2045 """Given a context return a memfilectx for ctx[path]
2046
2047 This is a convenience method for building a memctx based on another
2048 context.
2049 """
2050 def getfilectx(repo, memctx, path):
2051 fctx = ctx[path]
2052 # this is weird but apparently we only keep track of one parent
2053 # (why not only store that instead of a tuple?)
2054 copied = fctx.renamed()
2055 if copied:
2056 copied = copied[0]
2057 return memfilectx(repo, path, fctx.data(),
2058 islink=fctx.islink(), isexec=fctx.isexec(),
2059 copied=copied, memctx=memctx)
2060
2061 return getfilectx
2062
2044 class memctx(committablectx):
2063 class memctx(committablectx):
2045 """Use memctx to perform in-memory commits via localrepo.commitctx().
2064 """Use memctx to perform in-memory commits via localrepo.commitctx().
2046
2065
@@ -2088,17 +2107,7 b' class memctx(committablectx):'
2088
2107
2089 # if store is not callable, wrap it in a function
2108 # if store is not callable, wrap it in a function
2090 if not callable(filectxfn):
2109 if not callable(filectxfn):
2091 def getfilectx(repo, memctx, path):
2110 self._filectxfn = memfilefromctx(filectxfn)
2092 fctx = filectxfn[path]
2093 # this is weird but apparently we only keep track of one parent
2094 # (why not only store that instead of a tuple?)
2095 copied = fctx.renamed()
2096 if copied:
2097 copied = copied[0]
2098 return memfilectx(repo, path, fctx.data(),
2099 islink=fctx.islink(), isexec=fctx.isexec(),
2100 copied=copied, memctx=memctx)
2101 self._filectxfn = getfilectx
2102 else:
2111 else:
2103 # memoizing increases performance for e.g. vcs convert scenarios.
2112 # memoizing increases performance for e.g. vcs convert scenarios.
2104 self._filectxfn = makecachingfilectxfn(filectxfn)
2113 self._filectxfn = makecachingfilectxfn(filectxfn)
General Comments 0
You need to be logged in to leave comments. Login now