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

login
register
mail settings
Submitter David Soria Parra
Date Oct. 3, 2013, 2:47 p.m.
Message ID <a9c81ba427312f5b0eb0.1380811663@achird.localdomain>
Download mbox | patch
Permalink /patch/2723/
State Superseded, archived
Headers show

Comments

David Soria Parra - Oct. 3, 2013, 2:47 p.m.
# HG changeset patch
# User David Soria Parra <dsp@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.

Patch

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