Patchwork [06,of,10,V2] branchmap: move the cache file name into a dedicated function

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 28, 2012, 12:56 a.m.
Message ID <2734b4065b5c6ac69c46.1356656181@yamac.lan>
Download mbox | patch
Permalink /patch/310/
State Superseded, archived
Commit 5a047276764ee02917c896bf80343d2861c41f06
Headers show

Comments

Pierre-Yves David - Dec. 28, 2012, 12:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356314652 -3600
# Node ID 2734b4065b5c6ac69c46ef0d2aa02678ae8e65ff
# Parent  3dc28fcfff3d2955c95c7793bb05c8b18e21359d
branchmap: move the cache file name into a dedicated function

Filtered view of the repo will want to write they file name in a different file.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -7,13 +7,17 @@ 
 
 from node import bin, hex, nullid, nullrev
 import encoding
 import util
 
+def _filename(repo):
+    """name of a branchcache file for a given repo"""
+    return "cache/branchheads"
+
 def read(repo):
     try:
-        f = repo.opener("cache/branchheads")
+        f = repo.opener(_filename(repo))
         lines = f.read().split('\n')
         f.close()
     except (IOError, OSError):
         return branchcache()
 
@@ -114,11 +118,11 @@  class branchcache(dict):
             return False
 
 
     def write(self, repo):
         try:
-            f = repo.opener("cache/branchheads", "w", atomictemp=True)
+            f = repo.opener(_filename(repo), "w", atomictemp=True)
             cachekey = [hex(self.tipnode), str(self.tiprev)]
             if self.filteredhash is not None:
                 cachekey.append(hex(self.filteredhash))
             f.write(" ".join(cachekey) + '\n')
             for label, nodes in self.iteritems():