##// END OF EJS Templates
memfilectx: make changectx argument mandatory in constructor (API)...
Martin von Zweigbergk -
r35401:8a0cac20 default
parent child Browse files
Show More
@@ -376,7 +376,7 b' def synthesize(ui, repo, descpath, **opt'
376 dir = os.path.dirname(dir)
376 dir = os.path.dirname(dir)
377
377
378 def filectxfn(repo, memctx, path):
378 def filectxfn(repo, memctx, path):
379 return context.memfilectx(repo, path, files[path])
379 return context.memfilectx(repo, memctx, path, files[path])
380
380
381 ui.progress(_synthesizing, None)
381 ui.progress(_synthesizing, None)
382 message = 'synthesized wide repo with %d files' % (len(files),)
382 message = 'synthesized wide repo with %d files' % (len(files),)
@@ -468,7 +468,7 b' def synthesize(ui, repo, descpath, **opt'
468 def filectxfn(repo, memctx, path):
468 def filectxfn(repo, memctx, path):
469 if path not in changes:
469 if path not in changes:
470 return None
470 return None
471 return context.memfilectx(repo, path, changes[path])
471 return context.memfilectx(repo, memctx, path, changes[path])
472 if not changes:
472 if not changes:
473 continue
473 continue
474 if revs:
474 if revs:
@@ -253,7 +253,7 b' class mercurial_sink(common.converter_si'
253 data = self._rewritetags(source, revmap, data)
253 data = self._rewritetags(source, revmap, data)
254 if f == '.hgsubstate':
254 if f == '.hgsubstate':
255 data = self._rewritesubstate(source, data)
255 data = self._rewritesubstate(source, data)
256 return context.memfilectx(self.repo, f, data, 'l' in mode,
256 return context.memfilectx(self.repo, memctx, f, data, 'l' in mode,
257 'x' in mode, copies.get(f))
257 'x' in mode, copies.get(f))
258
258
259 pl = []
259 pl = []
@@ -401,7 +401,7 b' class mercurial_sink(common.converter_si'
401
401
402 data = "".join(newlines)
402 data = "".join(newlines)
403 def getfilectx(repo, memctx, f):
403 def getfilectx(repo, memctx, f):
404 return context.memfilectx(repo, f, data, False, False, None)
404 return context.memfilectx(repo, memctx, f, data, False, False, None)
405
405
406 self.ui.status(_("updating tags\n"))
406 self.ui.status(_("updating tags\n"))
407 date = "%s 0" % int(time.mktime(time.gmtime()))
407 date = "%s 0" % int(time.mktime(time.gmtime()))
@@ -602,7 +602,7 b' def collapse(repo, first, last, commitop'
602 if path in headmf:
602 if path in headmf:
603 fctx = last[path]
603 fctx = last[path]
604 flags = fctx.flags()
604 flags = fctx.flags()
605 mctx = context.memfilectx(repo,
605 mctx = context.memfilectx(repo, ctx,
606 fctx.path(), fctx.data(),
606 fctx.path(), fctx.data(),
607 islink='l' in flags,
607 islink='l' in flags,
608 isexec='x' in flags,
608 isexec='x' in flags,
@@ -261,7 +261,8 b' def _lfconvert_addchangeset(rsrc, rdst, '
261 # doesn't change after rename or copy
261 # doesn't change after rename or copy
262 renamed = lfutil.standin(renamed[0])
262 renamed = lfutil.standin(renamed[0])
263
263
264 return context.memfilectx(repo, f, lfiletohash[srcfname] + '\n',
264 return context.memfilectx(repo, memctx, f,
265 lfiletohash[srcfname] + '\n',
265 'l' in fctx.flags(), 'x' in fctx.flags(),
266 'l' in fctx.flags(), 'x' in fctx.flags(),
266 renamed)
267 renamed)
267 else:
268 else:
@@ -313,7 +314,7 b' def _getnormalcontext(repo, ctx, f, revm'
313 data = fctx.data()
314 data = fctx.data()
314 if f == '.hgtags':
315 if f == '.hgtags':
315 data = _converttags (repo.ui, revmap, data)
316 data = _converttags (repo.ui, revmap, data)
316 return context.memfilectx(repo, f, data, 'l' in fctx.flags(),
317 return context.memfilectx(repo, ctx, f, data, 'l' in fctx.flags(),
317 'x' in fctx.flags(), renamed)
318 'x' in fctx.flags(), renamed)
318
319
319 # Remap tag data using a revision map
320 # Remap tag data using a revision map
@@ -77,7 +77,7 b' def _commitfiltered(repo, ctx, match, al'
77 if path not in contentctx:
77 if path not in contentctx:
78 return None
78 return None
79 fctx = contentctx[path]
79 fctx = contentctx[path]
80 mctx = context.memfilectx(repo, fctx.path(), fctx.data(),
80 mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(),
81 fctx.islink(),
81 fctx.islink(),
82 fctx.isexec(),
82 fctx.isexec(),
83 copied=copied.get(path))
83 copied=copied.get(path))
@@ -3195,7 +3195,7 b' def amend(ui, repo, old, extra, pats, op'
3195
3195
3196 fctx = wctx[path]
3196 fctx = wctx[path]
3197 flags = fctx.flags()
3197 flags = fctx.flags()
3198 mctx = context.memfilectx(repo,
3198 mctx = context.memfilectx(repo, ctx_,
3199 fctx.path(), fctx.data(),
3199 fctx.path(), fctx.data(),
3200 islink='l' in flags,
3200 islink='l' in flags,
3201 isexec='x' in flags,
3201 isexec='x' in flags,
@@ -2204,12 +2204,11 b' class overlayworkingctx(committablectx):'
2204 files = self._cache.keys()
2204 files = self._cache.keys()
2205 def getfile(repo, memctx, path):
2205 def getfile(repo, memctx, path):
2206 if self._cache[path]['exists']:
2206 if self._cache[path]['exists']:
2207 return memfilectx(repo, path,
2207 return memfilectx(repo, memctx, path,
2208 self._cache[path]['data'],
2208 self._cache[path]['data'],
2209 'l' in self._cache[path]['flags'],
2209 'l' in self._cache[path]['flags'],
2210 'x' in self._cache[path]['flags'],
2210 'x' in self._cache[path]['flags'],
2211 self._cache[path]['copied'],
2211 self._cache[path]['copied'])
2212 memctx)
2213 else:
2212 else:
2214 # Returning None, but including the path in `files`, is
2213 # Returning None, but including the path in `files`, is
2215 # necessary for memctx to register a deletion.
2214 # necessary for memctx to register a deletion.
@@ -2389,9 +2388,9 b' def memfilefromctx(ctx):'
2389 copied = fctx.renamed()
2388 copied = fctx.renamed()
2390 if copied:
2389 if copied:
2391 copied = copied[0]
2390 copied = copied[0]
2392 return memfilectx(repo, path, fctx.data(),
2391 return memfilectx(repo, memctx, path, fctx.data(),
2393 islink=fctx.islink(), isexec=fctx.isexec(),
2392 islink=fctx.islink(), isexec=fctx.isexec(),
2394 copied=copied, memctx=memctx)
2393 copied=copied)
2395
2394
2396 return getfilectx
2395 return getfilectx
2397
2396
@@ -2405,9 +2404,8 b' def memfilefrompatch(patchstore):'
2405 if data is None:
2404 if data is None:
2406 return None
2405 return None
2407 islink, isexec = mode
2406 islink, isexec = mode
2408 return memfilectx(repo, path, data, islink=islink,
2407 return memfilectx(repo, memctx, path, data, islink=islink,
2409 isexec=isexec, copied=copied,
2408 isexec=isexec, copied=copied)
2410 memctx=memctx)
2411
2409
2412 return getfilectx
2410 return getfilectx
2413
2411
@@ -2539,8 +2537,8 b' class memfilectx(committablefilectx):'
2539
2537
2540 See memctx and committablefilectx for more details.
2538 See memctx and committablefilectx for more details.
2541 """
2539 """
2542 def __init__(self, repo, path, data, islink=False,
2540 def __init__(self, repo, changectx, path, data, islink=False,
2543 isexec=False, copied=None, memctx=None):
2541 isexec=False, copied=None):
2544 """
2542 """
2545 path is the normalized file path relative to repository root.
2543 path is the normalized file path relative to repository root.
2546 data is the file content as a string.
2544 data is the file content as a string.
@@ -2548,7 +2546,7 b' class memfilectx(committablefilectx):'
2548 isexec is True if the file is executable.
2546 isexec is True if the file is executable.
2549 copied is the source file path if current file was copied in the
2547 copied is the source file path if current file was copied in the
2550 revision being committed, or None."""
2548 revision being committed, or None."""
2551 super(memfilectx, self).__init__(repo, path, None, memctx)
2549 super(memfilectx, self).__init__(repo, path, None, changectx)
2552 self._data = data
2550 self._data = data
2553 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
2551 self._flags = (islink and 'l' or '') + (isexec and 'x' or '')
2554 self._copied = None
2552 self._copied = None
@@ -225,7 +225,8 b' def debugbuilddag(ui, repo, text=None,'
225
225
226 def fctxfn(repo, cx, path):
226 def fctxfn(repo, cx, path):
227 if path in filecontent:
227 if path in filecontent:
228 return context.memfilectx(repo, path, filecontent[path])
228 return context.memfilectx(repo, cx, path,
229 filecontent[path])
229 return None
230 return None
230
231
231 if len(ps) == 0 or ps[0] < 0:
232 if len(ps) == 0 or ps[0] < 0:
@@ -648,7 +648,8 b' verify pathauditor blocks evil filepaths'
648 > u = uimod.ui.load()
648 > u = uimod.ui.load()
649 > r = hg.repository(u, '.')
649 > r = hg.repository(u, '.')
650 > def filectxfn(repo, memctx, path):
650 > def filectxfn(repo, memctx, path):
651 > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
651 > return context.memfilectx(repo, memctx, path,
652 > '[hooks]\nupdate = echo owned')
652 > c = context.memctx(r, [r['tip'].node(), node.nullid],
653 > c = context.memctx(r, [r['tip'].node(), node.nullid],
653 > 'evil', [notrc], filectxfn, 0)
654 > 'evil', [notrc], filectxfn, 0)
654 > r.commitctx(c)
655 > r.commitctx(c)
@@ -673,7 +674,8 b' verify pathauditor blocks evil filepaths'
673 > u = uimod.ui.load()
674 > u = uimod.ui.load()
674 > r = hg.repository(u, '.')
675 > r = hg.repository(u, '.')
675 > def filectxfn(repo, memctx, path):
676 > def filectxfn(repo, memctx, path):
676 > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
677 > return context.memfilectx(repo, memctx, path,
678 > '[hooks]\nupdate = echo owned')
677 > c = context.memctx(r, [r['tip'].node(), node.nullid],
679 > c = context.memctx(r, [r['tip'].node(), node.nullid],
678 > 'evil', [notrc], filectxfn, 0)
680 > 'evil', [notrc], filectxfn, 0)
679 > r.commitctx(c)
681 > r.commitctx(c)
@@ -692,7 +694,8 b' verify pathauditor blocks evil filepaths'
692 > u = uimod.ui.load()
694 > u = uimod.ui.load()
693 > r = hg.repository(u, '.')
695 > r = hg.repository(u, '.')
694 > def filectxfn(repo, memctx, path):
696 > def filectxfn(repo, memctx, path):
695 > return context.memfilectx(repo, path, '[hooks]\nupdate = echo owned')
697 > return context.memfilectx(repo, memctx, path,
698 > '[hooks]\nupdate = echo owned')
696 > c = context.memctx(r, [r['tip'].node(), node.nullid],
699 > c = context.memctx(r, [r['tip'].node(), node.nullid],
697 > 'evil', [notrc], filectxfn, 0)
700 > 'evil', [notrc], filectxfn, 0)
698 > r.commitctx(c)
701 > r.commitctx(c)
@@ -32,7 +32,7 b' print("workingfilectx.date = (%d, %d)" %'
32 # test memctx with non-ASCII commit message
32 # test memctx with non-ASCII commit message
33
33
34 def filectxfn(repo, memctx, path):
34 def filectxfn(repo, memctx, path):
35 return context.memfilectx(repo, "foo", "")
35 return context.memfilectx(repo, memctx, "foo", "")
36
36
37 ctx = context.memctx(repo, ['tip', None],
37 ctx = context.memctx(repo, ['tip', None],
38 encoding.tolocal("Gr\xc3\xbcezi!"),
38 encoding.tolocal("Gr\xc3\xbcezi!"),
@@ -49,7 +49,7 b' def getfilectx(repo, memctx, f):'
49 data, flags = fctx.data(), fctx.flags()
49 data, flags = fctx.data(), fctx.flags()
50 if f == 'foo':
50 if f == 'foo':
51 data += 'bar\n'
51 data += 'bar\n'
52 return context.memfilectx(repo, f, data, 'l' in flags, 'x' in flags)
52 return context.memfilectx(repo, memctx, f, data, 'l' in flags, 'x' in flags)
53
53
54 ctxa = repo.changectx(0)
54 ctxa = repo.changectx(0)
55 ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
55 ctxb = context.memctx(repo, [ctxa.node(), None], "test diff", ["foo"],
General Comments 0
You need to be logged in to leave comments. Login now