next/prev: properly lock repo before touching bookmarks stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 14 Sep 2015 13:48:34 -0700
branchstable
changeset 1503 e8f7e4c53537
parent 1501 5c962163f77a
child 1504 415a51ac07a7
child 1511 91b6a30424a3
next/prev: properly lock repo before touching bookmarks
README
hgext/evolve.py
--- a/README	Mon Sep 14 13:23:43 2015 -0700
+++ b/README	Mon Sep 14 13:48:34 2015 -0700
@@ -54,6 +54,7 @@
 5.2.1 --
 
 - prune: fixed possible issue with lock and bookmark
+- next/prev: fixed possible issue with lock and bookmark
 
 5.2.0 -- 2015-06-25
 
--- a/hgext/evolve.py	Mon Sep 14 13:23:43 2015 -0700
+++ b/hgext/evolve.py	Mon Sep 14 13:48:34 2015 -0700
@@ -2004,11 +2004,15 @@
         shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, p.rev())
         if not ret:
-            if shouldmove:
-                repo._bookmarks[bm] = p.node()
-                repo._bookmarks.write()
-            else:
-                bmdeactivate(repo)
+            wlock = repo.wlock()
+            try:
+                if shouldmove:
+                    repo._bookmarks[bm] = p.node()
+                    repo._bookmarks.write()
+                else:
+                    bmdeactivate(repo)
+            finally:
+                wlock.release()
         displayer.show(p)
         return 0
     else:
@@ -2048,11 +2052,15 @@
         shouldmove = opts.get('move_bookmark') and bm is not None
         ret = hg.update(repo, c.rev())
         if not ret:
-            if shouldmove:
-                repo._bookmarks[bm] = c.node()
-                repo._bookmarks.write()
-            else:
-                bmdeactivate(repo)
+            wlock = repo.wlock()
+            try:
+                if shouldmove:
+                    repo._bookmarks[bm] = c.node()
+                    repo._bookmarks.write()
+                else:
+                    bmdeactivate(repo)
+            finally:
+                wlock.release()
         displayer.show(c)
         result = 0
     elif children: