Mercurial > hg-stable
comparison tests/test-shelve.t @ 25774:4f8c20fe66f0
shelve: keep old backups if timestamp can't decide exact order of them
Before this patch, backups to be discarded are decided by steps below
at 'hg unshelve' or so:
1. list '(st_mtime, filename)' tuples of each backups up
2. sort list of these tuples, and
3. discard backups other than 'maxbackups' ones at the end of list
This doesn't work well in the case below:
- "sort by name" order differs from actual backup-ing order, and
- some of backups have same timestamp
For example, 'test-shelve.t' satisfies the former condition:
- 'default-01' < 'default-1' in "sort by name" order
- 'default-1' < 'default-01' in actual backup-ing order
Then, 'default-01' is discarded instead of 'default-1' unexpectedly,
if they have same timestamp. This failure appears occasionally,
because the most important condition "same timestamp" is timing
critical.
To avoid such unexpected discarding, this patch keeps old backups if
timestamp can't decide exact order of them.
Timestamp of the border backup (= the oldest one of recent
'maxbackups' ones) as 'bordermtime' is used to examine whether
timestamp can decide exact order of backups.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 13 Jul 2015 23:34:12 +0900 |
parents | 2ca116614cfc |
children | 0eb093e40813 |
comparison
equal
deleted
inserted
replaced
25773:de654a83fe1c | 25774:4f8c20fe66f0 |
---|---|
183 $ hg revert --all -q | 183 $ hg revert --all -q |
184 $ rm a/a.orig b.rename/b c.copy | 184 $ rm a/a.orig b.rename/b c.copy |
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 |
191 M a/a | 201 M a/a |
192 A b.rename/b | 202 A b.rename/b |
193 b/b | 203 b/b |
194 A c.copy | 204 A c.copy |
195 c | 205 c |
196 R b/b | 206 R b/b |
197 $ hg shelve -l | 207 $ hg shelve -l |
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 | |
198 | 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] |
202 $ hg unshelve foo | 223 $ hg unshelve foo |