summaryrefslogtreecommitdiff
path: root/mercurial/store.py
diff options
context:
space:
mode:
Diffstat (limited to 'mercurial/store.py')
-rw-r--r--mercurial/store.py51
1 files changed, 24 insertions, 27 deletions
diff --git a/mercurial/store.py b/mercurial/store.py
index b6eb8b3..961c3aa 100644
--- a/mercurial/store.py
+++ b/mercurial/store.py
@@ -232,8 +232,7 @@ def _calcmode(path):
mode = None
return mode
-_data = ('data 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
- ' phaseroots obsstore')
+_data = 'data 00manifest.d 00manifest.i 00changelog.d 00changelog.i'
class basicstore(object):
'''base class for local repository stores'''
@@ -265,8 +264,7 @@ class basicstore(object):
l.append((decodedir(n), n, st.st_size))
elif kind == stat.S_IFDIR and recurse:
visit.append(fp)
- l.sort()
- return l
+ return sorted(l)
def datafiles(self):
return self._walk('data', True)
@@ -319,36 +317,36 @@ class fncache(object):
def _load(self):
'''fill the entries from the fncache file'''
+ self.entries = set()
self._dirty = False
try:
fp = self.opener('fncache', mode='rb')
except IOError:
# skip nonexistent file
- self.entries = set()
return
- self.entries = set(map(decodedir, fp.read().splitlines()))
- if '' in self.entries:
- fp.seek(0)
- for n, line in enumerate(fp):
- if not line.rstrip('\n'):
- t = _('invalid entry in fncache, line %s') % (n + 1)
- raise util.Abort(t)
+ for n, line in enumerate(fp):
+ if (len(line) < 2) or (line[-1] != '\n'):
+ t = _('invalid entry in fncache, line %s') % (n + 1)
+ raise util.Abort(t)
+ self.entries.add(decodedir(line[:-1]))
fp.close()
- def _write(self, files, atomictemp):
- fp = self.opener('fncache', mode='wb', atomictemp=atomictemp)
- if files:
- fp.write('\n'.join(map(encodedir, files)) + '\n')
- fp.close()
- self._dirty = False
-
def rewrite(self, files):
- self._write(files, False)
+ fp = self.opener('fncache', mode='wb')
+ for p in files:
+ fp.write(encodedir(p) + '\n')
+ fp.close()
self.entries = set(files)
+ self._dirty = False
def write(self):
- if self._dirty:
- self._write(self.entries, True)
+ if not self._dirty:
+ return
+ fp = self.opener('fncache', mode='wb', atomictemp=True)
+ for p in self.entries:
+ fp.write(encodedir(p) + '\n')
+ fp.rename()
+ self._dirty = False
def add(self, fn):
if self.entries is None:
@@ -392,16 +390,15 @@ class fncachestore(basicstore):
def join(self, f):
return self.path + '/' + self.encode(f)
- def getsize(self, path):
- return os.stat(self.path + '/' + path).st_size
-
def datafiles(self):
rewrite = False
existing = []
+ spath = self.path
for f in self.fncache:
ef = self.encode(f)
try:
- yield f, ef, self.getsize(ef)
+ st = os.stat(spath + '/' + ef)
+ yield f, ef, st.st_size
existing.append(f)
except OSError:
# nonexistent entry
@@ -412,7 +409,7 @@ class fncachestore(basicstore):
self.fncache.rewrite(existing)
def copylist(self):
- d = ('data dh fncache phaseroots obsstore'
+ d = ('data dh fncache'
' 00manifest.d 00manifest.i 00changelog.d 00changelog.i')
return (['requires', '00changelog.i'] +
['store/' + f for f in d.split()])