changeset 1501:5c962163f77a stable

prune: ensure we prune bookmarks in a transaction
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 14 Sep 2015 13:23:43 -0700
parents bc7eec65dfcf
children e8f7e4c53537
files README hgext/evolve.py
diffstat 2 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/README	Wed Aug 12 10:51:20 2015 -0700
+++ b/README	Mon Sep 14 13:23:43 2015 -0700
@@ -51,6 +51,10 @@
 Changelog
 =========
 
+5.2.1 --
+
+- prune: fixed possible issue with lock and bookmark
+
 5.2.0 -- 2015-06-25
 
 - evolve: gain a --rev option to control what revisions to evolve (issue4391)
--- a/hgext/evolve.py	Wed Aug 12 10:51:20 2015 -0700
+++ b/hgext/evolve.py	Mon Sep 14 13:23:43 2015 -0700
@@ -2113,10 +2113,18 @@
         revs = sorted(revs)
     return marks, revs
 
-def _deletebookmark(ui, marks, mark):
-    del marks[mark]
-    marks.write()
-    ui.write(_("bookmark '%s' deleted\n") % mark)
+def _deletebookmark(repo, marks, mark):
+    wlock = lock = tr = None
+    try:
+        wlock = repo.wlock()
+        lock = repo.lock()
+        tr = repo.transaction('prune')
+        del marks[mark]
+        marks.recordchange(tr)
+        tr.close()
+        repo.ui.write(_("bookmark '%s' deleted\n") % mark)
+    finally:
+        lockmod.release(tr, lock, wlock)
 
 
 
@@ -2170,7 +2178,7 @@
         marks,revs = _reachablefrombookmark(repo, revs, bookmark)
         if not revs:
             # no revisions to prune - delete bookmark immediately
-            _deletebookmark(ui, marks, bookmark)
+            _deletebookmark(repo, marks, bookmark)
 
     if not revs:
         raise util.Abort(_('nothing to prune'))
@@ -2264,7 +2272,7 @@
 
         # update bookmarks
         if bookmark:
-            _deletebookmark(ui, marks, bookmark)
+            _deletebookmark(repo, marks, bookmark)
 
         # create markers
         obsolete.createmarkers(repo, relations, metadata=metadata)