branchmap: move the cache file name into a dedicated function
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Mon, 24 Dec 2012 03:04:12 +0100
changeset 18185 5a047276764e
parent 18184 8d48af68e2ae
child 18186 d336f53cb2e3
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.
mercurial/branchmap.py
--- a/mercurial/branchmap.py	Tue Jan 01 18:19:24 2013 +0100
+++ b/mercurial/branchmap.py	Mon Dec 24 03:04:12 2012 +0100
@@ -9,9 +9,13 @@
 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):
@@ -117,7 +121,7 @@
 
     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))