Mercurial > hg
comparison mercurial/repoview.py @ 18246:58ca19edc043
clfilter: add impactable filter
The `mutable` filter still have some chance to get invalidated. This will happen
when:
- you garbage collect hidden changeset,
- public phase is moved backward,
- something is changed in the filtering (this could be fixed)
So we introduce an even more stable filtering set: everything with a revision
number egal or higher than the first mutable changeset is filtered.
The only official use of this filter is for branchcache.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Wed, 02 Jan 2013 02:02:41 +0100 |
parents | aff706b3a21c |
children | 378a025ff269 |
comparison
equal
deleted
inserted
replaced
18245:aff706b3a21c | 18246:58ca19edc043 |
---|---|
38 # fast check to avoid revset call on huge repo | 38 # fast check to avoid revset call on huge repo |
39 if util.any(repo._phasecache.phaseroots[1:]): | 39 if util.any(repo._phasecache.phaseroots[1:]): |
40 return frozenset(repo.revs('draft() + secret()')) | 40 return frozenset(repo.revs('draft() + secret()')) |
41 return frozenset() | 41 return frozenset() |
42 | 42 |
43 def computeimpactable(repo): | |
44 """Everything impactable by mutable revision | |
45 | |
46 The mutable filter still have some chance to get invalidated. This will | |
47 happen when: | |
48 | |
49 - you garbage collect hidden changeset, | |
50 - public phase is moved backward, | |
51 - something is changed in the filtering (this could be fixed) | |
52 | |
53 This filter out any mutable changeset and any public changeset that may be | |
54 impacted by something happening to a mutable revision. | |
55 | |
56 This is achieved by filtered everything with a revision number egal or | |
57 higher than the first mutable changeset is filtered.""" | |
58 assert not repo.changelog.filteredrevs | |
59 cl = repo.changelog | |
60 firstmutable = len(cl) | |
61 for roots in repo._phasecache.phaseroots[1:]: | |
62 if roots: | |
63 firstmutable = min(firstmutable, min(cl.rev(r) for r in roots)) | |
64 return frozenset(xrange(firstmutable, len(cl))) | |
65 | |
43 # function to compute filtered set | 66 # function to compute filtered set |
44 filtertable = {'hidden': computehidden, | 67 filtertable = {'hidden': computehidden, |
45 'unserved': computeunserved, | 68 'unserved': computeunserved, |
46 'mutable': computemutable} | 69 'mutable': computemutable, |
70 'impactable': computeimpactable} | |
47 ### Nearest subset relation | 71 ### Nearest subset relation |
48 # Nearest subset of filter X is a filter Y so that: | 72 # Nearest subset of filter X is a filter Y so that: |
49 # * Y is included in X, | 73 # * Y is included in X, |
50 # * X - Y is as small as possible. | 74 # * X - Y is as small as possible. |
51 # This create and ordering used for branchmap purpose. | 75 # This create and ordering used for branchmap purpose. |
52 # the ordering may be partial | 76 # the ordering may be partial |
53 subsettable = {None: 'hidden', | 77 subsettable = {None: 'hidden', |
54 'hidden': 'unserved', | 78 'hidden': 'unserved', |
55 'unserved': 'mutable'} | 79 'unserved': 'mutable', |
80 'mutable': 'impactable'} | |
56 | 81 |
57 def filteredrevs(repo, filtername): | 82 def filteredrevs(repo, filtername): |
58 """returns set of filtered revision for this filter name""" | 83 """returns set of filtered revision for this filter name""" |
59 if filtername not in repo.filteredrevcache: | 84 if filtername not in repo.filteredrevcache: |
60 func = filtertable[filtername] | 85 func = filtertable[filtername] |