comparison mercurial/context.py @ 41994:550a172a603b

memctx: rename constructor argument "copied" to "copysource" (API) It's just the path, not the nodeid, so "copysource" seems more appropriate. Differential Revision: https://phab.mercurial-scm.org/D6158
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 19 Mar 2019 22:58:39 -0700
parents 21cc92fea2aa
children 6fef387af1da
comparison
equal deleted inserted replaced
41993:cde5827d09a7 41994:550a172a603b
2231 This is a convenience method for building a memctx based on another 2231 This is a convenience method for building a memctx based on another
2232 context. 2232 context.
2233 """ 2233 """
2234 def getfilectx(repo, memctx, path): 2234 def getfilectx(repo, memctx, path):
2235 fctx = ctx[path] 2235 fctx = ctx[path]
2236 copied = fctx.copysource() 2236 copysource = fctx.copysource()
2237 return memfilectx(repo, memctx, path, fctx.data(), 2237 return memfilectx(repo, memctx, path, fctx.data(),
2238 islink=fctx.islink(), isexec=fctx.isexec(), 2238 islink=fctx.islink(), isexec=fctx.isexec(),
2239 copied=copied) 2239 copysource=copysource)
2240 2240
2241 return getfilectx 2241 return getfilectx
2242 2242
2243 def memfilefrompatch(patchstore): 2243 def memfilefrompatch(patchstore):
2244 """Given a patch (e.g. patchstore object) return a memfilectx 2244 """Given a patch (e.g. patchstore object) return a memfilectx
2245 2245
2246 This is a convenience method for building a memctx based on a patchstore. 2246 This is a convenience method for building a memctx based on a patchstore.
2247 """ 2247 """
2248 def getfilectx(repo, memctx, path): 2248 def getfilectx(repo, memctx, path):
2249 data, mode, copied = patchstore.getfile(path) 2249 data, mode, copysource = patchstore.getfile(path)
2250 if data is None: 2250 if data is None:
2251 return None 2251 return None
2252 islink, isexec = mode 2252 islink, isexec = mode
2253 return memfilectx(repo, memctx, path, data, islink=islink, 2253 return memfilectx(repo, memctx, path, data, islink=islink,
2254 isexec=isexec, copied=copied) 2254 isexec=isexec, copysource=copysource)
2255 2255
2256 return getfilectx 2256 return getfilectx
2257 2257
2258 class memctx(committablectx): 2258 class memctx(committablectx):
2259 """Use memctx to perform in-memory commits via localrepo.commitctx(). 2259 """Use memctx to perform in-memory commits via localrepo.commitctx().
2375 """memfilectx represents an in-memory file to commit. 2375 """memfilectx represents an in-memory file to commit.
2376 2376
2377 See memctx and committablefilectx for more details. 2377 See memctx and committablefilectx for more details.
2378 """ 2378 """
2379 def __init__(self, repo, changectx, path, data, islink=False, 2379 def __init__(self, repo, changectx, path, data, islink=False,
2380 isexec=False, copied=None): 2380 isexec=False, copysource=None):
2381 """ 2381 """
2382 path is the normalized file path relative to repository root. 2382 path is the normalized file path relative to repository root.
2383 data is the file content as a string. 2383 data is the file content as a string.
2384 islink is True if the file is a symbolic link. 2384 islink is True if the file is a symbolic link.
2385 isexec is True if the file is executable. 2385 isexec is True if the file is executable.
2392 elif isexec: 2392 elif isexec:
2393 self._flags = 'x' 2393 self._flags = 'x'
2394 else: 2394 else:
2395 self._flags = '' 2395 self._flags = ''
2396 self._copied = None 2396 self._copied = None
2397 if copied: 2397 if copysource:
2398 self._copied = (copied, nullid) 2398 self._copied = (copysource, nullid)
2399 2399
2400 def cmp(self, fctx): 2400 def cmp(self, fctx):
2401 return self.data() != fctx.data() 2401 return self.data() != fctx.data()
2402 2402
2403 def data(self): 2403 def data(self):