Mercurial > hg
annotate tests/autodiff.py @ 27015:341cb90ffd18
util: disable floating point stat times (issue4836)
Alternate fix for this issue which avoids putting extra function calls
and exception handling in the fast path.
For almost all purposes, integer timestamps are preferable to
Mercurial. It stores integer timestamps in the dirstate and would thus
like to avoid doing any float/int comparisons or conversions. We will
continue to have to deal with 1-second granularity on filesystems for
quite some time, so this won't significantly hinder our capabilities.
This has some impact on our file cache validation code in that it
lowers timestamp resolution. But as we still have to deal with
low-resolution filesystems, we're not relying on this anyway.
An alternate approach is to use stat[ST_MTIME], which is guaranteed to
be an integer. But since this support isn't already in our extension,
we can't depend on it being available without adding a hard Python->C
API dependency that's painful for people like yours truly who have
bisect regularly and people without compilers.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 19 Nov 2015 13:21:24 -0600 |
parents | 56b2bcea2529 |
children | 3b517f2a3989 |
rev | line source |
---|---|
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
1 # Extension dedicated to test patch.diff() upgrade modes |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
2 # |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
3 # |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23692
diff
changeset
|
4 from mercurial import cmdutil, scmutil, patch, error |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
5 |
21254
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
6 cmdtable = {} |
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
7 command = cmdutil.command(cmdtable) |
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
8 |
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
9 @command('autodiff', |
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
10 [('', 'git', '', 'git upgrade mode (yes/no/auto/warn/abort)')], |
51e5c793a9f4
tests: declare commands using decorator
Gregory Szorc <gregory.szorc@gmail.com>
parents:
17956
diff
changeset
|
11 '[OPTION]... [FILE]...') |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
12 def autodiff(ui, repo, *pats, **opts): |
23692
f78192115229
tests/autodiff.py: explicitly only honor feature diffopts
Siddharth Agarwal <sid0@fb.com>
parents:
21254
diff
changeset
|
13 diffopts = patch.difffeatureopts(ui, opts) |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
14 git = opts.get('git', 'no') |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
15 brokenfiles = set() |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
16 losedatafn = None |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
17 if git in ('yes', 'no'): |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
18 diffopts.git = git == 'yes' |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
19 diffopts.upgrade = False |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
20 elif git == 'auto': |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
21 diffopts.git = False |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
22 diffopts.upgrade = True |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
23 elif git == 'warn': |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
24 diffopts.git = False |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
25 diffopts.upgrade = True |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
26 def losedatafn(fn=None, **kwargs): |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
27 brokenfiles.add(fn) |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
28 return True |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
29 elif git == 'abort': |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
30 diffopts.git = False |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
31 diffopts.upgrade = True |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
32 def losedatafn(fn=None, **kwargs): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23692
diff
changeset
|
33 raise error.Abort('losing data for %s' % fn) |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
34 else: |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23692
diff
changeset
|
35 raise error.Abort('--git must be yes, no or auto') |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
36 |
14319
b33f3e35efb0
scmutil: move revsingle/pair/range from cmdutil
Matt Mackall <mpm@selenic.com>
parents:
10189
diff
changeset
|
37 node1, node2 = scmutil.revpair(repo, []) |
14671
35c2cc322ba8
scmutil: switch match users to supplying contexts
Matt Mackall <mpm@selenic.com>
parents:
14322
diff
changeset
|
38 m = scmutil.match(repo[node2], pats, opts) |
10189
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
39 it = patch.diff(repo, node1, node2, match=m, opts=diffopts, |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
40 losedatafn=losedatafn) |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
41 for chunk in it: |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
42 ui.write(chunk) |
e451e599fbcf
patch: support diff data loss detection and upgrade
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
43 for fn in sorted(brokenfiles): |
17956
a08775ec89f2
i18n: wrap false positives for translation detection
Matt Mackall <mpm@selenic.com>
parents:
14671
diff
changeset
|
44 ui.write(('data lost for: %s\n' % fn)) |