##// END OF EJS Templates
overlayworkingctx: add ``tomemctx()``...
Phil Cohen -
r35326:71edd38c default
parent child Browse files
Show More
@@ -2177,6 +2177,42 class overlayworkingctx(committablectx):
2177 self._path)
2177 self._path)
2178 return self._wrappedctx[path].size()
2178 return self._wrappedctx[path].size()
2179
2179
2180 def tomemctx(self, text, branch=None, extra=None, date=None, parents=None,
2181 user=None, editor=None):
2182 """Converts this ``overlayworkingctx`` into a ``memctx`` ready to be
2183 committed.
2184
2185 ``text`` is the commit message.
2186 ``parents`` (optional) are rev numbers.
2187 """
2188 # Default parents to the wrapped contexts' if not passed.
2189 if parents is None:
2190 parents = self._wrappedctx.parents()
2191 if len(parents) == 1:
2192 parents = (parents[0], None)
2193
2194 # ``parents`` is passed as rev numbers; convert to ``commitctxs``.
2195 if parents[1] is None:
2196 parents = (self._repo[parents[0]], None)
2197 else:
2198 parents = (self._repo[parents[0]], self._repo[parents[1]])
2199
2200 files = self._cache.keys()
2201 def getfile(repo, memctx, path):
2202 if self._cache[path]['exists']:
2203 return memfilectx(repo, path,
2204 self._cache[path]['data'],
2205 'l' in self._cache[path]['flags'],
2206 'x' in self._cache[path]['flags'],
2207 self._cache[path]['copied'],
2208 memctx)
2209 else:
2210 # Returning None, but including the path in `files`, is
2211 # necessary for memctx to register a deletion.
2212 return None
2213 return memctx(self._repo, parents, text, files, getfile, date=date,
2214 extra=extra, user=user, branch=branch, editor=editor)
2215
2180 def isdirty(self, path):
2216 def isdirty(self, path):
2181 return path in self._cache
2217 return path in self._cache
2182
2218
General Comments 0
You need to be logged in to leave comments. Login now