Mercurial > hg
comparison mercurial/repoview.py @ 32479:4c5bc7cbd989
hidden: unify the static and dynamic blocker logic
We no longer have cache and they both work the same way. Unifying the logic
simplify the code and reduce the amount of set copies.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 21 May 2017 15:47:06 +0200 |
parents | 1cc7c96cad75 |
children | 43ae9e6eaaba |
comparison
equal
deleted
inserted
replaced
32478:1cc7c96cad75 | 32479:4c5bc7cbd989 |
---|---|
44 tagsmod.readlocaltags(repo.ui, repo, tags, {}) | 44 tagsmod.readlocaltags(repo.ui, repo, tags, {}) |
45 if tags: | 45 if tags: |
46 rev, nodemap = cl.rev, cl.nodemap | 46 rev, nodemap = cl.rev, cl.nodemap |
47 blockers.update(rev(t[0]) for t in tags.values() if t[0] in nodemap) | 47 blockers.update(rev(t[0]) for t in tags.values() if t[0] in nodemap) |
48 return blockers | 48 return blockers |
49 | |
50 def _getstatichidden(repo): | |
51 """Revision to be hidden (disregarding dynamic blocker) | |
52 | |
53 To keep a consistent graph, we cannot hide any revisions with | |
54 non-hidden descendants. This function computes the set of | |
55 revisions that could be hidden while keeping the graph consistent. | |
56 | |
57 A second pass will be done to apply "dynamic blocker" like bookmarks or | |
58 working directory parents. | |
59 | |
60 """ | |
61 assert not repo.changelog.filteredrevs | |
62 hidden = hideablerevs(repo) | |
63 if hidden: | |
64 pfunc = repo.changelog.parentrevs | |
65 | |
66 mutablephases = (phases.draft, phases.secret) | |
67 mutable = repo._phasecache.getrevset(repo, mutablephases) | |
68 blockers = _consistencyblocker(pfunc, hidden, mutable) | |
69 | |
70 if blockers: | |
71 hidden = hidden - _domainancestors(pfunc, blockers, mutable) | |
72 return hidden | |
73 | 49 |
74 def _consistencyblocker(pfunc, hideable, domain): | 50 def _consistencyblocker(pfunc, hideable, domain): |
75 """return non-hideable changeset blocking hideable one | 51 """return non-hideable changeset blocking hideable one |
76 | 52 |
77 For consistency, we cannot actually hide a changeset if one of it children | 53 For consistency, we cannot actually hide a changeset if one of it children |
127 """compute the set of hidden revision to filter | 103 """compute the set of hidden revision to filter |
128 | 104 |
129 During most operation hidden should be filtered.""" | 105 During most operation hidden should be filtered.""" |
130 assert not repo.changelog.filteredrevs | 106 assert not repo.changelog.filteredrevs |
131 | 107 |
132 hidden = frozenset() | 108 hidden = hideablerevs(repo) |
133 hideable = hideablerevs(repo) | 109 if hidden: |
134 if hideable: | 110 pfunc = repo.changelog.parentrevs |
135 cl = repo.changelog | 111 mutablephases = (phases.draft, phases.secret) |
136 hidden = frozenset(_getstatichidden(repo)) | 112 mutable = repo._phasecache.getrevset(repo, mutablephases) |
113 | |
114 blockers = _consistencyblocker(pfunc, hidden, mutable) | |
137 | 115 |
138 # check if we have wd parents, bookmarks or tags pointing to hidden | 116 # check if we have wd parents, bookmarks or tags pointing to hidden |
139 # changesets and remove those. | 117 # changesets and remove those. |
140 dynamic = hidden & revealedrevs(repo) | 118 blockers |= (hidden & revealedrevs(repo)) |
141 if dynamic: | 119 if blockers: |
142 pfunc = cl.parentrevs | 120 hidden = hidden - _domainancestors(pfunc, blockers, mutable) |
143 mutablephases = (phases.draft, phases.secret) | 121 return frozenset(hidden) |
144 mutable = repo._phasecache.getrevset(repo, mutablephases) | |
145 hidden = hidden - _domainancestors(pfunc, dynamic, mutable) | |
146 return hidden | |
147 | 122 |
148 def computeunserved(repo): | 123 def computeunserved(repo): |
149 """compute the set of revision that should be filtered when used a server | 124 """compute the set of revision that should be filtered when used a server |
150 | 125 |
151 Secret and hidden changeset should not pretend to be here.""" | 126 Secret and hidden changeset should not pretend to be here.""" |