comparison hgext/evolve.py @ 1527:e080d2ae2656 stable

parents: avoid locking the repository during 'hg parents' The wrapping code was initially written for update and pull who need the lock anyway. We duplicated the logic in the parent case to remove the need for locking.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Fri, 06 Nov 2015 18:37:16 -0500
parents c15d6168412f
children afb0a33c4f6c
comparison
equal deleted inserted replaced
1526:c2a772ade409 1527:e080d2ae2656
676 ### Various trouble warning ### 676 ### Various trouble warning ###
677 ##################################################################### 677 #####################################################################
678 678
679 # This section take care of issue warning to the user when troubles appear 679 # This section take care of issue warning to the user when troubles appear
680 680
681
682 def _warnobsoletewc(ui, repo):
683 if repo['.'].obsolete():
684 ui.warn(_('working directory parent is obsolete!\n'))
685 if (not ui.quiet) and obsolete.isenabled(repo, commandopt):
686 ui.warn(_('(use "hg evolve" to update to its successor)\n'))
687
681 @eh.wrapcommand("update") 688 @eh.wrapcommand("update")
682 @eh.wrapcommand("parents")
683 @eh.wrapcommand("pull") 689 @eh.wrapcommand("pull")
684 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): 690 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
685 """Warn that the working directory parent is an obsolete changeset""" 691 """Warn that the working directory parent is an obsolete changeset"""
686 def warnobsolete(): 692 def warnobsolete():
687 if repo['.'].obsolete(): 693 _warnobsoletewc(ui, repo)
688 ui.warn(_('working directory parent is obsolete!\n'))
689 if (not ui.quiet) and obsolete.isenabled(repo, commandopt):
690 ui.warn(_('(use "hg evolve" to update to its successor)\n'))
691 wlock = None 694 wlock = None
692 try: 695 try:
693 wlock = repo.wlock() 696 wlock = repo.wlock()
694 repo._afterlock(warnobsolete) 697 repo._afterlock(warnobsolete)
695 res = origfn(ui, repo, *args, **opts) 698 res = origfn(ui, repo, *args, **opts)
696 finally: 699 finally:
697 lockmod.release(wlock) 700 lockmod.release(wlock)
701 return res
702
703 @eh.wrapcommand("parents")
704 def wrapparents(origfn, ui, repo, *args, **opts):
705 res = origfn(ui, repo, *args, **opts)
706 _warnobsoletewc(ui, repo)
698 return res 707 return res
699 708
700 # XXX this could wrap transaction code 709 # XXX this could wrap transaction code
701 # XXX (but this is a bit a layer violation) 710 # XXX (but this is a bit a layer violation)
702 @eh.wrapcommand("commit") 711 @eh.wrapcommand("commit")