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