Mercurial > hg-stable
view tests/test-demandimport.py @ 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 | 2205d00b6d2b |
children | 0d0f4070f6d7 |
line wrap: on
line source
from mercurial import demandimport demandimport.enable() import os if os.name != 'nt': try: import distutils.msvc9compiler print ('distutils.msvc9compiler needs to be an immediate ' 'importerror on non-windows platforms') distutils.msvc9compiler except ImportError: pass import re rsub = re.sub def f(obj): l = repr(obj) l = rsub("0x[0-9a-fA-F]+", "0x?", l) l = rsub("from '.*'", "from '?'", l) l = rsub("'<[a-z]*>'", "'<whatever>'", l) return l import os print "os =", f(os) print "os.system =", f(os.system) print "os =", f(os) from mercurial import util print "util =", f(util) print "util.system =", f(util.system) print "util =", f(util) print "util.system =", f(util.system) import re as fred print "fred =", f(fred) import sys as re print "re =", f(re) print "fred =", f(fred) print "fred.sub =", f(fred.sub) print "fred =", f(fred) print "re =", f(re) print "re.stderr =", f(re.stderr) print "re =", f(re) demandimport.disable() os.environ['HGDEMANDIMPORT'] = 'disable' demandimport.enable() from mercurial import node print "node =", f(node)