[PATCH 2 of 3] bookmarks: implement a proper copy() method

David Soria Parra dsp at experimentalworks.net
Thu Oct 3 09:47:43 CDT 2013


# HG changeset patch
# User David Soria Parra <dsp at experimentalworks.net>
# Date 1380806149 -7200
#      Thu Oct 03 15:15:49 2013 +0200
# Node ID a9c81ba427312f5b0eb0c6f18ead265a89d87623
# Parent  f6ae312f5a1545e2d594ab407fe19e1a16efedc4
bookmarks: implement a proper copy() method

dict supports copy() but if we copy bmstore we only get a dict and not a
bmstore. Therefore we implement copy() to return a proper bmstore object.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -25,10 +25,11 @@
     time.
     """
 
-    def __init__(self, repo):
+    def __init__(self, repo, read=True):
         dict.__init__(self)
         self._repo = repo
-        self.read()
+        if read:
+            self.read()
 
     def read(self):
         try:
@@ -50,6 +51,11 @@
             if inst.errno != errno.ENOENT:
                 raise
 
+    def copy(self):
+        bms = bmstore(self._repo, read=False)
+        bms.update(self)
+        return bms
+
     def write(self):
         '''Write bookmarks
 


More information about the Mercurial-devel mailing list