diff 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
line wrap: on
line diff
--- a/hgext/histedit.py	Mon Nov 18 15:43:45 2013 -0500
+++ b/hgext/histedit.py	Sun Nov 17 15:11:09 2013 -0800
@@ -159,6 +159,7 @@
 from mercurial import util
 from mercurial import obsolete
 from mercurial import merge as mergemod
+from mercurial.lock import release
 from mercurial.i18n import _
 
 cmdtable = {}
@@ -476,6 +477,15 @@
     for intentional "edit" command, but also for resolving unexpected
     conflicts).
     """
+    lock = wlock = None
+    try:
+        wlock = repo.wlock()
+        lock = repo.lock()
+        _histedit(ui, repo, *freeargs, **opts)
+    finally:
+        release(lock, wlock)
+
+def _histedit(ui, repo, *freeargs, **opts):
     # TODO only abort if we try and histedit mq patches, not just
     # blanket if mq patches are applied somewhere
     mq = getattr(repo, 'mq', None)