##// END OF EJS Templates
histedit: add proper locking around repair.strip() calls
Augie Fackler -
r17326:23b2ee0f stable
parent child Browse files
Show More
@@ -150,6 +150,7 b' from mercurial import cmdutil'
150 from mercurial import discovery
150 from mercurial import discovery
151 from mercurial import error
151 from mercurial import error
152 from mercurial import hg
152 from mercurial import hg
153 from mercurial import lock as lockmod
153 from mercurial import node
154 from mercurial import node
154 from mercurial import patch
155 from mercurial import patch
155 from mercurial import repair
156 from mercurial import repair
@@ -492,11 +493,16 b' def histedit(ui, repo, *parent, **opts):'
492 ui.debug('should strip temp nodes %s\n' %
493 ui.debug('should strip temp nodes %s\n' %
493 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
494 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
494 for nodes in (created, tmpnodes):
495 for nodes in (created, tmpnodes):
495 for n in reversed(nodes):
496 lock = None
496 try:
497 try:
497 repair.strip(ui, repo, n)
498 lock = repo.lock()
498 except error.LookupError:
499 for n in reversed(nodes):
499 pass
500 try:
501 repair.strip(ui, repo, n)
502 except error.LookupError:
503 pass
504 finally:
505 lockmod.release(lock)
500 os.unlink(os.path.join(repo.path, 'histedit-state'))
506 os.unlink(os.path.join(repo.path, 'histedit-state'))
501 return
507 return
502 else:
508 else:
@@ -636,19 +642,29 b' def histedit(ui, repo, *parent, **opts):'
636
642
637 ui.debug('should strip replaced nodes %s\n' %
643 ui.debug('should strip replaced nodes %s\n' %
638 ', '.join([node.hex(n)[:12] for n in replaced]))
644 ', '.join([node.hex(n)[:12] for n in replaced]))
639 for n in sorted(replaced, key=lambda x: repo[x].rev()):
645 lock = None
646 try:
647 lock = repo.lock()
648 for n in sorted(replaced, key=lambda x: repo[x].rev()):
649 try:
650 repair.strip(ui, repo, n)
651 except error.LookupError:
652 pass
653 finally:
654 lockmod.release(lock)
655
656 ui.debug('should strip temp nodes %s\n' %
657 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
658 lock = None
659 try:
660 lock = repo.lock()
661 for n in reversed(tmpnodes):
640 try:
662 try:
641 repair.strip(ui, repo, n)
663 repair.strip(ui, repo, n)
642 except error.LookupError:
664 except error.LookupError:
643 pass
665 pass
644
666 finally:
645 ui.debug('should strip temp nodes %s\n' %
667 lockmod.release(lock)
646 ', '.join([node.hex(n)[:12] for n in tmpnodes]))
647 for n in reversed(tmpnodes):
648 try:
649 repair.strip(ui, repo, n)
650 except error.LookupError:
651 pass
652 os.unlink(os.path.join(repo.path, 'histedit-state'))
668 os.unlink(os.path.join(repo.path, 'histedit-state'))
653 if os.path.exists(repo.sjoin('undo')):
669 if os.path.exists(repo.sjoin('undo')):
654 os.unlink(repo.sjoin('undo'))
670 os.unlink(repo.sjoin('undo'))
General Comments 0
You need to be logged in to leave comments. Login now