comparison hgext/histedit.py @ 20071:4778f398ec83 stable

histedit: hold wlock and lock while in progress Currently, histedit acquires and releases lock and wlock several times during its run. This isn't great because it allows other hg processes to come in and change state. With this fix, lock and wlock are acquired and released exactly once. The change to test-histedit-drop.t is a minor implementation one -- the cache is still correctly invalidated, but it just happens a little later and only gets printed out because of the unrelated --debug flag.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 17 Nov 2013 15:11:09 -0800
parents 1e13a5a9c66e
children 23dc77874191 5d22cadd1938
comparison
equal deleted inserted replaced
20070:509717d0d517 20071:4778f398ec83
157 from mercurial import repair 157 from mercurial import repair
158 from mercurial import scmutil 158 from mercurial import scmutil
159 from mercurial import util 159 from mercurial import util
160 from mercurial import obsolete 160 from mercurial import obsolete
161 from mercurial import merge as mergemod 161 from mercurial import merge as mergemod
162 from mercurial.lock import release
162 from mercurial.i18n import _ 163 from mercurial.i18n import _
163 164
164 cmdtable = {} 165 cmdtable = {}
165 command = cmdutil.command(cmdtable) 166 command = cmdutil.command(cmdtable)
166 167
474 475
475 Returns 0 on success, 1 if user intervention is required (not only 476 Returns 0 on success, 1 if user intervention is required (not only
476 for intentional "edit" command, but also for resolving unexpected 477 for intentional "edit" command, but also for resolving unexpected
477 conflicts). 478 conflicts).
478 """ 479 """
480 lock = wlock = None
481 try:
482 wlock = repo.wlock()
483 lock = repo.lock()
484 _histedit(ui, repo, *freeargs, **opts)
485 finally:
486 release(lock, wlock)
487
488 def _histedit(ui, repo, *freeargs, **opts):
479 # TODO only abort if we try and histedit mq patches, not just 489 # TODO only abort if we try and histedit mq patches, not just
480 # blanket if mq patches are applied somewhere 490 # blanket if mq patches are applied somewhere
481 mq = getattr(repo, 'mq', None) 491 mq = getattr(repo, 'mq', None)
482 if mq and mq.applied: 492 if mq and mq.applied:
483 raise util.Abort(_('source has mq patches applied')) 493 raise util.Abort(_('source has mq patches applied'))