[PATCH 14 of 18 V2] branchmap: add a copy method

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jan 3 19:04:17 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1357087242 -3600
# Node ID ecb6c49286b1c1238f5d9ce6d2d9ebe8b67ca650
# Parent  3a28bc72c1e1341fbf805fa72f2442f53eb75387
branchmap: add a copy method

If we want branchcache of different filter to collaborate, they need a simple
way to copy each other. This will ensure that each filtered have no side effect
on other filter level cache.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -115,10 +115,13 @@ class branchcache(dict):
             return ((self.tipnode == repo.changelog.node(self.tiprev))
                     and (self.filteredhash == self._hashfiltered(repo)))
         except IndexError:
             return False
 
+    def copy(self):
+        """return an deep copy of the branchcache object"""
+        return branchcache(self, self.tipnode, self.tiprev, self.filteredhash)
 
     def write(self, repo):
         try:
             f = repo.opener(_filename(repo), "w", atomictemp=True)
         except (IOError, OSError, util.Abort):


More information about the Mercurial-devel mailing list