comparison mercurial/repair.py @ 16716:0311a6abd38a

localrepo: strip now incrementally updates the branchheads cache Destroying history via strip used to invalidate the branchheads cache, causing it to be regenerated the next time it is read. This is expensive in large repos. This change converts strip to pass info to localrepo.destroyed() to enable to it to incrementally update the cache, improving the performance of strip and other operations that depend on it (e.g., rebase). This change also strengthens a bit the integrity checking of the branchheads cache when it is read, by rejecting the cache if it has nodes in it that no longer exist.
author Joshua Redstone <joshua.redstone@fb.com>
date Fri, 11 May 2012 10:35:54 -0700
parents c2d9ef43ff6c
children 27b2e1823e83
comparison
equal deleted inserted replaced
16715:1e24da6fcd67 16716:0311a6abd38a
54 collectone(repo.file(fname)) 54 collectone(repo.file(fname))
55 55
56 return s 56 return s
57 57
58 def strip(ui, repo, nodelist, backup="all", topic='backup'): 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
59 cl = repo.changelog 64 cl = repo.changelog
60 # TODO handle undo of merge sets 65 # TODO handle undo of merge sets
61 if isinstance(nodelist, str): 66 if isinstance(nodelist, str):
62 nodelist = [nodelist] 67 nodelist = [nodelist]
63 striplist = [cl.rev(node) for node in nodelist] 68 striplist = [cl.rev(node) for node in nodelist]
64 striprev = min(striplist) 69 striprev = min(striplist)
70
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))
65 78
66 keeppartialbundle = backup == 'strip' 79 keeppartialbundle = backup == 'strip'
67 80
68 # Some revisions with rev > striprev may not be descendants of striprev. 81 # Some revisions with rev > striprev may not be descendants of striprev.
69 # We have to find these revisions and put them in a bundle, so that 82 # We have to find these revisions and put them in a bundle, so that
167 elif saveheads: 180 elif saveheads:
168 ui.warn(_("strip failed, partial bundle stored in '%s'\n") 181 ui.warn(_("strip failed, partial bundle stored in '%s'\n")
169 % chgrpfile) 182 % chgrpfile)
170 raise 183 raise
171 184
172 repo.destroyed() 185 repo.destroyed(newheadrevs)