changeset 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 509717d0d517
children 6d4fda48b4e3 faa4b3fc4197
files hgext/histedit.py tests/test-histedit-drop.t
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
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)
--- a/tests/test-histedit-drop.t	Mon Nov 18 15:43:45 2013 -0500
+++ b/tests/test-histedit-drop.t	Sun Nov 17 15:11:09 2013 -0800
@@ -97,6 +97,7 @@
 Check histedit_source
 
   $ hg log --debug --rev f518305ce889
+  invalid branchheads cache (visible): tip differs
   changeset:   4:f518305ce889c07cb5bd05522176d75590ef3324
   tag:         tip
   phase:       draft