Show More
@@ -10,7 +10,6 b' from __future__ import absolute_import' | |||||
10 |
|
10 | |||
11 | import copy |
|
11 | import copy | |
12 | import hashlib |
|
12 | import hashlib | |
13 | import heapq |
|
|||
14 | import struct |
|
13 | import struct | |
15 |
|
14 | |||
16 | from .node import nullrev |
|
15 | from .node import nullrev | |
@@ -63,35 +62,33 b' def _getstatichidden(repo):' | |||||
63 |
|
62 | |||
64 | """ |
|
63 | """ | |
65 | assert not repo.changelog.filteredrevs |
|
64 | assert not repo.changelog.filteredrevs | |
66 |
hidden = |
|
65 | hidden = hideablerevs(repo) | |
67 | if hidden: |
|
66 | if hidden: | |
68 | getphase = repo._phasecache.phase |
|
67 | pfunc = repo.changelog.parentrevs | |
69 | getparentrevs = repo.changelog.parentrevs |
|
68 | ||
70 | # Skip heads which are public (guaranteed to not be hidden) |
|
69 | mutablephases = (phases.draft, phases.secret) | |
71 | heap = [-r for r in repo.changelog.headrevs() if getphase(repo, r)] |
|
70 | mutable = repo._phasecache.getrevset(repo, mutablephases) | |
72 | heapq.heapify(heap) |
|
71 | blockers = _consistencyblocker(pfunc, hidden, mutable) | |
73 | heappop = heapq.heappop |
|
72 | ||
74 | heappush = heapq.heappush |
|
73 | if blockers: | |
75 | seen = set() # no need to init it with heads, they have no children |
|
74 | hidden = hidden - _domainancestors(pfunc, blockers, mutable) | |
76 | while heap: |
|
|||
77 | rev = -heappop(heap) |
|
|||
78 | # All children have been processed so at that point, if no children |
|
|||
79 | # removed 'rev' from the 'hidden' set, 'rev' is going to be hidden. |
|
|||
80 | blocker = rev not in hidden |
|
|||
81 | for parent in getparentrevs(rev): |
|
|||
82 | if parent == nullrev: |
|
|||
83 | continue |
|
|||
84 | if blocker: |
|
|||
85 | # If visible, ensure parent will be visible too |
|
|||
86 | hidden.discard(parent) |
|
|||
87 | # - Avoid adding the same revision twice |
|
|||
88 | # - Skip nodes which are public (guaranteed to not be hidden) |
|
|||
89 | pre = len(seen) |
|
|||
90 | seen.add(parent) |
|
|||
91 | if pre < len(seen) and getphase(repo, rev): |
|
|||
92 | heappush(heap, -parent) |
|
|||
93 | return hidden |
|
75 | return hidden | |
94 |
|
76 | |||
|
77 | def _consistencyblocker(pfunc, hideable, domain): | |||
|
78 | """return non-hideable changeset blocking hideable one | |||
|
79 | ||||
|
80 | For consistency, we cannot actually hide a changeset if one of it children | |||
|
81 | are visible, this function find such children. | |||
|
82 | """ | |||
|
83 | others = domain - hideable | |||
|
84 | blockers = set() | |||
|
85 | for r in others: | |||
|
86 | for p in pfunc(r): | |||
|
87 | if p != nullrev and p in hideable: | |||
|
88 | blockers.add(r) | |||
|
89 | break | |||
|
90 | return blockers | |||
|
91 | ||||
95 | def _domainancestors(pfunc, revs, domain): |
|
92 | def _domainancestors(pfunc, revs, domain): | |
96 | """return ancestors of 'revs' within 'domain' |
|
93 | """return ancestors of 'revs' within 'domain' | |
97 |
|
94 |
General Comments 0
You need to be logged in to leave comments.
Login now