##// END OF EJS Templates
context: remove unused overlayfilectx (API)...
Sean Farley -
r39748:15e86ecf default
parent child Browse files
Show More
@@ -623,7 +623,6 b' class basefilectx(object):'
623 623 workingfilectx: a filecontext that represents files from the working
624 624 directory,
625 625 memfilectx: a filecontext that represents files in-memory,
626 overlayfilectx: duplicate another filecontext with some fields overridden.
627 626 """
628 627 @propertycache
629 628 def _filelog(self):
@@ -2370,76 +2369,6 b' class memfilectx(committablefilectx):'
2370 2369 """wraps repo.wwrite"""
2371 2370 self._data = data
2372 2371
2373 class overlayfilectx(committablefilectx):
2374 """Like memfilectx but take an original filectx and optional parameters to
2375 override parts of it. This is useful when fctx.data() is expensive (i.e.
2376 flag processor is expensive) and raw data, flags, and filenode could be
2377 reused (ex. rebase or mode-only amend a REVIDX_EXTSTORED file).
2378 """
2379
2380 def __init__(self, originalfctx, datafunc=None, path=None, flags=None,
2381 copied=None, ctx=None):
2382 """originalfctx: filecontext to duplicate
2383
2384 datafunc: None or a function to override data (file content). It is a
2385 function to be lazy. path, flags, copied, ctx: None or overridden value
2386
2387 copied could be (path, rev), or False. copied could also be just path,
2388 and will be converted to (path, nullid). This simplifies some callers.
2389 """
2390
2391 if path is None:
2392 path = originalfctx.path()
2393 if ctx is None:
2394 ctx = originalfctx.changectx()
2395 ctxmatch = lambda: True
2396 else:
2397 ctxmatch = lambda: ctx == originalfctx.changectx()
2398
2399 repo = originalfctx.repo()
2400 flog = originalfctx.filelog()
2401 super(overlayfilectx, self).__init__(repo, path, flog, ctx)
2402
2403 if copied is None:
2404 copied = originalfctx.renamed()
2405 copiedmatch = lambda: True
2406 else:
2407 if copied and not isinstance(copied, tuple):
2408 # repo._filecommit will recalculate copyrev so nullid is okay
2409 copied = (copied, nullid)
2410 copiedmatch = lambda: copied == originalfctx.renamed()
2411
2412 # When data, copied (could affect data), ctx (could affect filelog
2413 # parents) are not overridden, rawdata, rawflags, and filenode may be
2414 # reused (repo._filecommit should double check filelog parents).
2415 #
2416 # path, flags are not hashed in filelog (but in manifestlog) so they do
2417 # not affect reusable here.
2418 #
2419 # If ctx or copied is overridden to a same value with originalfctx,
2420 # still consider it's reusable. originalfctx.renamed() may be a bit
2421 # expensive so it's not called unless necessary. Assuming datafunc is
2422 # always expensive, do not call it for this "reusable" test.
2423 reusable = datafunc is None and ctxmatch() and copiedmatch()
2424
2425 if datafunc is None:
2426 datafunc = originalfctx.data
2427 if flags is None:
2428 flags = originalfctx.flags()
2429
2430 self._datafunc = datafunc
2431 self._flags = flags
2432 self._copied = copied
2433
2434 if reusable:
2435 # copy extra fields from originalfctx
2436 attrs = ['rawdata', 'rawflags', '_filenode', '_filerev']
2437 for attr_ in attrs:
2438 if util.safehasattr(originalfctx, attr_):
2439 setattr(self, attr_, getattr(originalfctx, attr_))
2440
2441 def data(self):
2442 return self._datafunc()
2443 2372
2444 2373 class metadataonlyctx(committablectx):
2445 2374 """Like memctx but it's reusing the manifest of different commit.
General Comments 0
You need to be logged in to leave comments. Login now