[PATCH 3 of 6 ctx-minor-fixes] context: remove unused overlayctx
Sean Farley
sean at farley.io
Wed Sep 19 01:35:45 EDT 2018
# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1526985338 -7200
# Tue May 22 12:35:38 2018 +0200
# Branch ctx-minor-fixes
# Node ID 2a524ac6b6e5da11f0f8ab9c9137d44c16f724b5
# Parent c21a9a45b1a718d67d294fb822b58c7d6a2aa207
context: remove unused overlayctx
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.
diff --git a/mercurial/context.py b/mercurial/context.py
index f85f426..4149dec 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -621,11 +621,10 @@ class basefilectx(object):
filectx: read-only access to a filerevision that is already present
in the repo,
workingfilectx: a filecontext that represents files from the working
directory,
memfilectx: a filecontext that represents files in-memory,
- overlayfilectx: duplicate another filecontext with some fields overridden.
"""
@propertycache
def _filelog(self):
return self._repo.file(self._path)
@@ -2368,80 +2367,10 @@ class memfilectx(committablefilectx):
def write(self, data, flags, **kwargs):
"""wraps repo.wwrite"""
self._data = data
-class overlayfilectx(committablefilectx):
- """Like memfilectx but take an original filectx and optional parameters to
- override parts of it. This is useful when fctx.data() is expensive (i.e.
- flag processor is expensive) and raw data, flags, and filenode could be
- reused (ex. rebase or mode-only amend a REVIDX_EXTSTORED file).
- """
-
- def __init__(self, originalfctx, datafunc=None, path=None, flags=None,
- copied=None, ctx=None):
- """originalfctx: filecontext to duplicate
-
- datafunc: None or a function to override data (file content). It is a
- function to be lazy. path, flags, copied, ctx: None or overridden value
-
- copied could be (path, rev), or False. copied could also be just path,
- and will be converted to (path, nullid). This simplifies some callers.
- """
-
- if path is None:
- path = originalfctx.path()
- if ctx is None:
- ctx = originalfctx.changectx()
- ctxmatch = lambda: True
- else:
- ctxmatch = lambda: ctx == originalfctx.changectx()
-
- repo = originalfctx.repo()
- flog = originalfctx.filelog()
- super(overlayfilectx, self).__init__(repo, path, flog, ctx)
-
- if copied is None:
- copied = originalfctx.renamed()
- copiedmatch = lambda: True
- else:
- if copied and not isinstance(copied, tuple):
- # repo._filecommit will recalculate copyrev so nullid is okay
- copied = (copied, nullid)
- copiedmatch = lambda: copied == originalfctx.renamed()
-
- # When data, copied (could affect data), ctx (could affect filelog
- # parents) are not overridden, rawdata, rawflags, and filenode may be
- # reused (repo._filecommit should double check filelog parents).
- #
- # path, flags are not hashed in filelog (but in manifestlog) so they do
- # not affect reusable here.
- #
- # If ctx or copied is overridden to a same value with originalfctx,
- # still consider it's reusable. originalfctx.renamed() may be a bit
- # expensive so it's not called unless necessary. Assuming datafunc is
- # always expensive, do not call it for this "reusable" test.
- reusable = datafunc is None and ctxmatch() and copiedmatch()
-
- if datafunc is None:
- datafunc = originalfctx.data
- if flags is None:
- flags = originalfctx.flags()
-
- self._datafunc = datafunc
- self._flags = flags
- self._copied = copied
-
- if reusable:
- # copy extra fields from originalfctx
- attrs = ['rawdata', 'rawflags', '_filenode', '_filerev']
- for attr_ in attrs:
- if util.safehasattr(originalfctx, attr_):
- setattr(self, attr_, getattr(originalfctx, attr_))
-
- def data(self):
- return self._datafunc()
class metadataonlyctx(committablectx):
"""Like memctx but it's reusing the manifest of different commit.
Intended to be used by lightweight operations that are creating
metadata-only changes.
More information about the Mercurial-devel
mailing list