Mercurial > hg
annotate tests/test-parseindex.t @ 26750:9f9ec4abe700
cmdutil: make in-memory changes visible to external editor (issue4378)
Before this patch, external editor process for the commit log can't
view some in-memory changes (especially, of dirstate), because they
aren't written out until the end of transaction (or wlock).
This causes unexpected output of Mercurial commands spawned from that
editor process.
To make in-memory changes visible to external editor process, this
patch does:
- write (or schedule to write) in-memory dirstate changes, and
- set HG_PENDING environment variable, if:
- a transaction is running, and
- there are in-memory changes to be visible
"hg diff" spawned from external editor process for "hg qrefresh"
shows:
- "changes newly imported into the topmost" before 49148d7868df(*)
- "all changes recorded in the topmost by refreshing" after this patch
(*) 49148d7868df changed steps invoking editor process
Even though backward compatibility may be broken, the latter behavior
looks reasonable, because "hg diff" spawned from the editor process
consistently shows "what changes new revision records" regardless of
invocation context.
In fact, issue4378 itself should be resolved by 800e090e9c64, which
made 'repo.transaction()' write in-memory dirstate changes out
explicitly before starting transaction. It also made "hg qrefresh"
imply 'dirstate.write()' before external editor invocation in call
chain below.
- mq.queue.refresh
- strip.strip
- repair.strip
- localrepository.transaction
- dirstate.write
- localrepository.commit
- invoke external editor
Though, this patch has '(issue4378)' in own summary line to indicate
that issues like issue4378 should be fixed by this.
BTW, this patch adds '-m' option to a 'hg ci --amend' execution in
'test-commit-amend.t', to avoid invoking external editor process.
In this case, "unsure" states may be changed to "clean" according to
timestamp or so on. These changes should be written into pending file,
if external editor invocation is required,
Then, writing dirstate changes out breaks stability of test, because
it shows "transaction abort!/rollback completed" occasionally.
Aborting after editor process invocation while commands below may
cause similar instability of tests, too (AFAIK, there is no more such
one, at this revision)
- commit --amend
- without --message/--logfile
- import
- without --message/--logfile,
- without --no-commit,
- without --bypass,
- one of below, and
- patch has no description text, or
- with --edit
- aborting at the 1st patch, which adds or removes file(s)
- if it only changes existing files, status is checked only for
changed files by 'scmutil.matchfiles()', and transition from
"unsure" to "normal" in dirstate doesn't occur (= dirstate
isn't changed, and written out)
- aborting at the 2nd or later patch implies other pending
changes (e.g. changelog), and always causes showing
"transaction abort!/rollback completed"
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | df41c7be16d6 |
children | 21fa3d3688f3 |
rev | line source |
---|---|
12476
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
1 revlog.parseindex must be able to parse the index file even if |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
2 an index entry is split between two 64k blocks. The ideal test |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
3 would be to create an index file with inline data where |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
4 64k < size < 64k + 64 (64k is the size of the read buffer, 64 is |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
5 the size of an index entry) and with an index entry starting right |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
6 before the 64k block boundary, and try to read it. |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
7 We approximate that by reducing the read buffer to 1 byte. |
2290
6563438219e3
add test for revlog.parseindex
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
8 |
12476
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
9 $ hg init a |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
10 $ cd a |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
11 $ echo abc > foo |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
12 $ hg add foo |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
13 $ hg commit -m 'add foo' |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
14 $ echo >> foo |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
15 $ hg commit -m 'change foo' |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
16 $ hg log -r 0: |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
17 changeset: 0:7c31755bf9b5 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
18 user: test |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
19 date: Thu Jan 01 00:00:00 1970 +0000 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
20 summary: add foo |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
21 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
22 changeset: 1:26333235a41c |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
23 tag: tip |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
24 user: test |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
25 date: Thu Jan 01 00:00:00 1970 +0000 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
26 summary: change foo |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
27 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
28 $ cat >> test.py << EOF |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
12476
diff
changeset
|
29 > from mercurial import changelog, scmutil |
12476
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
30 > from mercurial.node import * |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
31 > |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
32 > class singlebyteread(object): |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
33 > def __init__(self, real): |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
34 > self.real = real |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
35 > |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
36 > def read(self, size=-1): |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
37 > if size == 65536: |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
38 > size = 1 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
39 > return self.real.read(size) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
40 > |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
41 > def __getattr__(self, key): |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
42 > return getattr(self.real, key) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
43 > |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
44 > def opener(*args): |
13970
d13913355390
move opener from util to scmutil
Adrian Buehlmann <adrian@cadifra.com>
parents:
12476
diff
changeset
|
45 > o = scmutil.opener(*args) |
12476
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
46 > def wrapper(*a): |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
47 > f = o(*a) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
48 > return singlebyteread(f) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
49 > return wrapper |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
50 > |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
51 > cl = changelog.changelog(opener('.hg/store')) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
52 > print len(cl), 'revisions:' |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
53 > for r in cl: |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
54 > print short(cl.node(r)) |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
55 > EOF |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
56 $ python test.py |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
57 2 revisions: |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
58 7c31755bf9b5 |
4cce5194c307
tests: unify test-parseindex
Matt Mackall <mpm@selenic.com>
parents:
12156
diff
changeset
|
59 26333235a41c |
16913
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13970
diff
changeset
|
60 |
f2719b387380
tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents:
13970
diff
changeset
|
61 $ cd .. |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
62 |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
63 #if no-pure |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
64 |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
65 Test SEGV caused by bad revision passed to reachableroots() (issue4775): |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
66 |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
67 $ cd a |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
68 |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
69 $ python <<EOF |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
70 > from mercurial import changelog, scmutil |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
71 > cl = changelog.changelog(scmutil.vfs('.hg/store')) |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
72 > print 'good heads:' |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
73 > for head in [0, len(cl) - 1, -1]: |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
74 > print'%s: %r' % (head, cl.reachableroots(0, [head], [0])) |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
75 > print 'bad heads:' |
26018
c6115c30a376
reachableroots: verify type of each item of heads argument
Yuya Nishihara <yuya@tcha.org>
parents:
26017
diff
changeset
|
76 > for head in [len(cl), 10000, -2, -10000, None]: |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
77 > print '%s:' % head, |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
78 > try: |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
79 > cl.reachableroots(0, [head], [0]) |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
80 > print 'uncaught buffer overflow?' |
26018
c6115c30a376
reachableroots: verify type of each item of heads argument
Yuya Nishihara <yuya@tcha.org>
parents:
26017
diff
changeset
|
81 > except (IndexError, TypeError) as inst: |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
82 > print inst |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
83 > print 'good roots:' |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
84 > for root in [0, len(cl) - 1, -1]: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
85 > print '%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])) |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
86 > print 'out-of-range roots are ignored:' |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
87 > for root in [len(cl), 10000, -2, -10000]: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
88 > print '%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])) |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
89 > print 'bad roots:' |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
90 > for root in [None]: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
91 > print '%s:' % root, |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
92 > try: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
93 > cl.reachableroots(root, [len(cl) - 1], [root]) |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
94 > print 'uncaught error?' |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
95 > except TypeError as inst: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
96 > print inst |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
97 > EOF |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
98 good heads: |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
99 0: [0] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
100 1: [0] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
101 -1: [] |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
102 bad heads: |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
103 2: head out of range |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
104 10000: head out of range |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
105 -2: head out of range |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
106 -10000: head out of range |
26018
c6115c30a376
reachableroots: verify type of each item of heads argument
Yuya Nishihara <yuya@tcha.org>
parents:
26017
diff
changeset
|
107 None: an integer is required |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
108 good roots: |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
109 0: [0] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
110 1: [1] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
111 -1: [-1] |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
112 out-of-range roots are ignored: |
26094
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
113 2: [] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
114 10000: [] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
115 -2: [] |
df41c7be16d6
reachableroots: construct and sort baseset in revset module
Yuya Nishihara <yuya@tcha.org>
parents:
26061
diff
changeset
|
116 -10000: [] |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
117 bad roots: |
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
118 None: an integer is required |
26017
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
119 |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
120 $ cd .. |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
121 |
44705659da94
reachableroots: verify integer range of heads argument (issue4775)
Yuya Nishihara <yuya@tcha.org>
parents:
26016
diff
changeset
|
122 Test corrupted p1/p2 fields that could cause SEGV at parsers.c: |
25859
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25810
diff
changeset
|
123 |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
124 $ mkdir invalidparent |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
125 $ cd invalidparent |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
126 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
127 $ hg clone --pull -q --config phases.publish=False ../a limit |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
128 $ hg clone --pull -q --config phases.publish=False ../a segv |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
129 $ rm -R limit/.hg/cache segv/.hg/cache |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
130 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
131 $ python <<EOF |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
132 > data = open("limit/.hg/store/00changelog.i", "rb").read() |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
133 > for n, p in [('limit', '\0\0\0\x02'), ('segv', '\0\x01\0\0')]: |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
134 > # corrupt p1 at rev0 and p2 at rev1 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
135 > d = data[:24] + p + data[28:127 + 28] + p + data[127 + 32:] |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
136 > open(n + "/.hg/store/00changelog.i", "wb").write(d) |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
137 > EOF |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
138 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
139 $ hg debugindex -f1 limit/.hg/store/00changelog.i |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
140 rev flag offset length size base link p1 p2 nodeid |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
141 0 0000 0 63 62 0 0 2 -1 7c31755bf9b5 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
142 1 0000 63 66 65 1 1 0 2 26333235a41c |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
143 $ hg debugindex -f1 segv/.hg/store/00changelog.i |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
144 rev flag offset length size base link p1 p2 nodeid |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
145 0 0000 0 63 62 0 0 65536 -1 7c31755bf9b5 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
146 1 0000 63 66 65 1 1 0 65536 26333235a41c |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
147 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
148 $ cat <<EOF > test.py |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
149 > import sys |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
150 > from mercurial import changelog, scmutil |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
151 > cl = changelog.changelog(scmutil.vfs(sys.argv[1])) |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
152 > n0, n1 = cl.node(0), cl.node(1) |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
153 > ops = [ |
26016
c8d41c9c23c7
reachableroots: unify bail cases to raise exception correctly
Yuya Nishihara <yuya@tcha.org>
parents:
25859
diff
changeset
|
154 > ('reachableroots', |
26053
b68c9d232db6
reachableroots: use internal "revstates" array to test if rev is a root
Yuya Nishihara <yuya@tcha.org>
parents:
26018
diff
changeset
|
155 > lambda: cl.index.reachableroots2(0, [1], [0], False)), |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
156 > ('compute_phases_map_sets', lambda: cl.computephases([[0], []])), |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
157 > ('index_headrevs', lambda: cl.headrevs()), |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
158 > ('find_gca_candidates', lambda: cl.commonancestorsheads(n0, n1)), |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
159 > ('find_deepest', lambda: cl.ancestor(n0, n1)), |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
160 > ] |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
161 > for l, f in ops: |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
162 > print l + ':', |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
163 > try: |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
164 > f() |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
165 > print 'uncaught buffer overflow?' |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
166 > except ValueError, inst: |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
167 > print inst |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
168 > EOF |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
169 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
170 $ python test.py limit/.hg/store |
26016
c8d41c9c23c7
reachableroots: unify bail cases to raise exception correctly
Yuya Nishihara <yuya@tcha.org>
parents:
25859
diff
changeset
|
171 reachableroots: parent out of range |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
172 compute_phases_map_sets: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
173 index_headrevs: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
174 find_gca_candidates: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
175 find_deepest: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
176 $ python test.py segv/.hg/store |
26016
c8d41c9c23c7
reachableroots: unify bail cases to raise exception correctly
Yuya Nishihara <yuya@tcha.org>
parents:
25859
diff
changeset
|
177 reachableroots: parent out of range |
25810
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
178 compute_phases_map_sets: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
179 index_headrevs: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
180 find_gca_candidates: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
181 find_deepest: parent out of range |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
182 |
82d6a35cf432
parsers: fix buffer overflow by invalid parent revision read from revlog
Yuya Nishihara <yuya@tcha.org>
parents:
16913
diff
changeset
|
183 $ cd .. |
25859
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25810
diff
changeset
|
184 |
1619563959b3
tests: disable test of buffer overflow in parsers.c if --pure
Yuya Nishihara <yuya@tcha.org>
parents:
25810
diff
changeset
|
185 #endif |