Show More
@@ -334,7 +334,7 b' def synthesize(ui, repo, descpath, **opt' | |||||
334 | for __ in xrange(add): |
|
334 | for __ in xrange(add): | |
335 | lines.insert(random.randint(0, len(lines)), makeline()) |
|
335 | lines.insert(random.randint(0, len(lines)), makeline()) | |
336 | path = fctx.path() |
|
336 | path = fctx.path() | |
337 | changes[path] = context.memfilectx(path, |
|
337 | changes[path] = context.memfilectx(repo, path, | |
338 | '\n'.join(lines) + '\n') |
|
338 | '\n'.join(lines) + '\n') | |
339 | for __ in xrange(pick(filesremoved)): |
|
339 | for __ in xrange(pick(filesremoved)): | |
340 | path = random.choice(mfk) |
|
340 | path = random.choice(mfk) | |
@@ -354,7 +354,7 b' def synthesize(ui, repo, descpath, **opt' | |||||
354 | path = '/'.join(filter(None, path)) |
|
354 | path = '/'.join(filter(None, path)) | |
355 | data = '\n'.join(makeline() |
|
355 | data = '\n'.join(makeline() | |
356 | for __ in xrange(pick(linesinfilesadded))) + '\n' |
|
356 | for __ in xrange(pick(linesinfilesadded))) + '\n' | |
357 | changes[path] = context.memfilectx(path, data) |
|
357 | changes[path] = context.memfilectx(repo, path, data) | |
358 | def filectxfn(repo, memctx, path): |
|
358 | def filectxfn(repo, memctx, path): | |
359 | data = changes[path] |
|
359 | data = changes[path] | |
360 | if data is None: |
|
360 | if data is None: |
@@ -136,8 +136,8 b' class mercurial_sink(converter_sink):' | |||||
136 | data, mode = source.getfile(f, v) |
|
136 | data, mode = source.getfile(f, v) | |
137 | if f == '.hgtags': |
|
137 | if f == '.hgtags': | |
138 | data = self._rewritetags(source, revmap, data) |
|
138 | data = self._rewritetags(source, revmap, data) | |
139 |
return context.memfilectx(f, data, 'l' in mode, |
|
139 | return context.memfilectx(self.repo, f, data, 'l' in mode, | |
140 | copies.get(f)) |
|
140 | 'x' in mode, copies.get(f)) | |
141 |
|
141 | |||
142 | pl = [] |
|
142 | pl = [] | |
143 | for p in parents: |
|
143 | for p in parents: | |
@@ -229,7 +229,7 b' class mercurial_sink(converter_sink):' | |||||
229 |
|
229 | |||
230 | data = "".join(newlines) |
|
230 | data = "".join(newlines) | |
231 | def getfilectx(repo, memctx, f): |
|
231 | def getfilectx(repo, memctx, f): | |
232 | return context.memfilectx(f, data, False, False, None) |
|
232 | return context.memfilectx(repo, f, data, False, False, None) | |
233 |
|
233 | |||
234 | self.ui.status(_("updating tags\n")) |
|
234 | self.ui.status(_("updating tags\n")) | |
235 | date = "%s 0" % int(time.mktime(time.gmtime())) |
|
235 | date = "%s 0" % int(time.mktime(time.gmtime())) |
@@ -275,7 +275,8 b' def collapse(repo, first, last, commitop' | |||||
275 | if path in headmf: |
|
275 | if path in headmf: | |
276 | fctx = last[path] |
|
276 | fctx = last[path] | |
277 | flags = fctx.flags() |
|
277 | flags = fctx.flags() | |
278 |
mctx = context.memfilectx( |
|
278 | mctx = context.memfilectx(repo, | |
|
279 | fctx.path(), fctx.data(), | |||
279 | islink='l' in flags, |
|
280 | islink='l' in flags, | |
280 | isexec='x' in flags, |
|
281 | isexec='x' in flags, | |
281 | copied=copied.get(path)) |
|
282 | copied=copied.get(path)) |
@@ -172,10 +172,10 b' def _addchangeset(ui, rsrc, rdst, ctx, r' | |||||
172 | finally: |
|
172 | finally: | |
173 | if fd: |
|
173 | if fd: | |
174 | fd.close() |
|
174 | fd.close() | |
175 | return context.memfilectx(f, data, 'l' in fctx.flags(), |
|
175 | return context.memfilectx(repo, f, data, 'l' in fctx.flags(), | |
176 | 'x' in fctx.flags(), renamed) |
|
176 | 'x' in fctx.flags(), renamed) | |
177 | else: |
|
177 | else: | |
178 |
return _getnormalcontext(repo |
|
178 | return _getnormalcontext(repo, ctx, f, revmap) | |
179 |
|
179 | |||
180 | dstfiles = [] |
|
180 | dstfiles = [] | |
181 | for file in files: |
|
181 | for file in files: | |
@@ -255,10 +255,11 b' def _lfconvert_addchangeset(rsrc, rdst, ' | |||||
255 | # doesn't change after rename or copy |
|
255 | # doesn't change after rename or copy | |
256 | renamed = lfutil.standin(renamed[0]) |
|
256 | renamed = lfutil.standin(renamed[0]) | |
257 |
|
257 | |||
258 |
return context.memfilectx(f, lfiletohash[srcfname] + '\n', |
|
258 | return context.memfilectx(repo, f, lfiletohash[srcfname] + '\n', | |
259 |
fctx.flags(), 'x' in fctx.flags(), |
|
259 | 'l' in fctx.flags(), 'x' in fctx.flags(), | |
|
260 | renamed) | |||
260 | else: |
|
261 | else: | |
261 |
return _getnormalcontext(repo |
|
262 | return _getnormalcontext(repo, ctx, f, revmap) | |
262 |
|
263 | |||
263 | # Commit |
|
264 | # Commit | |
264 | _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap) |
|
265 | _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap) | |
@@ -293,7 +294,7 b' def _convertparents(ctx, revmap):' | |||||
293 | return parents |
|
294 | return parents | |
294 |
|
295 | |||
295 | # Get memfilectx for a normal file |
|
296 | # Get memfilectx for a normal file | |
296 |
def _getnormalcontext( |
|
297 | def _getnormalcontext(repo, ctx, f, revmap): | |
297 | try: |
|
298 | try: | |
298 | fctx = ctx.filectx(f) |
|
299 | fctx = ctx.filectx(f) | |
299 | except error.LookupError: |
|
300 | except error.LookupError: | |
@@ -304,8 +305,8 b' def _getnormalcontext(ui, ctx, f, revmap' | |||||
304 |
|
305 | |||
305 | data = fctx.data() |
|
306 | data = fctx.data() | |
306 | if f == '.hgtags': |
|
307 | if f == '.hgtags': | |
307 | data = _converttags (ui, revmap, data) |
|
308 | data = _converttags (repo.ui, revmap, data) | |
308 | return context.memfilectx(f, data, 'l' in fctx.flags(), |
|
309 | return context.memfilectx(repo, f, data, 'l' in fctx.flags(), | |
309 | 'x' in fctx.flags(), renamed) |
|
310 | 'x' in fctx.flags(), renamed) | |
310 |
|
311 | |||
311 | # Remap tag data using a revision map |
|
312 | # Remap tag data using a revision map |
@@ -2057,7 +2057,8 b' def amend(ui, repo, commitfunc, old, ext' | |||||
2057 | try: |
|
2057 | try: | |
2058 | fctx = ctx[path] |
|
2058 | fctx = ctx[path] | |
2059 | flags = fctx.flags() |
|
2059 | flags = fctx.flags() | |
2060 |
mctx = context.memfilectx( |
|
2060 | mctx = context.memfilectx(repo, | |
|
2061 | fctx.path(), fctx.data(), | |||
2061 | islink='l' in flags, |
|
2062 | islink='l' in flags, | |
2062 | isexec='x' in flags, |
|
2063 | isexec='x' in flags, | |
2063 | copied=copied.get(path)) |
|
2064 | copied=copied.get(path)) |
@@ -1681,17 +1681,17 b' def debugbuilddag(ui, repo, text=None,' | |||||
1681 | ml[id * linesperrev] += " r%i" % id |
|
1681 | ml[id * linesperrev] += " r%i" % id | |
1682 | mergedtext = "\n".join(ml) |
|
1682 | mergedtext = "\n".join(ml) | |
1683 | files.append(fn) |
|
1683 | files.append(fn) | |
1684 | fctxs[fn] = context.memfilectx(fn, mergedtext) |
|
1684 | fctxs[fn] = context.memfilectx(repo, fn, mergedtext) | |
1685 |
|
1685 | |||
1686 | if overwritten_file: |
|
1686 | if overwritten_file: | |
1687 | fn = "of" |
|
1687 | fn = "of" | |
1688 | files.append(fn) |
|
1688 | files.append(fn) | |
1689 | fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) |
|
1689 | fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) | |
1690 |
|
1690 | |||
1691 | if new_file: |
|
1691 | if new_file: | |
1692 | fn = "nf%i" % id |
|
1692 | fn = "nf%i" % id | |
1693 | files.append(fn) |
|
1693 | files.append(fn) | |
1694 | fctxs[fn] = context.memfilectx(fn, "r%i\n" % id) |
|
1694 | fctxs[fn] = context.memfilectx(repo, fn, "r%i\n" % id) | |
1695 | if len(ps) > 1: |
|
1695 | if len(ps) > 1: | |
1696 | if not p2: |
|
1696 | if not p2: | |
1697 | p2 = repo[ps[1]] |
|
1697 | p2 = repo[ps[1]] |
@@ -335,8 +335,8 b' def makememctx(repo, parents, text, user' | |||||
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) | |
@@ -1589,9 +1589,10 b' class memctx(committablectx):' | |||||
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, |
|
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. | |
@@ -1599,7 +1600,7 b' class memfilectx(committablefilectx):' | |||||
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 |
@@ -21,7 +21,7 b' print "workingfilectx.date =", repo[None' | |||||
21 | # test memctx with non-ASCII commit message |
|
21 | # test memctx with non-ASCII commit message | |
22 |
|
22 | |||
23 | def filectxfn(repo, memctx, path): |
|
23 | def filectxfn(repo, memctx, path): | |
24 | return context.memfilectx("foo", "") |
|
24 | return context.memfilectx(repo, "foo", "") | |
25 |
|
25 | |||
26 | ctx = context.memctx(repo, ['tip', None], |
|
26 | ctx = context.memctx(repo, ['tip', None], | |
27 | encoding.tolocal("Gr\xc3\xbcezi!"), |
|
27 | encoding.tolocal("Gr\xc3\xbcezi!"), |
General Comments 0
You need to be logged in to leave comments.
Login now