comparison mercurial/context.py @ 21689:503bb3af70fe

memfilectx: call super.__init__ instead of duplicating code This patch changes the calling signature of memfilectx's __init__ to fall in line with the other file contexts. Calling code and tests have been updated accordingly.
author Sean Farley <sean.michael.farley@gmail.com>
date Thu, 15 Aug 2013 16:49:27 -0500
parents cc677803bad4
children da352312fa18
comparison
equal deleted inserted replaced
21688:cc677803bad4 21689:503bb3af70fe
333 333
334 def makememctx(repo, parents, text, user, date, branch, files, store, 334 def makememctx(repo, parents, text, user, date, branch, files, store,
335 editor=None): 335 editor=None):
336 def getfilectx(repo, memctx, path): 336 def getfilectx(repo, memctx, path):
337 data, (islink, isexec), copied = store.getfile(path) 337 data, (islink, isexec), copied = store.getfile(path)
338 return memfilectx(path, data, islink=islink, isexec=isexec, 338 return memfilectx(repo, path, data, islink=islink, isexec=isexec,
339 copied=copied) 339 copied=copied, memctx=memctx)
340 extra = {} 340 extra = {}
341 if branch: 341 if branch:
342 extra['branch'] = encoding.fromlocal(branch) 342 extra['branch'] = encoding.fromlocal(branch)
343 ctx = memctx(repo, parents, text, files, getfilectx, user, 343 ctx = memctx(repo, parents, text, files, getfilectx, user,
344 date, extra, editor) 344 date, extra, editor)
1587 return self._repo.commitctx(self) 1587 return self._repo.commitctx(self)
1588 1588
1589 class memfilectx(committablefilectx): 1589 class memfilectx(committablefilectx):
1590 """memfilectx represents an in-memory file to commit. 1590 """memfilectx represents an in-memory file to commit.
1591 1591
1592 See memctx for more details. 1592 See memctx and commitablefilectx for more details.
1593 """ 1593 """
1594 def __init__(self, path, data, islink=False, isexec=False, copied=None): 1594 def __init__(self, repo, path, data, islink=False,
1595 isexec=False, copied=None, memctx=None):
1595 """ 1596 """
1596 path is the normalized file path relative to repository root. 1597 path is the normalized file path relative to repository root.
1597 data is the file content as a string. 1598 data is the file content as a string.
1598 islink is True if the file is a symbolic link. 1599 islink is True if the file is a symbolic link.
1599 isexec is True if the file is executable. 1600 isexec is True if the file is executable.
1600 copied is the source file path if current file was copied in the 1601 copied is the source file path if current file was copied in the
1601 revision being committed, or None.""" 1602 revision being committed, or None."""
1602 self._path = path 1603 super(memfilectx, self).__init__(repo, path, None, memctx)
1603 self._data = data 1604 self._data = data
1604 self._flags = (islink and 'l' or '') + (isexec and 'x' or '') 1605 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
1605 self._copied = None 1606 self._copied = None
1606 if copied: 1607 if copied:
1607 self._copied = (copied, nullid) 1608 self._copied = (copied, nullid)