diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -334,7 +334,7 @@ def synthesize(ui, repo, descpath, **opt for __ in xrange(add): lines.insert(random.randint(0, len(lines)), makeline()) path = fctx.path() - changes[path] = context.memfilectx(path, + changes[path] = context.memfilectx(repo, path, '\n'.join(lines) + '\n') for __ in xrange(pick(filesremoved)): path = random.choice(mfk) @@ -354,7 +354,7 @@ def synthesize(ui, repo, descpath, **opt path = '/'.join(filter(None, path)) data = '\n'.join(makeline() for __ in xrange(pick(linesinfilesadded))) + '\n' - changes[path] = context.memfilectx(path, data) + changes[path] = context.memfilectx(repo, path, data) def filectxfn(repo, memctx, path): data = changes[path] if data is None: diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py --- a/hgext/convert/hg.py +++ b/hgext/convert/hg.py @@ -136,8 +136,8 @@ class mercurial_sink(converter_sink): data, mode = source.getfile(f, v) if f == '.hgtags': data = self._rewritetags(source, revmap, data) - return context.memfilectx(f, data, 'l' in mode, 'x' in mode, - copies.get(f)) + return context.memfilectx(self.repo, f, data, 'l' in mode, + 'x' in mode, copies.get(f)) pl = [] for p in parents: @@ -229,7 +229,7 @@ class mercurial_sink(converter_sink): data = "".join(newlines) def getfilectx(repo, memctx, f): - return context.memfilectx(f, data, False, False, None) + return context.memfilectx(repo, f, data, False, False, None) self.ui.status(_("updating tags\n")) date = "%s 0" % int(time.mktime(time.gmtime())) diff --git a/hgext/histedit.py b/hgext/histedit.py --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -275,7 +275,8 @@ def collapse(repo, first, last, commitop if path in headmf: fctx = last[path] flags = fctx.flags() - mctx = context.memfilectx(fctx.path(), fctx.data(), + mctx = context.memfilectx(repo, + fctx.path(), fctx.data(), islink='l' in flags, isexec='x' in flags, copied=copied.get(path)) diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py +++ b/hgext/largefiles/lfcommands.py @@ -172,10 +172,10 @@ def _addchangeset(ui, rsrc, rdst, ctx, r finally: if fd: fd.close() - return context.memfilectx(f, data, 'l' in fctx.flags(), + return context.memfilectx(repo, f, data, 'l' in fctx.flags(), 'x' in fctx.flags(), renamed) else: - return _getnormalcontext(repo.ui, ctx, f, revmap) + return _getnormalcontext(repo, ctx, f, revmap) dstfiles = [] for file in files: @@ -255,10 +255,11 @@ def _lfconvert_addchangeset(rsrc, rdst, # doesn't change after rename or copy renamed = lfutil.standin(renamed[0]) - return context.memfilectx(f, lfiletohash[srcfname] + '\n', 'l' in - fctx.flags(), 'x' in fctx.flags(), renamed) + return context.memfilectx(repo, f, lfiletohash[srcfname] + '\n', + 'l' in fctx.flags(), 'x' in fctx.flags(), + renamed) else: - return _getnormalcontext(repo.ui, ctx, f, revmap) + return _getnormalcontext(repo, ctx, f, revmap) # Commit _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap) @@ -293,7 +294,7 @@ def _convertparents(ctx, revmap): return parents # Get memfilectx for a normal file -def _getnormalcontext(ui, ctx, f, revmap): +def _getnormalcontext(repo, ctx, f, revmap): try: fctx = ctx.filectx(f) except error.LookupError: @@ -304,8 +305,8 @@ def _getnormalcontext(ui, ctx, f, revmap data = fctx.data() if f == '.hgtags': - data = _converttags (ui, revmap, data) - return context.memfilectx(f, data, 'l' in fctx.flags(), + data = _converttags (repo.ui, revmap, data) + return context.memfilectx(repo, f, data, 'l' in fctx.flags(), 'x' in fctx.flags(), renamed) # Remap tag data using a revision map diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2057,7 +2057,8 @@ def amend(ui, repo, commitfunc, old, ext try: fctx = ctx[path] flags = fctx.flags() - mctx = context.memfilectx(fctx.path(), fctx.data(), + mctx = context.memfilectx(repo, + fctx.path(), fctx.data(), islink='l' in flags, isexec='x' in flags, copied=copied.get(path)) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1681,17 +1681,17 @@ def debugbuilddag(ui, repo, text=None, ml[id * linesperrev] += " r%i" % id mergedtext = "\n".join(ml) files.append(fn) - fctxs[fn] = context.memfilectx(fn, mergedtext) + fctxs[fn] = context.memfilectx(repo, fn, mergedtext) if overwritten_file: fn = "of" files.append(fn) - fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) + fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) if new_file: fn = "nf%i" % id files.append(fn) - fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) + fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) if len(ps) > 1: if not p2: p2 = repo[ps[1]] diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -335,8 +335,8 @@ def makememctx(repo, parents, text, user editor=None): def getfilectx(repo, memctx, path): data, (islink, isexec), copied = store.getfile(path) - return memfilectx(path, data, islink=islink, isexec=isexec, - copied=copied) + return memfilectx(repo, path, data, islink=islink, isexec=isexec, + copied=copied, memctx=memctx) extra = {} if branch: extra['branch'] = encoding.fromlocal(branch) @@ -1589,9 +1589,10 @@ class memctx(committablectx): class memfilectx(committablefilectx): """memfilectx represents an in-memory file to commit. - See memctx for more details. + See memctx and commitablefilectx for more details. """ - def __init__(self, path, data, islink=False, isexec=False, copied=None): + def __init__(self, repo, path, data, islink=False, + isexec=False, copied=None, memctx=None): """ path is the normalized file path relative to repository root. data is the file content as a string. @@ -1599,7 +1600,7 @@ class memfilectx(committablefilectx): isexec is True if the file is executable. copied is the source file path if current file was copied in the revision being committed, or None.""" - self._path = path + super(memfilectx, self).__init__(repo, path, None, memctx) self._data = data self._flags = (islink and 'l' or '') + (isexec and 'x' or '') self._copied = None diff --git a/tests/test-context.py b/tests/test-context.py --- a/tests/test-context.py +++ b/tests/test-context.py @@ -21,7 +21,7 @@ print "workingfilectx.date =", repo[None # test memctx with non-ASCII commit message def filectxfn(repo, memctx, path): - return context.memfilectx("foo", "") + return context.memfilectx(repo, "foo", "") ctx = context.memctx(repo, ['tip', None], encoding.tolocal("Gr\xc3\xbcezi!"),