mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
context: add convenience method for returning a memfilectx from a patch
This is mostly a copy of what makememctx does but refactored to make it behave more like our other convenience methods.
This commit is contained in:
parent
90b054fc18
commit
e67eb8ee09
@ -2060,6 +2060,22 @@ def memfilefromctx(ctx):
|
||||
|
||||
return getfilectx
|
||||
|
||||
def memfilefrompatch(patchstore):
|
||||
"""Given a patch (e.g. patchstore object) return a memfilectx
|
||||
|
||||
This is a convenience method for building a memctx based on a patchstore.
|
||||
"""
|
||||
def getfilectx(repo, memctx, path):
|
||||
data, mode, copied = patchstore.getfile(path)
|
||||
if data is None:
|
||||
return None
|
||||
islink, isexec = mode
|
||||
return memfilectx(repo, path, data, islink=islink,
|
||||
isexec=isexec, copied=copied,
|
||||
memctx=memctx)
|
||||
|
||||
return getfilectx
|
||||
|
||||
class memctx(committablectx):
|
||||
"""Use memctx to perform in-memory commits via localrepo.commitctx().
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user