comparison tests/test-parseindex.t @ 38079:ce307af030a2

py3: use print as a function in tests/test-parseindex.t Differential Revision: https://phab.mercurial-scm.org/D3603
author Pulkit Goyal <7895pulkit@gmail.com>
date Sat, 19 May 2018 18:42:18 +0530
parents ca890999d317
children 307b19c7c043
comparison
equal deleted inserted replaced
38078:549e970397b2 38079:ce307af030a2
24 user: test 24 user: test
25 date: Thu Jan 01 00:00:00 1970 +0000 25 date: Thu Jan 01 00:00:00 1970 +0000
26 summary: change foo 26 summary: change foo
27 27
28 $ cat >> test.py << EOF 28 $ cat >> test.py << EOF
29 > from __future__ import print_function
29 > from mercurial import changelog, vfs 30 > from mercurial import changelog, vfs
30 > from mercurial.node import * 31 > from mercurial.node import *
31 > 32 >
32 > class singlebyteread(object): 33 > class singlebyteread(object):
33 > def __init__(self, real): 34 > def __init__(self, real):
54 > f = o(*a, **kwargs) 55 > f = o(*a, **kwargs)
55 > return singlebyteread(f) 56 > return singlebyteread(f)
56 > return wrapper 57 > return wrapper
57 > 58 >
58 > cl = changelog.changelog(opener('.hg/store')) 59 > cl = changelog.changelog(opener('.hg/store'))
59 > print len(cl), 'revisions:' 60 > print(len(cl), 'revisions:')
60 > for r in cl: 61 > for r in cl:
61 > print short(cl.node(r)) 62 > print(short(cl.node(r)))
62 > EOF 63 > EOF
63 $ $PYTHON test.py 64 $ $PYTHON test.py
64 2 revisions: 65 2 revisions:
65 7c31755bf9b5 66 7c31755bf9b5
66 26333235a41c 67 26333235a41c
72 Test SEGV caused by bad revision passed to reachableroots() (issue4775): 73 Test SEGV caused by bad revision passed to reachableroots() (issue4775):
73 74
74 $ cd a 75 $ cd a
75 76
76 $ $PYTHON <<EOF 77 $ $PYTHON <<EOF
78 > from __future__ import print_function
77 > from mercurial import changelog, vfs 79 > from mercurial import changelog, vfs
78 > cl = changelog.changelog(vfs.vfs('.hg/store')) 80 > cl = changelog.changelog(vfs.vfs('.hg/store'))
79 > print 'good heads:' 81 > print('good heads:')
80 > for head in [0, len(cl) - 1, -1]: 82 > for head in [0, len(cl) - 1, -1]:
81 > print'%s: %r' % (head, cl.reachableroots(0, [head], [0])) 83 > print('%s: %r' % (head, cl.reachableroots(0, [head], [0])))
82 > print 'bad heads:' 84 > print('bad heads:')
83 > for head in [len(cl), 10000, -2, -10000, None]: 85 > for head in [len(cl), 10000, -2, -10000, None]:
84 > print '%s:' % head, 86 > print('%s:' % head, end=' ')
85 > try: 87 > try:
86 > cl.reachableroots(0, [head], [0]) 88 > cl.reachableroots(0, [head], [0])
87 > print 'uncaught buffer overflow?' 89 > print('uncaught buffer overflow?')
88 > except (IndexError, TypeError) as inst: 90 > except (IndexError, TypeError) as inst:
89 > print inst 91 > print(inst)
90 > print 'good roots:' 92 > print('good roots:')
91 > for root in [0, len(cl) - 1, -1]: 93 > for root in [0, len(cl) - 1, -1]:
92 > print '%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])) 94 > print('%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])))
93 > print 'out-of-range roots are ignored:' 95 > print('out-of-range roots are ignored:')
94 > for root in [len(cl), 10000, -2, -10000]: 96 > for root in [len(cl), 10000, -2, -10000]:
95 > print '%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])) 97 > print('%s: %r' % (root, cl.reachableroots(root, [len(cl) - 1], [root])))
96 > print 'bad roots:' 98 > print('bad roots:')
97 > for root in [None]: 99 > for root in [None]:
98 > print '%s:' % root, 100 > print('%s:' % root, end=' ')
99 > try: 101 > try:
100 > cl.reachableroots(root, [len(cl) - 1], [root]) 102 > cl.reachableroots(root, [len(cl) - 1], [root])
101 > print 'uncaught error?' 103 > print('uncaught error?')
102 > except TypeError as inst: 104 > except TypeError as inst:
103 > print inst 105 > print(inst)
104 > EOF 106 > EOF
105 good heads: 107 good heads:
106 0: [0] 108 0: [0]
107 1: [0] 109 1: [0]
108 -1: [] 110 -1: []
162 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio 164 rev chain# chainlen prev delta size rawsize chainsize ratio lindist extradist extraratio
163 0 1 1 -1 base 63 62 63 1.01613 63 0 0.00000 165 0 1 1 -1 base 63 62 63 1.01613 63 0 0.00000
164 1 2 1 -1 base 66 65 66 1.01538 66 0 0.00000 166 1 2 1 -1 base 66 65 66 1.01538 66 0 0.00000
165 167
166 $ cat <<EOF > test.py 168 $ cat <<EOF > test.py
169 > from __future__ import print_function
167 > import sys 170 > import sys
168 > from mercurial import changelog, vfs 171 > from mercurial import changelog, vfs
169 > cl = changelog.changelog(vfs.vfs(sys.argv[1])) 172 > cl = changelog.changelog(vfs.vfs(sys.argv[1]))
170 > n0, n1 = cl.node(0), cl.node(1) 173 > n0, n1 = cl.node(0), cl.node(1)
171 > ops = [ 174 > ops = [
175 > ('index_headrevs', lambda: cl.headrevs()), 178 > ('index_headrevs', lambda: cl.headrevs()),
176 > ('find_gca_candidates', lambda: cl.commonancestorsheads(n0, n1)), 179 > ('find_gca_candidates', lambda: cl.commonancestorsheads(n0, n1)),
177 > ('find_deepest', lambda: cl.ancestor(n0, n1)), 180 > ('find_deepest', lambda: cl.ancestor(n0, n1)),
178 > ] 181 > ]
179 > for l, f in ops: 182 > for l, f in ops:
180 > print l + ':', 183 > print(l + ':', end=' ')
181 > try: 184 > try:
182 > f() 185 > f()
183 > print 'uncaught buffer overflow?' 186 > print('uncaught buffer overflow?')
184 > except ValueError, inst: 187 > except ValueError, inst:
185 > print inst 188 > print(inst)
186 > EOF 189 > EOF
187 190
188 $ $PYTHON test.py limit/.hg/store 191 $ $PYTHON test.py limit/.hg/store
189 reachableroots: parent out of range 192 reachableroots: parent out of range
190 compute_phases_map_sets: parent out of range 193 compute_phases_map_sets: parent out of range