Show More
@@ -550,9 +550,6 b' class localrepository(repo.repository):' | |||
|
550 | 550 | continue |
|
551 | 551 | node, label = l.split(" ", 1) |
|
552 | 552 | label = encoding.tolocal(label.strip()) |
|
553 | if not node in self: | |
|
554 | raise ValueError('invalidating branch cache because node '+ | |
|
555 | '%s does not exist' % node) | |
|
556 | 553 | partial.setdefault(label, []).append(bin(node)) |
|
557 | 554 | except KeyboardInterrupt: |
|
558 | 555 | raise |
@@ -574,10 +571,6 b' class localrepository(repo.repository):' | |||
|
574 | 571 | pass |
|
575 | 572 | |
|
576 | 573 | def _updatebranchcache(self, partial, ctxgen): |
|
577 | """Given a branchhead cache, partial, that may have extra nodes or be | |
|
578 | missing heads, and a generator of nodes that are at least a superset of | |
|
579 | heads missing, this function updates partial to be correct. | |
|
580 | """ | |
|
581 | 574 | # collect new branch entries |
|
582 | 575 | newbranches = {} |
|
583 | 576 | for c in ctxgen: |
@@ -588,42 +581,21 b' class localrepository(repo.repository):' | |||
|
588 | 581 | for branch, newnodes in newbranches.iteritems(): |
|
589 | 582 | bheads = partial.setdefault(branch, []) |
|
590 | 583 | bheads.extend(newnodes) |
|
591 | # Remove duplicates - nodes that are in newnodes and are already in | |
|
592 | # bheads. This can happen if you strip a node and its parent was | |
|
593 | # already a head (because they're on different branches). | |
|
594 | bheads = set(bheads) | |
|
595 | ||
|
596 | # Remove candidate heads that no longer are in the repo (e.g., as | |
|
597 | # the result of a strip that just happened). | |
|
598 | # avoid using 'bhead in self' here because that dives down into | |
|
599 | # branchcache code somewhat recrusively. | |
|
600 | bheads = [bhead for bhead in bheads \ | |
|
601 | if self.changelog.hasnode(bhead)] | |
|
602 |
if |
|
|
603 | bheads = sorted(bheads, key=lambda x: self[x].rev()) | |
|
604 | # starting from tip means fewer passes over reachable | |
|
605 | while newnodes: | |
|
606 | latest = newnodes.pop() | |
|
607 | if latest not in bheads: | |
|
608 | continue | |
|
609 | minbhnode = self[bheads[0]].node() | |
|
610 | reachable = self.changelog.reachable(latest, minbhnode) | |
|
611 | reachable.remove(latest) | |
|
612 | if reachable: | |
|
613 | bheads = [b for b in bheads if b not in reachable] | |
|
584 | if len(bheads) <= 1: | |
|
585 | continue | |
|
586 | bheads = sorted(bheads, key=lambda x: self[x].rev()) | |
|
587 | # starting from tip means fewer passes over reachable | |
|
588 | while newnodes: | |
|
589 | latest = newnodes.pop() | |
|
590 | if latest not in bheads: | |
|
591 | continue | |
|
592 | minbhnode = self[bheads[0]].node() | |
|
593 | reachable = self.changelog.reachable(latest, minbhnode) | |
|
594 | reachable.remove(latest) | |
|
595 | if reachable: | |
|
596 | bheads = [b for b in bheads if b not in reachable] | |
|
614 | 597 | partial[branch] = bheads |
|
615 | 598 | |
|
616 | # There may be branches that cease to exist when the last commit in the | |
|
617 | # branch was stripped. This code filters them out. Note that the | |
|
618 | # branch that ceased to exist may not be in newbranches because | |
|
619 | # newbranches is the set of candidate heads, which when you strip the | |
|
620 | # last commit in a branch will be the parent branch. | |
|
621 | for branch in partial.keys(): | |
|
622 | nodes = [head for head in partial[branch] \ | |
|
623 | if self.changelog.hasnode(head)] | |
|
624 | if len(nodes) < 1: | |
|
625 | del partial[branch] | |
|
626 | ||
|
627 | 599 | def lookup(self, key): |
|
628 | 600 | return self[key].node() |
|
629 | 601 | |
@@ -886,9 +858,6 b' class localrepository(repo.repository):' | |||
|
886 | 858 | else: |
|
887 | 859 | ui.status(_('working directory now based on ' |
|
888 | 860 | 'revision %d\n') % parents) |
|
889 | # TODO: if we know which new heads may result from this rollback, pass | |
|
890 | # them to destroy(), which will prevent the branchhead cache from being | |
|
891 | # invalidated. | |
|
892 | 861 | self.destroyed() |
|
893 | 862 | return 0 |
|
894 | 863 | |
@@ -1332,27 +1301,12 b' class localrepository(repo.repository):' | |||
|
1332 | 1301 | tr.release() |
|
1333 | 1302 | lock.release() |
|
1334 | 1303 | |
|
1335 |
def destroyed(self |
|
|
1304 | def destroyed(self): | |
|
1336 | 1305 | '''Inform the repository that nodes have been destroyed. |
|
1337 | 1306 | Intended for use by strip and rollback, so there's a common |
|
1338 | place for anything that has to be done after destroying history. | |
|
1339 | ||
|
1340 | If you know the branchheadcache was uptodate before nodes were removed | |
|
1341 | and you also know the set of candidate set of new heads that may have | |
|
1342 | resulted from the destruction, you can set newheadrevs. This will | |
|
1343 | enable the code to update the branchheads cache, rather than having | |
|
1344 | future code decide it's invalid and regenrating it. | |
|
1345 | ''' | |
|
1346 | if newheadrevs: | |
|
1347 | tiprev = len(self) - 1 | |
|
1348 | ctxgen = (self[rev] for rev in newheadrevs) | |
|
1349 | self._updatebranchcache(self._branchcache, ctxgen) | |
|
1350 | self._writebranchcache(self._branchcache, self.changelog.tip(), | |
|
1351 | tiprev) | |
|
1352 | else: | |
|
1353 | # No info to update the cache. If nodes were destroyed, the cache | |
|
1354 | # is stale and this will be caught the next time it is read. | |
|
1355 | pass | |
|
1307 | place for anything that has to be done after destroying history.''' | |
|
1308 | # XXX it might be nice if we could take the list of destroyed | |
|
1309 | # nodes, but I don't see an easy way for rollback() to do that | |
|
1356 | 1310 | |
|
1357 | 1311 | # Ensure the persistent tag cache is updated. Doing it now |
|
1358 | 1312 | # means that the tag cache only has to worry about destroyed |
@@ -56,11 +56,6 b' def _collectbrokencsets(repo, files, str' | |||
|
56 | 56 | return s |
|
57 | 57 | |
|
58 | 58 | def strip(ui, repo, nodelist, backup="all", topic='backup'): |
|
59 | # It simplifies the logic around updating the branchheads cache if we only | |
|
60 | # have to consider the effect of the stripped revisions and not revisions | |
|
61 | # missing because the cache is out-of-date. | |
|
62 | repo.updatebranchcache() | |
|
63 | ||
|
64 | 59 | cl = repo.changelog |
|
65 | 60 | # TODO handle undo of merge sets |
|
66 | 61 | if isinstance(nodelist, str): |
@@ -68,14 +63,6 b' def strip(ui, repo, nodelist, backup="al' | |||
|
68 | 63 | striplist = [cl.rev(node) for node in nodelist] |
|
69 | 64 | striprev = min(striplist) |
|
70 | 65 | |
|
71 | # Set of potential new heads resulting from the strip. The parents of any | |
|
72 | # node removed could be a new head because the node to be removed could have | |
|
73 | # been the only child of the parent. | |
|
74 | # Do a list->set->list conversion to remove duplicates. | |
|
75 | stringstriplist = [str(rev) for rev in striplist] | |
|
76 | newheadrevs = set(repo.revs("parents(%lr::) - %lr::", stringstriplist, | |
|
77 | stringstriplist)) | |
|
78 | ||
|
79 | 66 | keeppartialbundle = backup == 'strip' |
|
80 | 67 | |
|
81 | 68 | # Some revisions with rev > striprev may not be descendants of striprev. |
@@ -182,4 +169,4 b' def strip(ui, repo, nodelist, backup="al' | |||
|
182 | 169 | % chgrpfile) |
|
183 | 170 | raise |
|
184 | 171 | |
|
185 |
repo.destroyed( |
|
|
172 | repo.destroyed() |
@@ -247,7 +247,6 b' Same thing, different code path:' | |||
|
247 | 247 | |
|
248 | 248 | $ echo b >> b |
|
249 | 249 | $ hg ci -m 'reopen branch' |
|
250 | created new head | |
|
251 | 250 | reopening closed branch head 4 |
|
252 | 251 | $ echo b >> b |
|
253 | 252 | $ hg ci --amend --close-branch |
@@ -36,8 +36,7 b' mq patch on an empty repo' | |||
|
36 | 36 | $ hg qrefresh -m 'patch 1' |
|
37 | 37 | $ show_branch_cache |
|
38 | 38 | tip: 0 |
|
39 | d986d5caac23a7d44a46efc0ddaf5eb9665844cf 0 | |
|
40 | d986d5caac23a7d44a46efc0ddaf5eb9665844cf default | |
|
39 | No branch cache | |
|
41 | 40 | |
|
42 | 41 | some regular revisions |
|
43 | 42 | |
@@ -76,8 +75,8 b' add some mq patches' | |||
|
76 | 75 | $ hg qrefresh -m 'patch 2' |
|
77 | 76 | $ show_branch_cache 1 |
|
78 | 77 | tip: 3 |
|
79 | 982611f6955f9c48d3365decea203217c945ef0d 2 | |
|
80 | 982611f6955f9c48d3365decea203217c945ef0d bar | |
|
78 | c229711f16da3d7591f89b1b8d963b79bda22714 1 | |
|
79 | c229711f16da3d7591f89b1b8d963b79bda22714 bar | |
|
81 | 80 | dc25e3827021582e979f600811852e36cbe57341 foo |
|
82 | 81 | branch foo: 3 |
|
83 | 82 | branch bar: 2 |
General Comments 0
You need to be logged in to leave comments.
Login now