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

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 4, 2013, 1:04 a.m.
Message ID <ecb6c49286b1c1238f5d.1357261457@yamac.lan>
Download mbox | patch
Permalink /patch/383/
State Accepted
Commit dd0b636b0b658546f9318d857a0f91e8f6587033
Headers show

Comments

Pierre-Yves David - Jan. 4, 2013, 1:04 a.m.
# 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.

Patch

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):