diff mercurial/bookmarks.py @ 15887:12dea4d998ec

bookmarks: primarily use repo lock, not wlock Bookmarks are repository data, not working directory data. Only the current bookmark is working directory data. Some lock shuffling is required to avoid lockout between the initial mock lock and locking of the localrepo instance that is created after copying.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 13 Jan 2012 02:30:43 +0100
parents 013688350c7d
children 60cb4f381a78
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Fri Jan 13 02:29:38 2012 +0100
+++ b/mercurial/bookmarks.py	Fri Jan 13 02:30:43 2012 +0100
@@ -84,7 +84,7 @@
             raise util.Abort(_("bookmark '%s' contains illegal "
                 "character" % mark))
 
-    wlock = repo.wlock()
+    lock = repo.lock()
     try:
 
         file = repo.opener('bookmarks', 'w', atomictemp=True)
@@ -99,7 +99,7 @@
             pass
 
     finally:
-        wlock.release()
+        lock.release()
 
 def setcurrent(repo, mark):
     '''Set the name of the bookmark that we are currently on
@@ -117,13 +117,13 @@
         raise util.Abort(_("bookmark '%s' contains illegal "
             "character" % mark))
 
-    wlock = repo.wlock()
+    lock = repo.lock()
     try:
         file = repo.opener('bookmarks.current', 'w', atomictemp=True)
         file.write(encoding.fromlocal(mark))
         file.close()
     finally:
-        wlock.release()
+        lock.release()
     repo._bookmarkcurrent = mark
 
 def updatecurrentbookmark(repo, oldnode, curbranch):
@@ -162,7 +162,7 @@
     return d
 
 def pushbookmark(repo, key, old, new):
-    w = repo.wlock()
+    lock = repo.lock()
     try:
         marks = repo._bookmarks
         if hex(marks.get(key, '')) != old:
@@ -176,7 +176,7 @@
         write(repo)
         return True
     finally:
-        w.release()
+        lock.release()
 
 def updatefromremote(ui, repo, remote, path):
     ui.debug("checking for updated bookmarks\n")