##// END OF EJS Templates
fncachestore: defer updating the fncache file to a single file open...
Adrian Buehlmann -
r13391:d00bbff8 default
parent child Browse files
Show More
@@ -781,8 +781,8 b' class localrepository(repo.repository):'
781 781 l.lock()
782 782 return l
783 783
784 l = self._lock(self.sjoin("lock"), wait, None, self.invalidate,
785 _('repository %s') % self.origroot)
784 l = self._lock(self.sjoin("lock"), wait, self.store.write,
785 self.invalidate, _('repository %s') % self.origroot)
786 786 self._lockref = weakref.ref(l)
787 787 return l
788 788
@@ -213,6 +213,9 b' class basicstore(object):'
213 213 def copylist(self):
214 214 return ['requires'] + _data.split()
215 215
216 def write(self):
217 pass
218
216 219 class encodedstore(basicstore):
217 220 def __init__(self, path, opener, pathjoiner):
218 221 self.pathjoiner = pathjoiner
@@ -243,10 +246,12 b' class fncache(object):'
243 246 def __init__(self, opener):
244 247 self.opener = opener
245 248 self.entries = None
249 self._dirty = False
246 250
247 251 def _load(self):
248 252 '''fill the entries from the fncache file'''
249 253 self.entries = set()
254 self._dirty = False
250 255 try:
251 256 fp = self.opener('fncache', mode='rb')
252 257 except IOError:
@@ -265,12 +270,22 b' class fncache(object):'
265 270 fp.write(encodedir(p) + '\n')
266 271 fp.close()
267 272 self.entries = set(files)
273 self._dirty = False
274
275 def write(self):
276 if not self._dirty:
277 return
278 fp = self.opener('fncache', mode='wb', atomictemp=True)
279 for p in self.entries:
280 fp.write(encodedir(p) + '\n')
281 fp.rename()
282 self._dirty = False
268 283
269 284 def add(self, fn):
270 285 if self.entries is None:
271 286 self._load()
272 287 if fn not in self.entries:
273 self.opener('fncache', 'ab').write(encodedir(fn) + '\n')
288 self._dirty = True
274 289 self.entries.add(fn)
275 290
276 291 def __contains__(self, fn):
@@ -328,6 +343,9 b' class fncachestore(basicstore):'
328 343 return (['requires', '00changelog.i'] +
329 344 [self.pathjoiner('store', f) for f in d.split()])
330 345
346 def write(self):
347 self.fncache.write()
348
331 349 def store(requirements, path, opener, pathjoiner=None):
332 350 pathjoiner = pathjoiner or os.path.join
333 351 if 'store' in requirements:
General Comments 0
You need to be logged in to leave comments. Login now