##// END OF EJS Templates
hidden: simplify the computation of consistency blocker...
marmoute -
r32476:20c1c2fb default
parent child Browse files
Show More
@@ -10,7 +10,6 b' from __future__ import absolute_import'
10 10
11 11 import copy
12 12 import hashlib
13 import heapq
14 13 import struct
15 14
16 15 from .node import nullrev
@@ -63,35 +62,33 b' def _getstatichidden(repo):'
63 62
64 63 """
65 64 assert not repo.changelog.filteredrevs
66 hidden = set(hideablerevs(repo))
65 hidden = hideablerevs(repo)
67 66 if hidden:
68 getphase = repo._phasecache.phase
69 getparentrevs = repo.changelog.parentrevs
70 # Skip heads which are public (guaranteed to not be hidden)
71 heap = [-r for r in repo.changelog.headrevs() if getphase(repo, r)]
72 heapq.heapify(heap)
73 heappop = heapq.heappop
74 heappush = heapq.heappush
75 seen = set() # no need to init it with heads, they have no children
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)
67 pfunc = repo.changelog.parentrevs
68
69 mutablephases = (phases.draft, phases.secret)
70 mutable = repo._phasecache.getrevset(repo, mutablephases)
71 blockers = _consistencyblocker(pfunc, hidden, mutable)
72
73 if blockers:
74 hidden = hidden - _domainancestors(pfunc, blockers, mutable)
93 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 92 def _domainancestors(pfunc, revs, domain):
96 93 """return ancestors of 'revs' within 'domain'
97 94
General Comments 0
You need to be logged in to leave comments. Login now