# HG changeset patch # User Pierre-Yves David # Date 2019-04-12 13:41:32 # Node ID caebe5e7f4bd990a366a34cf6771be3f74498f61 # Parent d086ba387ae8265b073f16421791380bd6686568 repoview: move subsettable in a dedicated module The dictionary got moved in `branchmap` to avoid import cycle. However, we are about to needs it in repoview too. So we introduce a now module to define that that mapping. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -94,6 +94,10 @@ try: except ImportError: pass try: + from mercurial.utils import repoviewutil # since 5.0 +except ImportError: + repoviewutil = None +try: from mercurial import scmutil # since 1.9 (or 8b252e826c68) except ImportError: pass @@ -471,7 +475,8 @@ def getbranchmapsubsettable(): # subsettable is defined in: # - branchmap since 2.9 (or 175c6fd8cacc) # - repoview since 2.5 (or 59a9f18d4587) - for mod in (branchmap, repoview): + # - repoviewutil since 5.0 + for mod in (branchmap, repoview, repoviewutil): subsettable = getattr(mod, 'subsettable', None) if subsettable: return subsettable diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py --- a/mercurial/branchmap.py +++ b/mercurial/branchmap.py @@ -23,28 +23,17 @@ from . import ( util, ) from .utils import ( + repoviewutil, stringutil, ) +subsettable = repoviewutil. subsettable + calcsize = struct.calcsize pack_into = struct.pack_into unpack_from = struct.unpack_from -### Nearest subset relation -# Nearest subset of filter X is a filter Y so that: -# * Y is included in X, -# * X - Y is as small as possible. -# This create and ordering used for branchmap purpose. -# the ordering may be partial -subsettable = {None: 'visible', - 'visible-hidden': 'visible', - 'visible': 'served', - 'served.hidden': 'served', - 'served': 'immutable', - 'immutable': 'base'} - - class BranchMapCache(object): """mapping of filtered views of repo with their branchcache""" def __init__(self): diff --git a/mercurial/repoview.py b/mercurial/repoview.py --- a/mercurial/repoview.py +++ b/mercurial/repoview.py @@ -25,9 +25,9 @@ def hideablerevs(repo): This is a standalone function to allow extensions to wrap it. Because we use the set of immutable changesets as a fallback subset in - branchmap (see mercurial.branchmap.subsettable), you cannot set "public" - changesets as "hideable". Doing so would break multiple code assertions and - lead to crashes.""" + branchmap (see mercurial.utils.repoviewutils.subsettable), you cannot set + "public" changesets as "hideable". Doing so would break multiple code + assertions and lead to crashes.""" obsoletes = obsolete.getrevs(repo, 'obsolete') internals = repo._phasecache.getrevset(repo, phases.localhiddenphases) internals = frozenset(internals) @@ -144,7 +144,7 @@ def computeimpactable(repo, visibilityex # function to compute filtered set # # When adding a new filter you MUST update the table at: -# mercurial.branchmap.subsettable +# mercurial.utils.repoviewutil.subsettable # Otherwise your filter will have to recompute all its branches cache # from scratch (very slow). filtertable = {'visible': computehidden, diff --git a/mercurial/utils/repoviewutil.py b/mercurial/utils/repoviewutil.py new file mode 100644 --- /dev/null +++ b/mercurial/utils/repoviewutil.py @@ -0,0 +1,22 @@ +# repoviewutil.py - constaints data relevant to repoview.py and other module +# +# Copyright 2012 Pierre-Yves David +# Logilab SA +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2 or any later version. + +from __future__ import absolute_import + +### Nearest subset relation +# Nearest subset of filter X is a filter Y so that: +# * Y is included in X, +# * X - Y is as small as possible. +# This create and ordering used for branchmap purpose. +# the ordering may be partial +subsettable = {None: 'visible', + 'visible-hidden': 'visible', + 'visible': 'served', + 'served.hidden': 'served', + 'served': 'immutable', + 'immutable': 'base'} diff --git a/tests/check-perf-code.py b/tests/check-perf-code.py --- a/tests/check-perf-code.py +++ b/tests/check-perf-code.py @@ -10,7 +10,7 @@ import sys # write static check patterns here perfpypats = [ [ - (r'(branchmap|repoview)\.subsettable', + (r'(branchmap|repoview|repoviewutil)\.subsettable', "use getbranchmapsubsettable() for early Mercurial"), (r'\.(vfs|svfs|opener|sopener)', "use getvfs()/getsvfs() for early Mercurial"),