equal
deleted
inserted
replaced
161 def cleanupoldbackups(repo): |
161 def cleanupoldbackups(repo): |
162 vfs = scmutil.vfs(repo.join(backupdir)) |
162 vfs = scmutil.vfs(repo.join(backupdir)) |
163 maxbackups = repo.ui.configint('shelve', 'maxbackups', 10) |
163 maxbackups = repo.ui.configint('shelve', 'maxbackups', 10) |
164 hgfiles = [f for f in vfs.listdir() if f.endswith('.hg')] |
164 hgfiles = [f for f in vfs.listdir() if f.endswith('.hg')] |
165 hgfiles = sorted([(vfs.stat(f).st_mtime, f) for f in hgfiles]) |
165 hgfiles = sorted([(vfs.stat(f).st_mtime, f) for f in hgfiles]) |
|
166 if 0 < maxbackups and maxbackups < len(hgfiles): |
|
167 bordermtime = hgfiles[-maxbackups][0] |
|
168 else: |
|
169 bordermtime = None |
166 for mtime, f in hgfiles[:len(hgfiles) - maxbackups]: |
170 for mtime, f in hgfiles[:len(hgfiles) - maxbackups]: |
|
171 if mtime == bordermtime: |
|
172 # keep it, because timestamp can't decide exact order of backups |
|
173 continue |
167 base = f[:-3] |
174 base = f[:-3] |
168 for ext in 'hg patch'.split(): |
175 for ext in 'hg patch'.split(): |
169 try: |
176 try: |
170 vfs.unlink(base + '.' + ext) |
177 vfs.unlink(base + '.' + ext) |
171 except OSError as err: |
178 except OSError as err: |
556 |
563 |
557 After a successful unshelve, the shelved changes are stored in a |
564 After a successful unshelve, the shelved changes are stored in a |
558 backup directory. Only the N most recent backups are kept. N |
565 backup directory. Only the N most recent backups are kept. N |
559 defaults to 10 but can be overridden using the shelve.maxbackups |
566 defaults to 10 but can be overridden using the shelve.maxbackups |
560 configuration option. |
567 configuration option. |
|
568 |
|
569 .. container:: verbose |
|
570 |
|
571 Timestamp in seconds is used to decide order of backups. More |
|
572 than ``maxbackups`` backups are kept, if same timestamp |
|
573 prevents from deciding exact order of them, for safety. |
561 """ |
574 """ |
562 abortf = opts['abort'] |
575 abortf = opts['abort'] |
563 continuef = opts['continue'] |
576 continuef = opts['continue'] |
564 if not abortf and not continuef: |
577 if not abortf and not continuef: |
565 cmdutil.checkunfinished(repo) |
578 cmdutil.checkunfinished(repo) |