--- a/hgext/states.py Tue Sep 27 11:25:13 2011 +0200
+++ b/hgext/states.py Wed Sep 28 12:35:55 2011 +0200
@@ -1038,35 +1038,28 @@
def strip(ui, repo, node, backup="all"):
cl = repo.changelog
-
striprev = cl.rev(node)
revstostrip = set(cl.descendants(striprev))
revstostrip.add(striprev)
- tostrip = set(cl.node(rev) for rev in revstostrip) # XXX stay in nodes?
-
- baserevstostrip = revstostrip - set(cl.descendants(*revstostrip))
- basetostrip = set(cl.node(rev) for rev in baserevstostrip) # XXX stay in nodes?
- newstatesheads = reduce(or_,
- (set(cl.parents(n)) for n in basetostrip),
- set([]))
-
- statesheads={} # use this cache as repo.nodestate shall work
- for nd in newstatesheads:
+ tostrip = set(map(cl.node, revstostrip))
+ # compute the potentially new created states bondaries which are any
+ # parent of the stripped node that are not stripped (may not be heads)
+ newbondaries = set(par for nod in tostrip for par in cl.parents(nod)
+ if par not in tostrip)
+ # save the current states of newbondaries in a chache as repo.nodestate
+ # must work along the loop. We will use the next loop to add them.
+ statesheads={}
+ for nd in newbondaries:
state = repo.nodestate(nd)
- if not state.trackheads:
- continue
- statesheads.setdefault(state, set([])).add(nd)
+ if state.trackheads:
+ statesheads.setdefault(state, set([])).add(nd)
for state, heads in repo._statesheads.iteritems():
- if not state.trackheads:
- continue
- heads = set(heads)
- headstostrip = tostrip & heads
- heads.difference_update(headstostrip)
- heads.update(statesheads.get(state, set([])))
- repo._statesheads[state] = list(heads)
- _writestateshead(repo) # after ostrip ?
-
+ if state.trackheads:
+ heads = set(heads) - tostrip | statesheads.get(state, set([]))
+ repo._statesheads[state] = list(heads)
+ _writestateshead(repo)
return ostrip(ui, repo, node, backup)
+
mercurial.repair.strip = strip