323 |
323 |
324 |
324 |
325 def cleanupoldbackups(repo): |
325 def cleanupoldbackups(repo): |
326 vfs = vfsmod.vfs(repo.vfs.join(backupdir)) |
326 vfs = vfsmod.vfs(repo.vfs.join(backupdir)) |
327 maxbackups = repo.ui.configint(b'shelve', b'maxbackups') |
327 maxbackups = repo.ui.configint(b'shelve', b'maxbackups') |
328 hgfiles = [f for f in vfs.listdir() if f.endswith(b'.' + patchextension)] |
328 hgfiles = listshelves(vfs) |
329 hgfiles = sorted([(vfs.stat(f)[stat.ST_MTIME], f) for f in hgfiles]) |
|
330 if maxbackups > 0 and maxbackups < len(hgfiles): |
329 if maxbackups > 0 and maxbackups < len(hgfiles): |
331 bordermtime = hgfiles[-maxbackups][0] |
330 bordermtime = hgfiles[maxbackups - 1][0] |
332 else: |
331 else: |
333 bordermtime = None |
332 bordermtime = None |
334 for mtime, f in hgfiles[: len(hgfiles) - maxbackups]: |
333 for mtime, name in hgfiles[maxbackups:]: |
335 if mtime == bordermtime: |
334 if mtime == bordermtime: |
336 # keep it, because timestamp can't decide exact order of backups |
335 # keep it, because timestamp can't decide exact order of backups |
337 continue |
336 continue |
338 base = f[: -(1 + len(patchextension))] |
|
339 for ext in shelvefileextensions: |
337 for ext in shelvefileextensions: |
340 vfs.tryunlink(base + b'.' + ext) |
338 vfs.tryunlink(name + b'.' + ext) |
341 |
339 |
342 |
340 |
343 def _backupactivebookmark(repo): |
341 def _backupactivebookmark(repo): |
344 activebookmark = repo._activebookmark |
342 activebookmark = repo._activebookmark |
345 if activebookmark: |
343 if activebookmark: |