[PATCH 5 of 9] branchmap: move the cache file name into a dedicated function
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Dec 26 14:33:01 CST 2012
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1356314652 -3600
# Node ID ba744239ad1bfdce8e87de573e5dc191d0a7db06
# Parent ed03a82360c2b90195a2d4dacca205e5a705a1f2
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.
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()
@@ -113,11 +117,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.filtered is not None:
cachekey.append(hex(self.filtered))
f.write(" ".join(cachekey) + '\n')
for label, nodes in self.iteritems():
More information about the Mercurial-devel
mailing list