Show More
@@ -163,7 +163,14 b' def cleanupoldbackups(repo):' | |||||
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: | |
@@ -558,6 +565,12 b' def unshelve(ui, repo, *shelved, **opts)' | |||||
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'] |
@@ -185,6 +185,16 b' local edits should not prevent a shelved' | |||||
185 |
|
185 | |||
186 | apply it and make sure our state is as expected |
|
186 | apply it and make sure our state is as expected | |
187 |
|
187 | |||
|
188 | (this also tests that same timestamp prevents backups from being | |||
|
189 | removed, even though there are more than 'maxbackups' backups) | |||
|
190 | ||||
|
191 | $ f -t .hg/shelve-backup/default.hg | |||
|
192 | .hg/shelve-backup/default.hg: file | |||
|
193 | $ touch -t 200001010000 .hg/shelve-backup/default.hg | |||
|
194 | $ f -t .hg/shelve-backup/default-1.hg | |||
|
195 | .hg/shelve-backup/default-1.hg: file | |||
|
196 | $ touch -t 200001010000 .hg/shelve-backup/default-1.hg | |||
|
197 | ||||
188 | $ hg unshelve |
|
198 | $ hg unshelve | |
189 | unshelving change 'default-01' |
|
199 | unshelving change 'default-01' | |
190 | $ hg status -C |
|
200 | $ hg status -C | |
@@ -196,6 +206,17 b' apply it and make sure our state is as e' | |||||
196 | R b/b |
|
206 | R b/b | |
197 | $ hg shelve -l |
|
207 | $ hg shelve -l | |
198 |
|
208 | |||
|
209 | (both of default.hg and default-1.hg should be still kept, because it | |||
|
210 | is difficult to decide actual order of them from same timestamp) | |||
|
211 | ||||
|
212 | $ ls .hg/shelve-backup/ | |||
|
213 | default-01.hg | |||
|
214 | default-01.patch | |||
|
215 | default-1.hg | |||
|
216 | default-1.patch | |||
|
217 | default.hg | |||
|
218 | default.patch | |||
|
219 | ||||
199 | $ hg unshelve |
|
220 | $ hg unshelve | |
200 | abort: no shelved changes to apply! |
|
221 | abort: no shelved changes to apply! | |
201 | [255] |
|
222 | [255] |
General Comments 0
You need to be logged in to leave comments.
Login now