Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 39712:15e86ecf6b26
context: remove unused overlayfilectx (API)
It seems that this was maybe used in an extension but at this point
nothing in lfs, hg-experimental, or any other cursory repo looked at has
a reference to this class; so, for now, let's just remove it.
author | Sean Farley <sean@farley.io> |
---|---|
date | Tue, 22 May 2018 12:35:38 +0200 |
parents | 6c8ceebce309 |
children | a5dafefc4a53 |
comparison
equal
deleted
inserted
replaced
39711:6c8ceebce309 | 39712:15e86ecf6b26 |
---|---|
621 filectx: read-only access to a filerevision that is already present | 621 filectx: read-only access to a filerevision that is already present |
622 in the repo, | 622 in the repo, |
623 workingfilectx: a filecontext that represents files from the working | 623 workingfilectx: a filecontext that represents files from the working |
624 directory, | 624 directory, |
625 memfilectx: a filecontext that represents files in-memory, | 625 memfilectx: a filecontext that represents files in-memory, |
626 overlayfilectx: duplicate another filecontext with some fields overridden. | |
627 """ | 626 """ |
628 @propertycache | 627 @propertycache |
629 def _filelog(self): | 628 def _filelog(self): |
630 return self._repo.file(self._path) | 629 return self._repo.file(self._path) |
631 | 630 |
2368 | 2367 |
2369 def write(self, data, flags, **kwargs): | 2368 def write(self, data, flags, **kwargs): |
2370 """wraps repo.wwrite""" | 2369 """wraps repo.wwrite""" |
2371 self._data = data | 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 class metadataonlyctx(committablectx): | 2373 class metadataonlyctx(committablectx): |
2445 """Like memctx but it's reusing the manifest of different commit. | 2374 """Like memctx but it's reusing the manifest of different commit. |
2446 Intended to be used by lightweight operations that are creating | 2375 Intended to be used by lightweight operations that are creating |
2447 metadata-only changes. | 2376 metadata-only changes. |