##// END OF EJS Templates
remotefilelog: use progress helper in basestore...
Martin von Zweigbergk -
r40876:ad21fbcb default
parent child Browse files
Show More
@@ -77,14 +77,15 b' class basestore(object):'
77 ui = self.ui
77 ui = self.ui
78 entries = ledger.sources.get(self, [])
78 entries = ledger.sources.get(self, [])
79 count = 0
79 count = 0
80 progress = ui.makeprogress(_("cleaning up"), unit="files",
81 total=len(entries))
80 for entry in entries:
82 for entry in entries:
81 if entry.gced or (entry.datarepacked and entry.historyrepacked):
83 if entry.gced or (entry.datarepacked and entry.historyrepacked):
82 ui.progress(_("cleaning up"), count, unit="files",
84 progress.update(count)
83 total=len(entries))
84 path = self._getfilepath(entry.filename, entry.node)
85 path = self._getfilepath(entry.filename, entry.node)
85 util.tryunlink(path)
86 util.tryunlink(path)
86 count += 1
87 count += 1
87 ui.progress(_("cleaning up"), None)
88 progress.complete()
88
89
89 # Clean up the repo cache directory.
90 # Clean up the repo cache directory.
90 self._cleanupdirectory(self._getrepocachepath())
91 self._cleanupdirectory(self._getrepocachepath())
@@ -302,8 +303,6 b' class basestore(object):'
302 def gc(self, keepkeys):
303 def gc(self, keepkeys):
303 ui = self.ui
304 ui = self.ui
304 cachepath = self._path
305 cachepath = self._path
305 _removing = _("removing unnecessary files")
306 _truncating = _("enforcing cache limit")
307
306
308 # prune cache
307 # prune cache
309 import Queue
308 import Queue
@@ -316,7 +315,9 b' class basestore(object):'
316 # keep files newer than a day even if they aren't needed
315 # keep files newer than a day even if they aren't needed
317 limit = time.time() - (60 * 60 * 24)
316 limit = time.time() - (60 * 60 * 24)
318
317
319 ui.progress(_removing, count, unit="files")
318 progress = ui.makeprogress(_("removing unnecessary files"),
319 unit="files")
320 progress.update(0)
320 for root, dirs, files in os.walk(cachepath):
321 for root, dirs, files in os.walk(cachepath):
321 for file in files:
322 for file in files:
322 if file == 'repos':
323 if file == 'repos':
@@ -326,7 +327,7 b' class basestore(object):'
326 if '/packs/' in root:
327 if '/packs/' in root:
327 continue
328 continue
328
329
329 ui.progress(_removing, count, unit="files")
330 progress.update(count)
330 path = os.path.join(root, file)
331 path = os.path.join(root, file)
331 key = os.path.relpath(path, cachepath)
332 key = os.path.relpath(path, cachepath)
332 count += 1
333 count += 1
@@ -357,16 +358,17 b' class basestore(object):'
357 ui.warn(msg % path)
358 ui.warn(msg % path)
358 continue
359 continue
359 removed += 1
360 removed += 1
360 ui.progress(_removing, None)
361 progress.complete()
361
362
362 # remove oldest files until under limit
363 # remove oldest files until under limit
363 limit = ui.configbytes("remotefilelog", "cachelimit")
364 limit = ui.configbytes("remotefilelog", "cachelimit")
364 if size > limit:
365 if size > limit:
365 excess = size - limit
366 excess = size - limit
367 progress = ui.makeprogress(_("enforcing cache limit"), unit="bytes",
368 total=excess)
366 removedexcess = 0
369 removedexcess = 0
367 while queue and size > limit and size > 0:
370 while queue and size > limit and size > 0:
368 ui.progress(_truncating, removedexcess, unit="bytes",
371 progress.update(removedexcess)
369 total=excess)
370 atime, oldpath, oldpathstat = queue.get()
372 atime, oldpath, oldpathstat = queue.get()
371 try:
373 try:
372 shallowutil.unlinkfile(oldpath)
374 shallowutil.unlinkfile(oldpath)
@@ -379,7 +381,7 b' class basestore(object):'
379 size -= oldpathstat.st_size
381 size -= oldpathstat.st_size
380 removed += 1
382 removed += 1
381 removedexcess += oldpathstat.st_size
383 removedexcess += oldpathstat.st_size
382 ui.progress(_truncating, None)
384 progress.complete()
383
385
384 ui.status(_("finished: removed %s of %s files (%0.2f GB to %0.2f GB)\n")
386 ui.status(_("finished: removed %s of %s files (%0.2f GB to %0.2f GB)\n")
385 % (removed, count,
387 % (removed, count,
General Comments 0
You need to be logged in to leave comments. Login now