bookmarks: create undo.bookmarks using repo.opener instead of util.copyfile stable
authorBrodie Rao <brodie@bitheap.org>
Tue, 07 Dec 2010 20:03:04 +1100
branchstable
changeset 13103 6e79a3bb8c79
parent 13102 2956945c3bee
child 13104 5dac0d04b838
child 13105 2245fcd0e160
child 13165 b98d7ffa5c5b
bookmarks: create undo.bookmarks using repo.opener instead of util.copyfile This more closely matches how the other undo files are created, and we don't care about settings permissions or times on the file, which can fail if the user running hg doesn't own the file.
hgext/bookmarks.py
--- a/hgext/bookmarks.py	Tue Dec 07 19:47:53 2010 +1100
+++ b/hgext/bookmarks.py	Tue Dec 07 20:03:04 2010 +1100
@@ -44,8 +44,14 @@
     can be copied back on rollback.
     '''
     refs = repo._bookmarks
-    if os.path.exists(repo.join('bookmarks')):
-        util.copyfile(repo.join('bookmarks'), repo.join('undo.bookmarks'))
+
+    try:
+        bms = repo.opener('bookmarks').read()
+    except IOError:
+        bms = None
+    if bms is not None:
+        repo.opener('undo.bookmarks', 'w').write(bms)
+
     if repo._bookmarkcurrent not in refs:
         setcurrent(repo, None)
     wlock = repo.wlock()