17 """Revisions candidates to be hidden |
17 """Revisions candidates to be hidden |
18 |
18 |
19 This is a standalone function to help extensions to wrap it.""" |
19 This is a standalone function to help extensions to wrap it.""" |
20 return obsolete.getrevs(repo, 'obsolete') |
20 return obsolete.getrevs(repo, 'obsolete') |
21 |
21 |
22 def _gethiddenblockers(repo): |
22 def _getstaticblockers(repo): |
23 """Get revisions that will block hidden changesets from being filtered |
23 """Cacheable revisions blocking hidden changesets from being filtered. |
24 |
24 |
|
25 Additional non-cached hidden blockers are computed in _getdynamicblockers. |
25 This is a standalone function to help extensions to wrap it.""" |
26 This is a standalone function to help extensions to wrap it.""" |
26 assert not repo.changelog.filteredrevs |
27 assert not repo.changelog.filteredrevs |
27 hideable = hideablerevs(repo) |
28 hideable = hideablerevs(repo) |
28 blockers = [] |
29 blockers = set() |
29 if hideable: |
30 if hideable: |
30 # We use cl to avoid recursive lookup from repo[xxx] |
31 # We use cl to avoid recursive lookup from repo[xxx] |
31 cl = repo.changelog |
32 cl = repo.changelog |
32 firsthideable = min(hideable) |
33 firsthideable = min(hideable) |
33 revs = cl.revs(start=firsthideable) |
34 revs = cl.revs(start=firsthideable) |
34 tofilter = repo.revs( |
35 tofilter = repo.revs( |
35 '(%ld) and children(%ld)', list(revs), list(hideable)) |
36 '(%ld) and children(%ld)', list(revs), list(hideable)) |
36 blockers = set([r for r in tofilter if r not in hideable]) |
37 blockers.update([r for r in tofilter if r not in hideable]) |
37 for par in repo[None].parents(): |
38 return blockers |
38 blockers.add(par.rev()) |
39 |
39 for bm in repo._bookmarks.values(): |
40 def _getdynamicblockers(repo): |
40 blockers.add(cl.rev(bm)) |
41 """Non-cacheable revisions blocking hidden changesets from being filtered. |
41 tags = {} |
42 |
42 tagsmod.readlocaltags(repo.ui, repo, tags, {}) |
43 Get revisions that will block hidden changesets and are likely to change, |
43 if tags: |
44 but unlikely to create hidden blockers. They won't be cached, so be careful |
44 rev, nodemap = cl.rev, cl.nodemap |
45 with adding additional computation.""" |
45 blockers.update(rev(t[0]) for t in tags.values() if t[0] in nodemap) |
46 |
|
47 cl = repo.changelog |
|
48 blockers = set() |
|
49 blockers.update([par.rev() for par in repo[None].parents()]) |
|
50 blockers.update([cl.rev(bm) for bm in repo._bookmarks.values()]) |
|
51 |
|
52 tags = {} |
|
53 tagsmod.readlocaltags(repo.ui, repo, tags, {}) |
|
54 if tags: |
|
55 rev, nodemap = cl.rev, cl.nodemap |
|
56 blockers.update(rev(t[0]) for t in tags.values() if t[0] in nodemap) |
46 return blockers |
57 return blockers |
47 |
58 |
48 def computehidden(repo): |
59 def computehidden(repo): |
49 """compute the set of hidden revision to filter |
60 """compute the set of hidden revision to filter |
50 |
61 |
51 During most operation hidden should be filtered.""" |
62 During most operation hidden should be filtered.""" |
52 assert not repo.changelog.filteredrevs |
63 assert not repo.changelog.filteredrevs |
|
64 hidden = frozenset() |
53 hideable = hideablerevs(repo) |
65 hideable = hideablerevs(repo) |
54 if hideable: |
66 if hideable: |
55 cl = repo.changelog |
67 cl = repo.changelog |
56 blocked = cl.ancestors(_gethiddenblockers(repo), inclusive=True) |
68 blocked = cl.ancestors(_getstaticblockers(repo), inclusive=True) |
57 return frozenset(r for r in hideable if r not in blocked) |
69 hidden = frozenset(r for r in hideable if r not in blocked) |
58 return frozenset() |
70 |
|
71 # check if we have wd parents, bookmarks or tags pointing to hidden |
|
72 # changesets and remove those. |
|
73 dynamic = hidden & _getdynamicblockers(repo) |
|
74 if dynamic: |
|
75 blocked = cl.ancestors(dynamic, inclusive=True) |
|
76 hidden = frozenset(r for r in hidden if r not in blocked) |
|
77 return hidden |
59 |
78 |
60 def computeunserved(repo): |
79 def computeunserved(repo): |
61 """compute the set of revision that should be filtered when used a server |
80 """compute the set of revision that should be filtered when used a server |
62 |
81 |
63 Secret and hidden changeset should not pretend to be here.""" |
82 Secret and hidden changeset should not pretend to be here.""" |