##// END OF EJS Templates
repoview: move subsettable in a dedicated module...
marmoute -
r42309:890f450f default draft
parent child Browse files
Show More
@@ -0,0 +1,22 b''
1 # repoviewutil.py - constaints data relevant to repoview.py and other module
2 #
3 # Copyright 2012 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
4 # Logilab SA <contact@logilab.fr>
5 #
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
8
9 from __future__ import absolute_import
10
11 ### Nearest subset relation
12 # Nearest subset of filter X is a filter Y so that:
13 # * Y is included in X,
14 # * X - Y is as small as possible.
15 # This create and ordering used for branchmap purpose.
16 # the ordering may be partial
17 subsettable = {None: 'visible',
18 'visible-hidden': 'visible',
19 'visible': 'served',
20 'served.hidden': 'served',
21 'served': 'immutable',
22 'immutable': 'base'}
@@ -94,6 +94,10 b' try:'
94 except ImportError:
94 except ImportError:
95 pass
95 pass
96 try:
96 try:
97 from mercurial.utils import repoviewutil # since 5.0
98 except ImportError:
99 repoviewutil = None
100 try:
97 from mercurial import scmutil # since 1.9 (or 8b252e826c68)
101 from mercurial import scmutil # since 1.9 (or 8b252e826c68)
98 except ImportError:
102 except ImportError:
99 pass
103 pass
@@ -471,7 +475,8 b' def getbranchmapsubsettable():'
471 # subsettable is defined in:
475 # subsettable is defined in:
472 # - branchmap since 2.9 (or 175c6fd8cacc)
476 # - branchmap since 2.9 (or 175c6fd8cacc)
473 # - repoview since 2.5 (or 59a9f18d4587)
477 # - repoview since 2.5 (or 59a9f18d4587)
474 for mod in (branchmap, repoview):
478 # - repoviewutil since 5.0
479 for mod in (branchmap, repoview, repoviewutil):
475 subsettable = getattr(mod, 'subsettable', None)
480 subsettable = getattr(mod, 'subsettable', None)
476 if subsettable:
481 if subsettable:
477 return subsettable
482 return subsettable
@@ -23,28 +23,17 b' from . import ('
23 util,
23 util,
24 )
24 )
25 from .utils import (
25 from .utils import (
26 repoviewutil,
26 stringutil,
27 stringutil,
27 )
28 )
28
29
30 subsettable = repoviewutil. subsettable
31
29 calcsize = struct.calcsize
32 calcsize = struct.calcsize
30 pack_into = struct.pack_into
33 pack_into = struct.pack_into
31 unpack_from = struct.unpack_from
34 unpack_from = struct.unpack_from
32
35
33
36
34 ### Nearest subset relation
35 # Nearest subset of filter X is a filter Y so that:
36 # * Y is included in X,
37 # * X - Y is as small as possible.
38 # This create and ordering used for branchmap purpose.
39 # the ordering may be partial
40 subsettable = {None: 'visible',
41 'visible-hidden': 'visible',
42 'visible': 'served',
43 'served.hidden': 'served',
44 'served': 'immutable',
45 'immutable': 'base'}
46
47
48 class BranchMapCache(object):
37 class BranchMapCache(object):
49 """mapping of filtered views of repo with their branchcache"""
38 """mapping of filtered views of repo with their branchcache"""
50 def __init__(self):
39 def __init__(self):
@@ -25,9 +25,9 b' def hideablerevs(repo):'
25 This is a standalone function to allow extensions to wrap it.
25 This is a standalone function to allow extensions to wrap it.
26
26
27 Because we use the set of immutable changesets as a fallback subset in
27 Because we use the set of immutable changesets as a fallback subset in
28 branchmap (see mercurial.branchmap.subsettable), you cannot set "public"
28 branchmap (see mercurial.utils.repoviewutils.subsettable), you cannot set
29 changesets as "hideable". Doing so would break multiple code assertions and
29 "public" changesets as "hideable". Doing so would break multiple code
30 lead to crashes."""
30 assertions and lead to crashes."""
31 obsoletes = obsolete.getrevs(repo, 'obsolete')
31 obsoletes = obsolete.getrevs(repo, 'obsolete')
32 internals = repo._phasecache.getrevset(repo, phases.localhiddenphases)
32 internals = repo._phasecache.getrevset(repo, phases.localhiddenphases)
33 internals = frozenset(internals)
33 internals = frozenset(internals)
@@ -144,7 +144,7 b' def computeimpactable(repo, visibilityex'
144 # function to compute filtered set
144 # function to compute filtered set
145 #
145 #
146 # When adding a new filter you MUST update the table at:
146 # When adding a new filter you MUST update the table at:
147 # mercurial.branchmap.subsettable
147 # mercurial.utils.repoviewutil.subsettable
148 # Otherwise your filter will have to recompute all its branches cache
148 # Otherwise your filter will have to recompute all its branches cache
149 # from scratch (very slow).
149 # from scratch (very slow).
150 filtertable = {'visible': computehidden,
150 filtertable = {'visible': computehidden,
@@ -10,7 +10,7 b' import sys'
10 # write static check patterns here
10 # write static check patterns here
11 perfpypats = [
11 perfpypats = [
12 [
12 [
13 (r'(branchmap|repoview)\.subsettable',
13 (r'(branchmap|repoview|repoviewutil)\.subsettable',
14 "use getbranchmapsubsettable() for early Mercurial"),
14 "use getbranchmapsubsettable() for early Mercurial"),
15 (r'\.(vfs|svfs|opener|sopener)',
15 (r'\.(vfs|svfs|opener|sopener)',
16 "use getvfs()/getsvfs() for early Mercurial"),
16 "use getvfs()/getsvfs() for early Mercurial"),
General Comments 0
You need to be logged in to leave comments. Login now