[PATCH 2 of 6 V3] branchmap: move the cache file name into a dedicated function
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Tue Jan 1 16:14:40 CST 2013
# 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.
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():
More information about the Mercurial-devel
mailing list