Patchwork [2,of,6,V3] branchmap: move the cache file name into a dedicated function

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 1, 2013, 10:14 p.m.
Message ID <db187f83ff0cdc760998.1357078480@yamac.lan>
Download mbox | patch
Permalink /patch/341/
State Accepted
Commit 5a047276764ee02917c896bf80343d2861c41f06
Headers show

Comments

Pierre-Yves David - Jan. 1, 2013, 10:14 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356314652 -3600
# Node ID db187f83ff0cdc760998f8e66ef75a000d9a804e
# Parent  d5a9f27529d3f7c6fdf3e927847b82f29c888573
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()
 
@@ -115,11 +119,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():