##// END OF EJS Templates
histedit: factorise node stripping logic...
Pierre-Yves David -
r17664:4eb13b61 default
parent child Browse files
Show More
@@ -482,21 +482,8 b' def histedit(ui, repo, *parent, **opts):'
482 existing, rules, keep, tip, replacemap) = readstate(repo)
482 existing, rules, keep, tip, replacemap) = readstate(repo)
483 ui.debug('restore wc to old tip %s\n' % node.hex(tip))
483 ui.debug('restore wc to old tip %s\n' % node.hex(tip))
484 hg.clean(repo, tip)
484 hg.clean(repo, tip)
485 ui.debug('should strip created nodes %s\n' %
485 cleanupnode(ui, repo, 'created', created)
486 ', '.join([node.short(n) for n in created]))
486 cleanupnode(ui, repo, 'temp', tmpnodes)
487 ui.debug('should strip temp nodes %s\n' %
488 ', '.join([node.short(n) for n in tmpnodes]))
489 for nodes in (created, tmpnodes):
490 lock = None
491 try:
492 lock = repo.lock()
493 for n in reversed(nodes):
494 try:
495 repair.strip(ui, repo, n)
496 except error.LookupError:
497 pass
498 finally:
499 lockmod.release(lock)
500 os.unlink(os.path.join(repo.path, 'histedit-state'))
487 os.unlink(os.path.join(repo.path, 'histedit-state'))
501 return
488 return
502 else:
489 else:
@@ -604,32 +591,9 b' def histedit(ui, repo, *parent, **opts):'
604 if replacemap:
591 if replacemap:
605 movebookmarks(ui, repo, replacemap, tmpnodes, created)
592 movebookmarks(ui, repo, replacemap, tmpnodes, created)
606 # TODO update mq state
593 # TODO update mq state
594 cleanupnode(ui, repo, 'replaced', replaced)
607
595
608 ui.debug('should strip replaced nodes %s\n' %
596 cleanupnode(ui, repo, 'temp', tmpnodes)
609 ', '.join([node.short(n) for n in replaced]))
610 lock = None
611 try:
612 lock = repo.lock()
613 for n in sorted(replaced, key=lambda x: repo[x].rev()):
614 try:
615 repair.strip(ui, repo, n)
616 except error.LookupError:
617 pass
618 finally:
619 lockmod.release(lock)
620
621 ui.debug('should strip temp nodes %s\n' %
622 ', '.join([node.short(n) for n in tmpnodes]))
623 lock = None
624 try:
625 lock = repo.lock()
626 for n in reversed(tmpnodes):
627 try:
628 repair.strip(ui, repo, n)
629 except error.LookupError:
630 pass
631 finally:
632 lockmod.release(lock)
633 os.unlink(os.path.join(repo.path, 'histedit-state'))
597 os.unlink(os.path.join(repo.path, 'histedit-state'))
634 if os.path.exists(repo.sjoin('undo')):
598 if os.path.exists(repo.sjoin('undo')):
635 os.unlink(repo.sjoin('undo'))
599 os.unlink(repo.sjoin('undo'))
@@ -747,3 +711,26 b' def movebookmarks(ui, repo, replacemap, '
747
711
748 for old, new in sorted(replacemap.iteritems()):
712 for old, new in sorted(replacemap.iteritems()):
749 copybms(old, new)
713 copybms(old, new)
714
715 def cleanupnode(ui, repo, name, nodes):
716 """strip a group of nodes from the repository
717
718 The set of node to strip may contains unknown nodes."""
719 ui.debug('should strip %s nodes %s\n' %
720 (name, ', '.join([node.short(n) for n in nodes])))
721 lock = None
722 try:
723 lock = repo.lock()
724 # Find all node that need to be stripped
725 # (we hg %lr instead of %ln to silently ignore unknown item
726 nm = repo.changelog.nodemap
727 nodes = [n for n in nodes if n in nm]
728 roots = [c.node() for c in repo.set("roots(%ln)", nodes)]
729 for c in roots:
730 # We should process node in reverse order to strip tip most first.
731 # but this trigger a bug in changegroup hook.
732 # This would reduce bundle overhead
733 repair.strip(ui, repo, c)
734 finally:
735 lockmod.release(lock)
736
General Comments 0
You need to be logged in to leave comments. Login now