Patchwork [12,of,16] branchmap: add a copy method

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 2, 2013, 1:09 a.m.
Message ID <b137101ab3599fd9e0fc.1357088974@yamac.lan>
Download mbox | patch
Permalink /patch/359/
State Superseded, archived
Commit dd0b636b0b658546f9318d857a0f91e8f6587033
Headers show

Comments

Pierre-Yves David - Jan. 2, 2013, 1:09 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1357087242 -3600
# Node ID b137101ab3599fd9e0fc7cff7e73bbb14db592b0
# Parent  bb98e3c68f91154193fed5fcb54e4c1960714f12
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)
             cachekey = [hex(self.tipnode), str(self.tiprev)]