##// END OF EJS Templates
tests: bulk changes to avoid whitespace errors of check-code.py...
FUJIWARA Katsunori -
r41885:c70bdd22 default
parent child Browse files
Show More
@@ -1,120 +1,121 b''
1 #testcases sshv1 sshv2
1 #testcases sshv1 sshv2
2
2
3 #if sshv2
3 #if sshv2
4 $ cat >> $HGRCPATH << EOF
4 $ cat >> $HGRCPATH << EOF
5 > [experimental]
5 > [experimental]
6 > sshpeer.advertise-v2 = true
6 > sshpeer.advertise-v2 = true
7 > sshserver.support-v2 = true
7 > sshserver.support-v2 = true
8 > EOF
8 > EOF
9 #endif
9 #endif
10
10
11 $ cat > bundle2.py << EOF
11 $ cat > bundle2.py << EOF
12 > """A small extension to test bundle2 pushback parts.
12 > """A small extension to test bundle2 pushback parts.
13 > Current bundle2 implementation doesn't provide a way to generate those
13 > Current bundle2 implementation doesn't provide a way to generate those
14 > parts, so they must be created by extensions.
14 > parts, so they must be created by extensions.
15 > """
15 > """
16 > from __future__ import absolute_import
16 > from __future__ import absolute_import
17 > from mercurial import bundle2, exchange, pushkey, util
17 > from mercurial import bundle2, exchange, pushkey, util
18 > def _newhandlechangegroup(op, inpart):
18 > def _newhandlechangegroup(op, inpart):
19 > """This function wraps the changegroup part handler for getbundle.
19 > """This function wraps the changegroup part handler for getbundle.
20 > It issues an additional pushkey part to send a new
20 > It issues an additional pushkey part to send a new
21 > bookmark back to the client"""
21 > bookmark back to the client"""
22 > result = bundle2.handlechangegroup(op, inpart)
22 > result = bundle2.handlechangegroup(op, inpart)
23 > if b'pushback' in op.reply.capabilities:
23 > if b'pushback' in op.reply.capabilities:
24 > params = {b'namespace': b'bookmarks',
24 > params = {b'namespace': b'bookmarks',
25 > b'key': b'new-server-mark',
25 > b'key': b'new-server-mark',
26 > b'old': b'',
26 > b'old': b'',
27 > b'new': b'tip'}
27 > b'new': b'tip'}
28 > encodedparams = [(k, pushkey.encode(v)) for (k,v) in params.items()]
28 > encodedparams = [(k, pushkey.encode(v))
29 > for (k, v) in params.items()]
29 > op.reply.newpart(b'pushkey', mandatoryparams=encodedparams)
30 > op.reply.newpart(b'pushkey', mandatoryparams=encodedparams)
30 > else:
31 > else:
31 > op.reply.newpart(b'output', data=b'pushback not enabled')
32 > op.reply.newpart(b'output', data=b'pushback not enabled')
32 > return result
33 > return result
33 > _newhandlechangegroup.params = bundle2.handlechangegroup.params
34 > _newhandlechangegroup.params = bundle2.handlechangegroup.params
34 > bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup
35 > bundle2.parthandlermapping[b'changegroup'] = _newhandlechangegroup
35 > EOF
36 > EOF
36
37
37 $ cat >> $HGRCPATH <<EOF
38 $ cat >> $HGRCPATH <<EOF
38 > [ui]
39 > [ui]
39 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
40 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
40 > username = nobody <no.reply@example.com>
41 > username = nobody <no.reply@example.com>
41 >
42 >
42 > [alias]
43 > [alias]
43 > tglog = log -G -T "{desc} [{phase}:{node|short}]"
44 > tglog = log -G -T "{desc} [{phase}:{node|short}]"
44 > EOF
45 > EOF
45
46
46 Set up server repository
47 Set up server repository
47
48
48 $ hg init server
49 $ hg init server
49 $ cd server
50 $ cd server
50 $ echo c0 > f0
51 $ echo c0 > f0
51 $ hg commit -Am 0
52 $ hg commit -Am 0
52 adding f0
53 adding f0
53
54
54 Set up client repository
55 Set up client repository
55
56
56 $ cd ..
57 $ cd ..
57 $ hg clone ssh://user@dummy/server client -q
58 $ hg clone ssh://user@dummy/server client -q
58 $ cd client
59 $ cd client
59
60
60 Enable extension
61 Enable extension
61 $ cat >> $HGRCPATH <<EOF
62 $ cat >> $HGRCPATH <<EOF
62 > [extensions]
63 > [extensions]
63 > bundle2=$TESTTMP/bundle2.py
64 > bundle2=$TESTTMP/bundle2.py
64 > EOF
65 > EOF
65
66
66 Without config
67 Without config
67
68
68 $ cd ../client
69 $ cd ../client
69 $ echo c1 > f1
70 $ echo c1 > f1
70 $ hg commit -Am 1
71 $ hg commit -Am 1
71 adding f1
72 adding f1
72 $ hg push
73 $ hg push
73 pushing to ssh://user@dummy/server
74 pushing to ssh://user@dummy/server
74 searching for changes
75 searching for changes
75 remote: adding changesets
76 remote: adding changesets
76 remote: adding manifests
77 remote: adding manifests
77 remote: adding file changes
78 remote: adding file changes
78 remote: added 1 changesets with 1 changes to 1 files
79 remote: added 1 changesets with 1 changes to 1 files
79 remote: pushback not enabled
80 remote: pushback not enabled
80 $ hg bookmark
81 $ hg bookmark
81 no bookmarks set
82 no bookmarks set
82
83
83 $ cd ../server
84 $ cd ../server
84 $ hg tglog
85 $ hg tglog
85 o 1 [public:2b9c7234e035]
86 o 1 [public:2b9c7234e035]
86 |
87 |
87 @ 0 [public:6cee5c8f3e5b]
88 @ 0 [public:6cee5c8f3e5b]
88
89
89
90
90
91
91
92
92 With config
93 With config
93
94
94 $ cd ../client
95 $ cd ../client
95 $ echo '[experimental]' >> .hg/hgrc
96 $ echo '[experimental]' >> .hg/hgrc
96 $ echo 'bundle2.pushback = True' >> .hg/hgrc
97 $ echo 'bundle2.pushback = True' >> .hg/hgrc
97 $ echo c2 > f2
98 $ echo c2 > f2
98 $ hg commit -Am 2
99 $ hg commit -Am 2
99 adding f2
100 adding f2
100 $ hg push
101 $ hg push
101 pushing to ssh://user@dummy/server
102 pushing to ssh://user@dummy/server
102 searching for changes
103 searching for changes
103 remote: adding changesets
104 remote: adding changesets
104 remote: adding manifests
105 remote: adding manifests
105 remote: adding file changes
106 remote: adding file changes
106 remote: added 1 changesets with 1 changes to 1 files
107 remote: added 1 changesets with 1 changes to 1 files
107 $ hg bookmark
108 $ hg bookmark
108 new-server-mark 2:0a76dfb2e179
109 new-server-mark 2:0a76dfb2e179
109
110
110 $ cd ../server
111 $ cd ../server
111 $ hg tglog
112 $ hg tglog
112 o 2 [public:0a76dfb2e179]
113 o 2 [public:0a76dfb2e179]
113 |
114 |
114 o 1 [public:2b9c7234e035]
115 o 1 [public:2b9c7234e035]
115 |
116 |
116 @ 0 [public:6cee5c8f3e5b]
117 @ 0 [public:6cee5c8f3e5b]
117
118
118
119
119
120
120
121
@@ -1,659 +1,659 b''
1 #require cvs
1 #require cvs
2
2
3 $ cvscall()
3 $ cvscall()
4 > {
4 > {
5 > cvs -f "$@"
5 > cvs -f "$@"
6 > }
6 > }
7 $ hgcat()
7 $ hgcat()
8 > {
8 > {
9 > hg --cwd src-hg cat -r tip "$1"
9 > hg --cwd src-hg cat -r tip "$1"
10 > }
10 > }
11 $ echo "[extensions]" >> $HGRCPATH
11 $ echo "[extensions]" >> $HGRCPATH
12 $ echo "convert = " >> $HGRCPATH
12 $ echo "convert = " >> $HGRCPATH
13 $ cat > cvshooks.py <<EOF
13 $ cat > cvshooks.py <<EOF
14 > def cvslog(ui,repo,hooktype,log):
14 > def cvslog(ui, repo, hooktype, log):
15 > ui.write(b'%s hook: %d entries\n' % (hooktype,len(log)))
15 > ui.write(b'%s hook: %d entries\n' % (hooktype, len(log)))
16 >
16 >
17 > def cvschangesets(ui,repo,hooktype,changesets):
17 > def cvschangesets(ui, repo, hooktype, changesets):
18 > ui.write(b'%s hook: %d changesets\n' % (hooktype,len(changesets)))
18 > ui.write(b'%s hook: %d changesets\n' % (hooktype, len(changesets)))
19 > EOF
19 > EOF
20 $ hookpath=`pwd`
20 $ hookpath=`pwd`
21 $ cat <<EOF >> $HGRCPATH
21 $ cat <<EOF >> $HGRCPATH
22 > [hooks]
22 > [hooks]
23 > cvslog = python:$hookpath/cvshooks.py:cvslog
23 > cvslog = python:$hookpath/cvshooks.py:cvslog
24 > cvschangesets = python:$hookpath/cvshooks.py:cvschangesets
24 > cvschangesets = python:$hookpath/cvshooks.py:cvschangesets
25 > EOF
25 > EOF
26
26
27 create cvs repository
27 create cvs repository
28
28
29 $ mkdir cvsrepo
29 $ mkdir cvsrepo
30 $ cd cvsrepo
30 $ cd cvsrepo
31 $ CVSROOT=`pwd`
31 $ CVSROOT=`pwd`
32 $ export CVSROOT
32 $ export CVSROOT
33 $ CVS_OPTIONS=-f
33 $ CVS_OPTIONS=-f
34 $ export CVS_OPTIONS
34 $ export CVS_OPTIONS
35 $ cd ..
35 $ cd ..
36 $ rmdir cvsrepo
36 $ rmdir cvsrepo
37 $ cvscall -q -d "$CVSROOT" init
37 $ cvscall -q -d "$CVSROOT" init
38
38
39 create source directory
39 create source directory
40
40
41 $ mkdir src-temp
41 $ mkdir src-temp
42 $ cd src-temp
42 $ cd src-temp
43 $ echo a > a
43 $ echo a > a
44 $ mkdir b
44 $ mkdir b
45 $ cd b
45 $ cd b
46 $ echo c > c
46 $ echo c > c
47 $ cd ..
47 $ cd ..
48
48
49 import source directory
49 import source directory
50
50
51 $ cvscall -q import -m import src INITIAL start
51 $ cvscall -q import -m import src INITIAL start
52 N src/a
52 N src/a
53 N src/b/c
53 N src/b/c
54
54
55 No conflicts created by this import
55 No conflicts created by this import
56
56
57 $ cd ..
57 $ cd ..
58
58
59 checkout source directory
59 checkout source directory
60
60
61 $ cvscall -q checkout src
61 $ cvscall -q checkout src
62 U src/a
62 U src/a
63 U src/b/c
63 U src/b/c
64
64
65 commit a new revision changing b/c
65 commit a new revision changing b/c
66
66
67 $ cd src
67 $ cd src
68 $ sleep 1
68 $ sleep 1
69 $ echo c >> b/c
69 $ echo c >> b/c
70 $ cvscall -q commit -mci0 . | grep '<--'
70 $ cvscall -q commit -mci0 . | grep '<--'
71 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
71 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
72 $ cd ..
72 $ cd ..
73
73
74 convert fresh repo and also check localtimezone option
74 convert fresh repo and also check localtimezone option
75
75
76 NOTE: This doesn't check all time zones -- it merely determines that
76 NOTE: This doesn't check all time zones -- it merely determines that
77 the configuration option is taking effect.
77 the configuration option is taking effect.
78
78
79 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
79 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
80 since it does not use DST (unlike other U.S. time zones) and is always
80 since it does not use DST (unlike other U.S. time zones) and is always
81 a fixed difference from UTC.
81 a fixed difference from UTC.
82
82
83 This choice is limited to work on Linux environments. At least on
83 This choice is limited to work on Linux environments. At least on
84 FreeBSD 11 this timezone is not known. A better choice is
84 FreeBSD 11 this timezone is not known. A better choice is
85 TZ=Pacific/Johnston. On Linux "US/Hawaii" is just a symlink to this
85 TZ=Pacific/Johnston. On Linux "US/Hawaii" is just a symlink to this
86 name and also it is known on FreeBSD and on Solaris.
86 name and also it is known on FreeBSD and on Solaris.
87
87
88 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
88 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
89 initializing destination src-hg repository
89 initializing destination src-hg repository
90 connecting to $TESTTMP/cvsrepo
90 connecting to $TESTTMP/cvsrepo
91 scanning source...
91 scanning source...
92 collecting CVS rlog
92 collecting CVS rlog
93 5 log entries
93 5 log entries
94 cvslog hook: 5 entries
94 cvslog hook: 5 entries
95 creating changesets
95 creating changesets
96 3 changeset entries
96 3 changeset entries
97 cvschangesets hook: 3 changesets
97 cvschangesets hook: 3 changesets
98 sorting...
98 sorting...
99 converting...
99 converting...
100 2 Initial revision
100 2 Initial revision
101 1 ci0
101 1 ci0
102 0 import
102 0 import
103 updating tags
103 updating tags
104 $ hgcat a
104 $ hgcat a
105 a
105 a
106 $ hgcat b/c
106 $ hgcat b/c
107 c
107 c
108 c
108 c
109
109
110 convert fresh repo with --filemap
110 convert fresh repo with --filemap
111
111
112 $ echo include b/c > filemap
112 $ echo include b/c > filemap
113 $ hg convert --filemap filemap src src-filemap
113 $ hg convert --filemap filemap src src-filemap
114 initializing destination src-filemap repository
114 initializing destination src-filemap repository
115 connecting to $TESTTMP/cvsrepo
115 connecting to $TESTTMP/cvsrepo
116 scanning source...
116 scanning source...
117 collecting CVS rlog
117 collecting CVS rlog
118 5 log entries
118 5 log entries
119 cvslog hook: 5 entries
119 cvslog hook: 5 entries
120 creating changesets
120 creating changesets
121 3 changeset entries
121 3 changeset entries
122 cvschangesets hook: 3 changesets
122 cvschangesets hook: 3 changesets
123 sorting...
123 sorting...
124 converting...
124 converting...
125 2 Initial revision
125 2 Initial revision
126 1 ci0
126 1 ci0
127 0 import
127 0 import
128 filtering out empty revision
128 filtering out empty revision
129 repository tip rolled back to revision 1 (undo convert)
129 repository tip rolled back to revision 1 (undo convert)
130 updating tags
130 updating tags
131 $ hgcat b/c
131 $ hgcat b/c
132 c
132 c
133 c
133 c
134 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
134 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
135 2 update tags files: .hgtags
135 2 update tags files: .hgtags
136 1 ci0 files: b/c
136 1 ci0 files: b/c
137 0 Initial revision files: b/c
137 0 Initial revision files: b/c
138
138
139 convert full repository (issue1649)
139 convert full repository (issue1649)
140
140
141 $ cvscall -q -d "$CVSROOT" checkout -d srcfull "." | grep -v CVSROOT
141 $ cvscall -q -d "$CVSROOT" checkout -d srcfull "." | grep -v CVSROOT
142 U srcfull/src/a
142 U srcfull/src/a
143 U srcfull/src/b/c
143 U srcfull/src/b/c
144 $ ls srcfull
144 $ ls srcfull
145 CVS
145 CVS
146 CVSROOT
146 CVSROOT
147 src
147 src
148 $ hg convert srcfull srcfull-hg \
148 $ hg convert srcfull srcfull-hg \
149 > | grep -v 'log entries' | grep -v 'hook:' \
149 > | grep -v 'log entries' | grep -v 'hook:' \
150 > | grep -v '^[0-3] .*' # filter instable changeset order
150 > | grep -v '^[0-3] .*' # filter instable changeset order
151 initializing destination srcfull-hg repository
151 initializing destination srcfull-hg repository
152 connecting to $TESTTMP/cvsrepo
152 connecting to $TESTTMP/cvsrepo
153 scanning source...
153 scanning source...
154 collecting CVS rlog
154 collecting CVS rlog
155 creating changesets
155 creating changesets
156 4 changeset entries
156 4 changeset entries
157 sorting...
157 sorting...
158 converting...
158 converting...
159 updating tags
159 updating tags
160 $ hg cat -r tip --cwd srcfull-hg src/a
160 $ hg cat -r tip --cwd srcfull-hg src/a
161 a
161 a
162 $ hg cat -r tip --cwd srcfull-hg src/b/c
162 $ hg cat -r tip --cwd srcfull-hg src/b/c
163 c
163 c
164 c
164 c
165
165
166 commit new file revisions
166 commit new file revisions
167
167
168 $ cd src
168 $ cd src
169 $ echo a >> a
169 $ echo a >> a
170 $ echo c >> b/c
170 $ echo c >> b/c
171 $ cvscall -q commit -mci1 . | grep '<--'
171 $ cvscall -q commit -mci1 . | grep '<--'
172 $TESTTMP/cvsrepo/src/a,v <-- a
172 $TESTTMP/cvsrepo/src/a,v <-- a
173 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
173 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
174 $ cd ..
174 $ cd ..
175
175
176 convert again
176 convert again
177
177
178 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
178 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
179 connecting to $TESTTMP/cvsrepo
179 connecting to $TESTTMP/cvsrepo
180 scanning source...
180 scanning source...
181 collecting CVS rlog
181 collecting CVS rlog
182 7 log entries
182 7 log entries
183 cvslog hook: 7 entries
183 cvslog hook: 7 entries
184 creating changesets
184 creating changesets
185 4 changeset entries
185 4 changeset entries
186 cvschangesets hook: 4 changesets
186 cvschangesets hook: 4 changesets
187 sorting...
187 sorting...
188 converting...
188 converting...
189 0 ci1
189 0 ci1
190 $ hgcat a
190 $ hgcat a
191 a
191 a
192 a
192 a
193 $ hgcat b/c
193 $ hgcat b/c
194 c
194 c
195 c
195 c
196 c
196 c
197
197
198 convert again with --filemap
198 convert again with --filemap
199
199
200 $ hg convert --filemap filemap src src-filemap
200 $ hg convert --filemap filemap src src-filemap
201 connecting to $TESTTMP/cvsrepo
201 connecting to $TESTTMP/cvsrepo
202 scanning source...
202 scanning source...
203 collecting CVS rlog
203 collecting CVS rlog
204 7 log entries
204 7 log entries
205 cvslog hook: 7 entries
205 cvslog hook: 7 entries
206 creating changesets
206 creating changesets
207 4 changeset entries
207 4 changeset entries
208 cvschangesets hook: 4 changesets
208 cvschangesets hook: 4 changesets
209 sorting...
209 sorting...
210 converting...
210 converting...
211 0 ci1
211 0 ci1
212 $ hgcat b/c
212 $ hgcat b/c
213 c
213 c
214 c
214 c
215 c
215 c
216 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
216 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
217 3 ci1 files: b/c
217 3 ci1 files: b/c
218 2 update tags files: .hgtags
218 2 update tags files: .hgtags
219 1 ci0 files: b/c
219 1 ci0 files: b/c
220 0 Initial revision files: b/c
220 0 Initial revision files: b/c
221
221
222 commit branch
222 commit branch
223
223
224 $ cd src
224 $ cd src
225 $ cvs -q update -r1.1 b/c
225 $ cvs -q update -r1.1 b/c
226 U b/c
226 U b/c
227 $ cvs -q tag -b branch
227 $ cvs -q tag -b branch
228 T a
228 T a
229 T b/c
229 T b/c
230 $ cvs -q update -r branch > /dev/null
230 $ cvs -q update -r branch > /dev/null
231 $ sleep 1
231 $ sleep 1
232 $ echo d >> b/c
232 $ echo d >> b/c
233 $ cvs -q commit -mci2 . | grep '<--'
233 $ cvs -q commit -mci2 . | grep '<--'
234 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
234 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
235 $ cd ..
235 $ cd ..
236
236
237 convert again
237 convert again
238
238
239 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
239 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
240 connecting to $TESTTMP/cvsrepo
240 connecting to $TESTTMP/cvsrepo
241 scanning source...
241 scanning source...
242 collecting CVS rlog
242 collecting CVS rlog
243 8 log entries
243 8 log entries
244 cvslog hook: 8 entries
244 cvslog hook: 8 entries
245 creating changesets
245 creating changesets
246 5 changeset entries
246 5 changeset entries
247 cvschangesets hook: 5 changesets
247 cvschangesets hook: 5 changesets
248 sorting...
248 sorting...
249 converting...
249 converting...
250 0 ci2
250 0 ci2
251 $ hgcat b/c
251 $ hgcat b/c
252 c
252 c
253 d
253 d
254
254
255 convert again with --filemap
255 convert again with --filemap
256
256
257 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True --filemap filemap src src-filemap
257 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True --filemap filemap src src-filemap
258 connecting to $TESTTMP/cvsrepo
258 connecting to $TESTTMP/cvsrepo
259 scanning source...
259 scanning source...
260 collecting CVS rlog
260 collecting CVS rlog
261 8 log entries
261 8 log entries
262 cvslog hook: 8 entries
262 cvslog hook: 8 entries
263 creating changesets
263 creating changesets
264 5 changeset entries
264 5 changeset entries
265 cvschangesets hook: 5 changesets
265 cvschangesets hook: 5 changesets
266 sorting...
266 sorting...
267 converting...
267 converting...
268 0 ci2
268 0 ci2
269 $ hgcat b/c
269 $ hgcat b/c
270 c
270 c
271 d
271 d
272 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
272 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
273 4 ci2 files: b/c
273 4 ci2 files: b/c
274 3 ci1 files: b/c
274 3 ci1 files: b/c
275 2 update tags files: .hgtags
275 2 update tags files: .hgtags
276 1 ci0 files: b/c
276 1 ci0 files: b/c
277 0 Initial revision files: b/c
277 0 Initial revision files: b/c
278
278
279 commit a new revision with funny log message
279 commit a new revision with funny log message
280
280
281 $ cd src
281 $ cd src
282 $ sleep 1
282 $ sleep 1
283 $ echo e >> a
283 $ echo e >> a
284 $ cvscall -q commit -m'funny
284 $ cvscall -q commit -m'funny
285 > ----------------------------
285 > ----------------------------
286 > log message' . | grep '<--' |\
286 > log message' . | grep '<--' |\
287 > sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
287 > sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
288 checking in src/a,v
288 checking in src/a,v
289
289
290 commit new file revisions with some fuzz
290 commit new file revisions with some fuzz
291
291
292 $ sleep 1
292 $ sleep 1
293 $ echo f >> a
293 $ echo f >> a
294 $ cvscall -q commit -mfuzzy . | grep '<--'
294 $ cvscall -q commit -mfuzzy . | grep '<--'
295 $TESTTMP/cvsrepo/src/a,v <-- a
295 $TESTTMP/cvsrepo/src/a,v <-- a
296 $ sleep 4 # the two changes will be split if fuzz < 4
296 $ sleep 4 # the two changes will be split if fuzz < 4
297 $ echo g >> b/c
297 $ echo g >> b/c
298 $ cvscall -q commit -mfuzzy . | grep '<--'
298 $ cvscall -q commit -mfuzzy . | grep '<--'
299 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
299 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
300 $ cd ..
300 $ cd ..
301
301
302 convert again
302 convert again
303
303
304 $ TZ=Pacific/Johnston hg convert --config convert.cvsps.fuzz=2 --config convert.localtimezone=True src src-hg
304 $ TZ=Pacific/Johnston hg convert --config convert.cvsps.fuzz=2 --config convert.localtimezone=True src src-hg
305 connecting to $TESTTMP/cvsrepo
305 connecting to $TESTTMP/cvsrepo
306 scanning source...
306 scanning source...
307 collecting CVS rlog
307 collecting CVS rlog
308 11 log entries
308 11 log entries
309 cvslog hook: 11 entries
309 cvslog hook: 11 entries
310 creating changesets
310 creating changesets
311 8 changeset entries
311 8 changeset entries
312 cvschangesets hook: 8 changesets
312 cvschangesets hook: 8 changesets
313 sorting...
313 sorting...
314 converting...
314 converting...
315 2 funny
315 2 funny
316 1 fuzzy
316 1 fuzzy
317 0 fuzzy
317 0 fuzzy
318 $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
318 $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
319 o 8 (branch) fuzzy date: * -1000 files: b/c (glob)
319 o 8 (branch) fuzzy date: * -1000 files: b/c (glob)
320 |
320 |
321 o 7 (branch) fuzzy date: * -1000 files: a (glob)
321 o 7 (branch) fuzzy date: * -1000 files: a (glob)
322 |
322 |
323 o 6 (branch) funny
323 o 6 (branch) funny
324 | ----------------------------
324 | ----------------------------
325 | log message date: * -1000 files: a (glob)
325 | log message date: * -1000 files: a (glob)
326 o 5 (branch) ci2 date: * -1000 files: b/c (glob)
326 o 5 (branch) ci2 date: * -1000 files: b/c (glob)
327
327
328 o 4 () ci1 date: * -1000 files: a b/c (glob)
328 o 4 () ci1 date: * -1000 files: a b/c (glob)
329 |
329 |
330 o 3 () update tags date: * +0000 files: .hgtags (glob)
330 o 3 () update tags date: * +0000 files: .hgtags (glob)
331 |
331 |
332 | o 2 (INITIAL) import date: * -1000 files: (glob)
332 | o 2 (INITIAL) import date: * -1000 files: (glob)
333 | |
333 | |
334 o | 1 () ci0 date: * -1000 files: b/c (glob)
334 o | 1 () ci0 date: * -1000 files: b/c (glob)
335 |/
335 |/
336 o 0 () Initial revision date: * -1000 files: a b/c (glob)
336 o 0 () Initial revision date: * -1000 files: a b/c (glob)
337
337
338
338
339 testing debugcvsps
339 testing debugcvsps
340
340
341 $ cd src
341 $ cd src
342 $ hg debugcvsps --fuzz=2 -x >/dev/null
342 $ hg debugcvsps --fuzz=2 -x >/dev/null
343
343
344 commit a new revision changing a and removing b/c
344 commit a new revision changing a and removing b/c
345
345
346 $ cvscall -q update -A
346 $ cvscall -q update -A
347 U a
347 U a
348 U b/c
348 U b/c
349 $ sleep 1
349 $ sleep 1
350 $ echo h >> a
350 $ echo h >> a
351 $ cvscall -Q remove -f b/c
351 $ cvscall -Q remove -f b/c
352 $ cvscall -q commit -mci | grep '<--'
352 $ cvscall -q commit -mci | grep '<--'
353 $TESTTMP/cvsrepo/src/a,v <-- a
353 $TESTTMP/cvsrepo/src/a,v <-- a
354 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
354 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
355
355
356 update and verify the cvsps cache
356 update and verify the cvsps cache
357
357
358 $ hg debugcvsps --fuzz=2 -u
358 $ hg debugcvsps --fuzz=2 -u
359 collecting CVS rlog
359 collecting CVS rlog
360 13 log entries
360 13 log entries
361 cvslog hook: 13 entries
361 cvslog hook: 13 entries
362 creating changesets
362 creating changesets
363 11 changeset entries
363 11 changeset entries
364 cvschangesets hook: 11 changesets
364 cvschangesets hook: 11 changesets
365 ---------------------
365 ---------------------
366 PatchSet 1
366 PatchSet 1
367 Date: * (glob)
367 Date: * (glob)
368 Author: * (glob)
368 Author: * (glob)
369 Branch: HEAD
369 Branch: HEAD
370 Tag: (none)
370 Tag: (none)
371 Branchpoints: INITIAL
371 Branchpoints: INITIAL
372 Log:
372 Log:
373 Initial revision
373 Initial revision
374
374
375 Members:
375 Members:
376 a:INITIAL->1.1
376 a:INITIAL->1.1
377
377
378 ---------------------
378 ---------------------
379 PatchSet 2
379 PatchSet 2
380 Date: * (glob)
380 Date: * (glob)
381 Author: * (glob)
381 Author: * (glob)
382 Branch: HEAD
382 Branch: HEAD
383 Tag: (none)
383 Tag: (none)
384 Branchpoints: INITIAL, branch
384 Branchpoints: INITIAL, branch
385 Log:
385 Log:
386 Initial revision
386 Initial revision
387
387
388 Members:
388 Members:
389 b/c:INITIAL->1.1
389 b/c:INITIAL->1.1
390
390
391 ---------------------
391 ---------------------
392 PatchSet 3
392 PatchSet 3
393 Date: * (glob)
393 Date: * (glob)
394 Author: * (glob)
394 Author: * (glob)
395 Branch: INITIAL
395 Branch: INITIAL
396 Tag: start
396 Tag: start
397 Log:
397 Log:
398 import
398 import
399
399
400 Members:
400 Members:
401 a:1.1->1.1.1.1
401 a:1.1->1.1.1.1
402 b/c:1.1->1.1.1.1
402 b/c:1.1->1.1.1.1
403
403
404 ---------------------
404 ---------------------
405 PatchSet 4
405 PatchSet 4
406 Date: * (glob)
406 Date: * (glob)
407 Author: * (glob)
407 Author: * (glob)
408 Branch: HEAD
408 Branch: HEAD
409 Tag: (none)
409 Tag: (none)
410 Log:
410 Log:
411 ci0
411 ci0
412
412
413 Members:
413 Members:
414 b/c:1.1->1.2
414 b/c:1.1->1.2
415
415
416 ---------------------
416 ---------------------
417 PatchSet 5
417 PatchSet 5
418 Date: * (glob)
418 Date: * (glob)
419 Author: * (glob)
419 Author: * (glob)
420 Branch: HEAD
420 Branch: HEAD
421 Tag: (none)
421 Tag: (none)
422 Branchpoints: branch
422 Branchpoints: branch
423 Log:
423 Log:
424 ci1
424 ci1
425
425
426 Members:
426 Members:
427 a:1.1->1.2
427 a:1.1->1.2
428
428
429 ---------------------
429 ---------------------
430 PatchSet 6
430 PatchSet 6
431 Date: * (glob)
431 Date: * (glob)
432 Author: * (glob)
432 Author: * (glob)
433 Branch: HEAD
433 Branch: HEAD
434 Tag: (none)
434 Tag: (none)
435 Log:
435 Log:
436 ci1
436 ci1
437
437
438 Members:
438 Members:
439 b/c:1.2->1.3
439 b/c:1.2->1.3
440
440
441 ---------------------
441 ---------------------
442 PatchSet 7
442 PatchSet 7
443 Date: * (glob)
443 Date: * (glob)
444 Author: * (glob)
444 Author: * (glob)
445 Branch: branch
445 Branch: branch
446 Tag: (none)
446 Tag: (none)
447 Log:
447 Log:
448 ci2
448 ci2
449
449
450 Members:
450 Members:
451 b/c:1.1->1.1.2.1
451 b/c:1.1->1.1.2.1
452
452
453 ---------------------
453 ---------------------
454 PatchSet 8
454 PatchSet 8
455 Date: * (glob)
455 Date: * (glob)
456 Author: * (glob)
456 Author: * (glob)
457 Branch: branch
457 Branch: branch
458 Tag: (none)
458 Tag: (none)
459 Log:
459 Log:
460 funny
460 funny
461 ----------------------------
461 ----------------------------
462 log message
462 log message
463
463
464 Members:
464 Members:
465 a:1.2->1.2.2.1
465 a:1.2->1.2.2.1
466
466
467 ---------------------
467 ---------------------
468 PatchSet 9
468 PatchSet 9
469 Date: * (glob)
469 Date: * (glob)
470 Author: * (glob)
470 Author: * (glob)
471 Branch: branch
471 Branch: branch
472 Tag: (none)
472 Tag: (none)
473 Log:
473 Log:
474 fuzzy
474 fuzzy
475
475
476 Members:
476 Members:
477 a:1.2.2.1->1.2.2.2
477 a:1.2.2.1->1.2.2.2
478
478
479 ---------------------
479 ---------------------
480 PatchSet 10
480 PatchSet 10
481 Date: * (glob)
481 Date: * (glob)
482 Author: * (glob)
482 Author: * (glob)
483 Branch: branch
483 Branch: branch
484 Tag: (none)
484 Tag: (none)
485 Log:
485 Log:
486 fuzzy
486 fuzzy
487
487
488 Members:
488 Members:
489 b/c:1.1.2.1->1.1.2.2
489 b/c:1.1.2.1->1.1.2.2
490
490
491 ---------------------
491 ---------------------
492 PatchSet 11
492 PatchSet 11
493 Date: * (glob)
493 Date: * (glob)
494 Author: * (glob)
494 Author: * (glob)
495 Branch: HEAD
495 Branch: HEAD
496 Tag: (none)
496 Tag: (none)
497 Log:
497 Log:
498 ci
498 ci
499
499
500 Members:
500 Members:
501 a:1.2->1.3
501 a:1.2->1.3
502 b/c:1.3->1.4(DEAD)
502 b/c:1.3->1.4(DEAD)
503
503
504
504
505 $ cd ..
505 $ cd ..
506
506
507 Test transcoding CVS log messages (issue5597)
507 Test transcoding CVS log messages (issue5597)
508 =============================================
508 =============================================
509
509
510 To emulate commit messages in (non-ascii) multiple encodings portably,
510 To emulate commit messages in (non-ascii) multiple encodings portably,
511 this test scenario writes CVS history file (*,v file) directly via
511 this test scenario writes CVS history file (*,v file) directly via
512 python code.
512 python code.
513
513
514 Commit messages of version 1.2 - 1.4 use u3042 in 3 encodings below.
514 Commit messages of version 1.2 - 1.4 use u3042 in 3 encodings below.
515
515
516 |encoding |byte sequence | decodable as: |
516 |encoding |byte sequence | decodable as: |
517 | | | utf-8 euc-jp cp932 |
517 | | | utf-8 euc-jp cp932 |
518 +----------+--------------+--------------------+
518 +----------+--------------+--------------------+
519 |utf-8 |\xe3\x81\x82 | o x x |
519 |utf-8 |\xe3\x81\x82 | o x x |
520 |euc-jp |\xa4\xa2 | x o o |
520 |euc-jp |\xa4\xa2 | x o o |
521 |cp932 |\x82\xa0 | x x o |
521 |cp932 |\x82\xa0 | x x o |
522
522
523 $ mkdir -p cvsrepo/transcoding
523 $ mkdir -p cvsrepo/transcoding
524 $ python <<EOF
524 $ python <<EOF
525 > fp = open('cvsrepo/transcoding/file,v', 'wb')
525 > fp = open('cvsrepo/transcoding/file,v', 'wb')
526 > fp.write((b'''
526 > fp.write((b'''
527 > head 1.4;
527 > head 1.4;
528 > access;
528 > access;
529 > symbols
529 > symbols
530 > start:1.1.1.1 INITIAL:1.1.1;
530 > start:1.1.1.1 INITIAL:1.1.1;
531 > locks; strict;
531 > locks; strict;
532 > comment @# @;
532 > comment @# @;
533 >
533 >
534 >
534 >
535 > 1.4
535 > 1.4
536 > date 2017.07.10.00.00.04; author nobody; state Exp;
536 > date 2017.07.10.00.00.04; author nobody; state Exp;
537 > branches;
537 > branches;
538 > next 1.3;
538 > next 1.3;
539 > commitid 10059635D016A510FFA;
539 > commitid 10059635D016A510FFA;
540 >
540 >
541 > 1.3
541 > 1.3
542 > date 2017.07.10.00.00.03; author nobody; state Exp;
542 > date 2017.07.10.00.00.03; author nobody; state Exp;
543 > branches;
543 > branches;
544 > next 1.2;
544 > next 1.2;
545 > commitid 10059635CFF6A4FF34E;
545 > commitid 10059635CFF6A4FF34E;
546 >
546 >
547 > 1.2
547 > 1.2
548 > date 2017.07.10.00.00.02; author nobody; state Exp;
548 > date 2017.07.10.00.00.02; author nobody; state Exp;
549 > branches;
549 > branches;
550 > next 1.1;
550 > next 1.1;
551 > commitid 10059635CFD6A4D5095;
551 > commitid 10059635CFD6A4D5095;
552 >
552 >
553 > 1.1
553 > 1.1
554 > date 2017.07.10.00.00.01; author nobody; state Exp;
554 > date 2017.07.10.00.00.01; author nobody; state Exp;
555 > branches
555 > branches
556 > 1.1.1.1;
556 > 1.1.1.1;
557 > next ;
557 > next ;
558 > commitid 10059635CFB6A4A3C33;
558 > commitid 10059635CFB6A4A3C33;
559 >
559 >
560 > 1.1.1.1
560 > 1.1.1.1
561 > date 2017.07.10.00.00.01; author nobody; state Exp;
561 > date 2017.07.10.00.00.01; author nobody; state Exp;
562 > branches;
562 > branches;
563 > next ;
563 > next ;
564 > commitid 10059635CFB6A4A3C33;
564 > commitid 10059635CFB6A4A3C33;
565 >
565 >
566 >
566 >
567 > desc
567 > desc
568 > @@
568 > @@
569 >
569 >
570 >
570 >
571 > 1.4
571 > 1.4
572 > log
572 > log
573 > @''' + u'\u3042'.encode('cp932') + b''' (cp932)
573 > @''' + u'\u3042'.encode('cp932') + b''' (cp932)
574 > @
574 > @
575 > text
575 > text
576 > @1
576 > @1
577 > 2
577 > 2
578 > 3
578 > 3
579 > 4
579 > 4
580 > @
580 > @
581 >
581 >
582 >
582 >
583 > 1.3
583 > 1.3
584 > log
584 > log
585 > @''' + u'\u3042'.encode('euc-jp') + b''' (euc-jp)
585 > @''' + u'\u3042'.encode('euc-jp') + b''' (euc-jp)
586 > @
586 > @
587 > text
587 > text
588 > @d4 1
588 > @d4 1
589 > @
589 > @
590 >
590 >
591 >
591 >
592 > 1.2
592 > 1.2
593 > log
593 > log
594 > @''' + u'\u3042'.encode('utf-8') + b''' (utf-8)
594 > @''' + u'\u3042'.encode('utf-8') + b''' (utf-8)
595 > @
595 > @
596 > text
596 > text
597 > @d3 1
597 > @d3 1
598 > @
598 > @
599 >
599 >
600 >
600 >
601 > 1.1
601 > 1.1
602 > log
602 > log
603 > @Initial revision
603 > @Initial revision
604 > @
604 > @
605 > text
605 > text
606 > @d2 1
606 > @d2 1
607 > @
607 > @
608 >
608 >
609 >
609 >
610 > 1.1.1.1
610 > 1.1.1.1
611 > log
611 > log
612 > @import
612 > @import
613 > @
613 > @
614 > text
614 > text
615 > @@
615 > @@
616 > ''').lstrip())
616 > ''').lstrip())
617 > EOF
617 > EOF
618
618
619 $ cvscall -q checkout transcoding
619 $ cvscall -q checkout transcoding
620 U transcoding/file
620 U transcoding/file
621
621
622 Test converting in normal case
622 Test converting in normal case
623 ------------------------------
623 ------------------------------
624
624
625 (filtering by grep in order to check only form of debug messages)
625 (filtering by grep in order to check only form of debug messages)
626
626
627 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp,cp932 -q --debug transcoding transcoding-hg | grep 'transcoding by'
627 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp,cp932 -q --debug transcoding transcoding-hg | grep 'transcoding by'
628 transcoding by utf-8: 1.1 of file
628 transcoding by utf-8: 1.1 of file
629 transcoding by utf-8: 1.1.1.1 of file
629 transcoding by utf-8: 1.1.1.1 of file
630 transcoding by utf-8: 1.2 of file
630 transcoding by utf-8: 1.2 of file
631 transcoding by euc-jp: 1.3 of file
631 transcoding by euc-jp: 1.3 of file
632 transcoding by cp932: 1.4 of file
632 transcoding by cp932: 1.4 of file
633 $ hg -R transcoding-hg --encoding utf-8 log -T "{rev}: {desc}\n"
633 $ hg -R transcoding-hg --encoding utf-8 log -T "{rev}: {desc}\n"
634 5: update tags
634 5: update tags
635 4: import
635 4: import
636 3: \xe3\x81\x82 (cp932) (esc)
636 3: \xe3\x81\x82 (cp932) (esc)
637 2: \xe3\x81\x82 (euc-jp) (esc)
637 2: \xe3\x81\x82 (euc-jp) (esc)
638 1: \xe3\x81\x82 (utf-8) (esc)
638 1: \xe3\x81\x82 (utf-8) (esc)
639 0: Initial revision
639 0: Initial revision
640 $ rm -rf transcoding-hg
640 $ rm -rf transcoding-hg
641
641
642 Test converting in error cases
642 Test converting in error cases
643 ------------------------------
643 ------------------------------
644
644
645 unknown encoding in convert.cvsps.logencoding
645 unknown encoding in convert.cvsps.logencoding
646
646
647 $ hg convert --config convert.cvsps.logencoding=foobar -q transcoding transcoding-hg
647 $ hg convert --config convert.cvsps.logencoding=foobar -q transcoding transcoding-hg
648 abort: unknown encoding: foobar
648 abort: unknown encoding: foobar
649 (check convert.cvsps.logencoding configuration)
649 (check convert.cvsps.logencoding configuration)
650 [255]
650 [255]
651 $ rm -rf transcoding-hg
651 $ rm -rf transcoding-hg
652
652
653 no acceptable encoding in convert.cvsps.logencoding
653 no acceptable encoding in convert.cvsps.logencoding
654
654
655 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp -q transcoding transcoding-hg
655 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp -q transcoding transcoding-hg
656 abort: no encoding can transcode CVS log message for 1.4 of file
656 abort: no encoding can transcode CVS log message for 1.4 of file
657 (check convert.cvsps.logencoding configuration)
657 (check convert.cvsps.logencoding configuration)
658 [255]
658 [255]
659 $ rm -rf transcoding-hg
659 $ rm -rf transcoding-hg
@@ -1,1889 +1,1889 b''
1 Test basic extension support
1 Test basic extension support
2 $ cat > unflush.py <<EOF
2 $ cat > unflush.py <<EOF
3 > import sys
3 > import sys
4 > from mercurial import pycompat
4 > from mercurial import pycompat
5 > if pycompat.ispy3:
5 > if pycompat.ispy3:
6 > # no changes required
6 > # no changes required
7 > sys.exit(0)
7 > sys.exit(0)
8 > with open(sys.argv[1], 'rb') as f:
8 > with open(sys.argv[1], 'rb') as f:
9 > data = f.read()
9 > data = f.read()
10 > with open(sys.argv[1], 'wb') as f:
10 > with open(sys.argv[1], 'wb') as f:
11 > f.write(data.replace(b', flush=True', b''))
11 > f.write(data.replace(b', flush=True', b''))
12 > EOF
12 > EOF
13
13
14 $ cat > foobar.py <<EOF
14 $ cat > foobar.py <<EOF
15 > import os
15 > import os
16 > from mercurial import commands, exthelper, registrar
16 > from mercurial import commands, exthelper, registrar
17 >
17 >
18 > eh = exthelper.exthelper()
18 > eh = exthelper.exthelper()
19 > eh.configitem(b'tests', b'foo', default=b"Foo")
19 > eh.configitem(b'tests', b'foo', default=b"Foo")
20 >
20 >
21 > uisetup = eh.finaluisetup
21 > uisetup = eh.finaluisetup
22 > uipopulate = eh.finaluipopulate
22 > uipopulate = eh.finaluipopulate
23 > reposetup = eh.finalreposetup
23 > reposetup = eh.finalreposetup
24 > cmdtable = eh.cmdtable
24 > cmdtable = eh.cmdtable
25 > configtable = eh.configtable
25 > configtable = eh.configtable
26 >
26 >
27 > @eh.uisetup
27 > @eh.uisetup
28 > def _uisetup(ui):
28 > def _uisetup(ui):
29 > ui.debug(b"uisetup called [debug]\\n")
29 > ui.debug(b"uisetup called [debug]\\n")
30 > ui.write(b"uisetup called\\n")
30 > ui.write(b"uisetup called\\n")
31 > ui.status(b"uisetup called [status]\\n")
31 > ui.status(b"uisetup called [status]\\n")
32 > ui.flush()
32 > ui.flush()
33 > @eh.uipopulate
33 > @eh.uipopulate
34 > def _uipopulate(ui):
34 > def _uipopulate(ui):
35 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1
35 > ui._populatecnt = getattr(ui, "_populatecnt", 0) + 1
36 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt)
36 > ui.write(b"uipopulate called (%d times)\n" % ui._populatecnt)
37 > @eh.reposetup
37 > @eh.reposetup
38 > def _reposetup(ui, repo):
38 > def _reposetup(ui, repo):
39 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
39 > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root))
40 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
40 > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!"))
41 > ui.flush()
41 > ui.flush()
42 > @eh.command(b'foo', [], b'hg foo')
42 > @eh.command(b'foo', [], b'hg foo')
43 > def foo(ui, *args, **kwargs):
43 > def foo(ui, *args, **kwargs):
44 > foo = ui.config(b'tests', b'foo')
44 > foo = ui.config(b'tests', b'foo')
45 > ui.write(foo)
45 > ui.write(foo)
46 > ui.write(b"\\n")
46 > ui.write(b"\\n")
47 > @eh.command(b'bar', [], b'hg bar', norepo=True)
47 > @eh.command(b'bar', [], b'hg bar', norepo=True)
48 > def bar(ui, *args, **kwargs):
48 > def bar(ui, *args, **kwargs):
49 > ui.write(b"Bar\\n")
49 > ui.write(b"Bar\\n")
50 > EOF
50 > EOF
51 $ abspath=`pwd`/foobar.py
51 $ abspath=`pwd`/foobar.py
52
52
53 $ mkdir barfoo
53 $ mkdir barfoo
54 $ cp foobar.py barfoo/__init__.py
54 $ cp foobar.py barfoo/__init__.py
55 $ barfoopath=`pwd`/barfoo
55 $ barfoopath=`pwd`/barfoo
56
56
57 $ hg init a
57 $ hg init a
58 $ cd a
58 $ cd a
59 $ echo foo > file
59 $ echo foo > file
60 $ hg add file
60 $ hg add file
61 $ hg commit -m 'add file'
61 $ hg commit -m 'add file'
62
62
63 $ echo '[extensions]' >> $HGRCPATH
63 $ echo '[extensions]' >> $HGRCPATH
64 $ echo "foobar = $abspath" >> $HGRCPATH
64 $ echo "foobar = $abspath" >> $HGRCPATH
65 $ hg foo
65 $ hg foo
66 uisetup called
66 uisetup called
67 uisetup called [status]
67 uisetup called [status]
68 uipopulate called (1 times)
68 uipopulate called (1 times)
69 uipopulate called (1 times)
69 uipopulate called (1 times)
70 uipopulate called (1 times)
70 uipopulate called (1 times)
71 reposetup called for a
71 reposetup called for a
72 ui == repo.ui
72 ui == repo.ui
73 uipopulate called (1 times) (chg !)
73 uipopulate called (1 times) (chg !)
74 uipopulate called (1 times) (chg !)
74 uipopulate called (1 times) (chg !)
75 uipopulate called (1 times) (chg !)
75 uipopulate called (1 times) (chg !)
76 uipopulate called (1 times) (chg !)
76 uipopulate called (1 times) (chg !)
77 uipopulate called (1 times) (chg !)
77 uipopulate called (1 times) (chg !)
78 reposetup called for a (chg !)
78 reposetup called for a (chg !)
79 ui == repo.ui (chg !)
79 ui == repo.ui (chg !)
80 Foo
80 Foo
81 $ hg foo --quiet
81 $ hg foo --quiet
82 uisetup called (no-chg !)
82 uisetup called (no-chg !)
83 uipopulate called (1 times)
83 uipopulate called (1 times)
84 uipopulate called (1 times)
84 uipopulate called (1 times)
85 uipopulate called (1 times) (chg !)
85 uipopulate called (1 times) (chg !)
86 uipopulate called (1 times) (chg !)
86 uipopulate called (1 times) (chg !)
87 uipopulate called (1 times) (chg !)
87 uipopulate called (1 times) (chg !)
88 reposetup called for a (chg !)
88 reposetup called for a (chg !)
89 ui == repo.ui
89 ui == repo.ui
90 Foo
90 Foo
91 $ hg foo --debug
91 $ hg foo --debug
92 uisetup called [debug] (no-chg !)
92 uisetup called [debug] (no-chg !)
93 uisetup called (no-chg !)
93 uisetup called (no-chg !)
94 uisetup called [status] (no-chg !)
94 uisetup called [status] (no-chg !)
95 uipopulate called (1 times)
95 uipopulate called (1 times)
96 uipopulate called (1 times)
96 uipopulate called (1 times)
97 uipopulate called (1 times) (chg !)
97 uipopulate called (1 times) (chg !)
98 uipopulate called (1 times) (chg !)
98 uipopulate called (1 times) (chg !)
99 uipopulate called (1 times) (chg !)
99 uipopulate called (1 times) (chg !)
100 reposetup called for a (chg !)
100 reposetup called for a (chg !)
101 ui == repo.ui
101 ui == repo.ui
102 Foo
102 Foo
103
103
104 $ cd ..
104 $ cd ..
105 $ hg clone a b
105 $ hg clone a b
106 uisetup called (no-chg !)
106 uisetup called (no-chg !)
107 uisetup called [status] (no-chg !)
107 uisetup called [status] (no-chg !)
108 uipopulate called (1 times)
108 uipopulate called (1 times)
109 uipopulate called (1 times) (chg !)
109 uipopulate called (1 times) (chg !)
110 uipopulate called (1 times) (chg !)
110 uipopulate called (1 times) (chg !)
111 reposetup called for a
111 reposetup called for a
112 ui == repo.ui
112 ui == repo.ui
113 uipopulate called (1 times)
113 uipopulate called (1 times)
114 reposetup called for b
114 reposetup called for b
115 ui == repo.ui
115 ui == repo.ui
116 updating to branch default
116 updating to branch default
117 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
117 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
118
118
119 $ hg bar
119 $ hg bar
120 uisetup called (no-chg !)
120 uisetup called (no-chg !)
121 uisetup called [status] (no-chg !)
121 uisetup called [status] (no-chg !)
122 uipopulate called (1 times)
122 uipopulate called (1 times)
123 uipopulate called (1 times) (chg !)
123 uipopulate called (1 times) (chg !)
124 Bar
124 Bar
125 $ echo 'foobar = !' >> $HGRCPATH
125 $ echo 'foobar = !' >> $HGRCPATH
126
126
127 module/__init__.py-style
127 module/__init__.py-style
128
128
129 $ echo "barfoo = $barfoopath" >> $HGRCPATH
129 $ echo "barfoo = $barfoopath" >> $HGRCPATH
130 $ cd a
130 $ cd a
131 $ hg foo
131 $ hg foo
132 uisetup called
132 uisetup called
133 uisetup called [status]
133 uisetup called [status]
134 uipopulate called (1 times)
134 uipopulate called (1 times)
135 uipopulate called (1 times)
135 uipopulate called (1 times)
136 uipopulate called (1 times)
136 uipopulate called (1 times)
137 reposetup called for a
137 reposetup called for a
138 ui == repo.ui
138 ui == repo.ui
139 uipopulate called (1 times) (chg !)
139 uipopulate called (1 times) (chg !)
140 uipopulate called (1 times) (chg !)
140 uipopulate called (1 times) (chg !)
141 uipopulate called (1 times) (chg !)
141 uipopulate called (1 times) (chg !)
142 uipopulate called (1 times) (chg !)
142 uipopulate called (1 times) (chg !)
143 uipopulate called (1 times) (chg !)
143 uipopulate called (1 times) (chg !)
144 reposetup called for a (chg !)
144 reposetup called for a (chg !)
145 ui == repo.ui (chg !)
145 ui == repo.ui (chg !)
146 Foo
146 Foo
147 $ echo 'barfoo = !' >> $HGRCPATH
147 $ echo 'barfoo = !' >> $HGRCPATH
148
148
149 Check that extensions are loaded in phases:
149 Check that extensions are loaded in phases:
150
150
151 $ cat > foo.py <<EOF
151 $ cat > foo.py <<EOF
152 > from __future__ import print_function
152 > from __future__ import print_function
153 > import os
153 > import os
154 > from mercurial import exthelper
154 > from mercurial import exthelper
155 > name = os.path.basename(__file__).rsplit('.', 1)[0]
155 > name = os.path.basename(__file__).rsplit('.', 1)[0]
156 > print("1) %s imported" % name, flush=True)
156 > print("1) %s imported" % name, flush=True)
157 > eh = exthelper.exthelper()
157 > eh = exthelper.exthelper()
158 > @eh.uisetup
158 > @eh.uisetup
159 > def _uisetup(ui):
159 > def _uisetup(ui):
160 > print("2) %s uisetup" % name, flush=True)
160 > print("2) %s uisetup" % name, flush=True)
161 > @eh.extsetup
161 > @eh.extsetup
162 > def _extsetup(ui):
162 > def _extsetup(ui):
163 > print("3) %s extsetup" % name, flush=True)
163 > print("3) %s extsetup" % name, flush=True)
164 > @eh.uipopulate
164 > @eh.uipopulate
165 > def _uipopulate(ui):
165 > def _uipopulate(ui):
166 > print("4) %s uipopulate" % name, flush=True)
166 > print("4) %s uipopulate" % name, flush=True)
167 > @eh.reposetup
167 > @eh.reposetup
168 > def _reposetup(ui, repo):
168 > def _reposetup(ui, repo):
169 > print("5) %s reposetup" % name, flush=True)
169 > print("5) %s reposetup" % name, flush=True)
170 >
170 >
171 > extsetup = eh.finalextsetup
171 > extsetup = eh.finalextsetup
172 > reposetup = eh.finalreposetup
172 > reposetup = eh.finalreposetup
173 > uipopulate = eh.finaluipopulate
173 > uipopulate = eh.finaluipopulate
174 > uisetup = eh.finaluisetup
174 > uisetup = eh.finaluisetup
175 > revsetpredicate = eh.revsetpredicate
175 > revsetpredicate = eh.revsetpredicate
176 >
176 >
177 > bytesname = name.encode('utf-8')
177 > bytesname = name.encode('utf-8')
178 > # custom predicate to check registration of functions at loading
178 > # custom predicate to check registration of functions at loading
179 > from mercurial import (
179 > from mercurial import (
180 > smartset,
180 > smartset,
181 > )
181 > )
182 > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb
182 > @eh.revsetpredicate(bytesname, safe=True) # safe=True for query via hgweb
183 > def custompredicate(repo, subset, x):
183 > def custompredicate(repo, subset, x):
184 > return smartset.baseset([r for r in subset if r in {0}])
184 > return smartset.baseset([r for r in subset if r in {0}])
185 > EOF
185 > EOF
186 $ "$PYTHON" $TESTTMP/unflush.py foo.py
186 $ "$PYTHON" $TESTTMP/unflush.py foo.py
187
187
188 $ cp foo.py bar.py
188 $ cp foo.py bar.py
189 $ echo 'foo = foo.py' >> $HGRCPATH
189 $ echo 'foo = foo.py' >> $HGRCPATH
190 $ echo 'bar = bar.py' >> $HGRCPATH
190 $ echo 'bar = bar.py' >> $HGRCPATH
191
191
192 Check normal command's load order of extensions and registration of functions
192 Check normal command's load order of extensions and registration of functions
193
193
194 $ hg log -r "foo() and bar()" -q
194 $ hg log -r "foo() and bar()" -q
195 1) foo imported
195 1) foo imported
196 1) bar imported
196 1) bar imported
197 2) foo uisetup
197 2) foo uisetup
198 2) bar uisetup
198 2) bar uisetup
199 3) foo extsetup
199 3) foo extsetup
200 3) bar extsetup
200 3) bar extsetup
201 4) foo uipopulate
201 4) foo uipopulate
202 4) bar uipopulate
202 4) bar uipopulate
203 4) foo uipopulate
203 4) foo uipopulate
204 4) bar uipopulate
204 4) bar uipopulate
205 4) foo uipopulate
205 4) foo uipopulate
206 4) bar uipopulate
206 4) bar uipopulate
207 5) foo reposetup
207 5) foo reposetup
208 5) bar reposetup
208 5) bar reposetup
209 0:c24b9ac61126
209 0:c24b9ac61126
210
210
211 Check hgweb's load order of extensions and registration of functions
211 Check hgweb's load order of extensions and registration of functions
212
212
213 $ cat > hgweb.cgi <<EOF
213 $ cat > hgweb.cgi <<EOF
214 > #!$PYTHON
214 > #!$PYTHON
215 > from mercurial import demandimport; demandimport.enable()
215 > from mercurial import demandimport; demandimport.enable()
216 > from mercurial.hgweb import hgweb
216 > from mercurial.hgweb import hgweb
217 > from mercurial.hgweb import wsgicgi
217 > from mercurial.hgweb import wsgicgi
218 > application = hgweb(b'.', b'test repo')
218 > application = hgweb(b'.', b'test repo')
219 > wsgicgi.launch(application)
219 > wsgicgi.launch(application)
220 > EOF
220 > EOF
221 $ . "$TESTDIR/cgienv"
221 $ . "$TESTDIR/cgienv"
222
222
223 $ PATH_INFO='/' SCRIPT_NAME='' "$PYTHON" hgweb.cgi \
223 $ PATH_INFO='/' SCRIPT_NAME='' "$PYTHON" hgweb.cgi \
224 > | grep '^[0-9]) ' # ignores HTML output
224 > | grep '^[0-9]) ' # ignores HTML output
225 1) foo imported
225 1) foo imported
226 1) bar imported
226 1) bar imported
227 2) foo uisetup
227 2) foo uisetup
228 2) bar uisetup
228 2) bar uisetup
229 3) foo extsetup
229 3) foo extsetup
230 3) bar extsetup
230 3) bar extsetup
231 4) foo uipopulate
231 4) foo uipopulate
232 4) bar uipopulate
232 4) bar uipopulate
233 4) foo uipopulate
233 4) foo uipopulate
234 4) bar uipopulate
234 4) bar uipopulate
235 5) foo reposetup
235 5) foo reposetup
236 5) bar reposetup
236 5) bar reposetup
237
237
238 (check that revset predicate foo() and bar() are available)
238 (check that revset predicate foo() and bar() are available)
239
239
240 #if msys
240 #if msys
241 $ PATH_INFO='//shortlog'
241 $ PATH_INFO='//shortlog'
242 #else
242 #else
243 $ PATH_INFO='/shortlog'
243 $ PATH_INFO='/shortlog'
244 #endif
244 #endif
245 $ export PATH_INFO
245 $ export PATH_INFO
246 $ SCRIPT_NAME='' QUERY_STRING='rev=foo() and bar()' "$PYTHON" hgweb.cgi \
246 $ SCRIPT_NAME='' QUERY_STRING='rev=foo() and bar()' "$PYTHON" hgweb.cgi \
247 > | grep '<a href="/rev/[0-9a-z]*">'
247 > | grep '<a href="/rev/[0-9a-z]*">'
248 <a href="/rev/c24b9ac61126">add file</a>
248 <a href="/rev/c24b9ac61126">add file</a>
249
249
250 $ echo 'foo = !' >> $HGRCPATH
250 $ echo 'foo = !' >> $HGRCPATH
251 $ echo 'bar = !' >> $HGRCPATH
251 $ echo 'bar = !' >> $HGRCPATH
252
252
253 Check "from __future__ import absolute_import" support for external libraries
253 Check "from __future__ import absolute_import" support for external libraries
254
254
255 (import-checker.py reports issues for some of heredoc python code
255 (import-checker.py reports issues for some of heredoc python code
256 fragments below, because import-checker.py does not know test specific
256 fragments below, because import-checker.py does not know test specific
257 package hierarchy. NO_CHECK_* should be used as a limit mark of
257 package hierarchy. NO_CHECK_* should be used as a limit mark of
258 heredoc, in order to make import-checker.py ignore them. For
258 heredoc, in order to make import-checker.py ignore them. For
259 simplicity, all python code fragments below are generated with such
259 simplicity, all python code fragments below are generated with such
260 limit mark, regardless of importing module or not.)
260 limit mark, regardless of importing module or not.)
261
261
262 #if windows
262 #if windows
263 $ PATHSEP=";"
263 $ PATHSEP=";"
264 #else
264 #else
265 $ PATHSEP=":"
265 $ PATHSEP=":"
266 #endif
266 #endif
267 $ export PATHSEP
267 $ export PATHSEP
268
268
269 $ mkdir $TESTTMP/libroot
269 $ mkdir $TESTTMP/libroot
270 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
270 $ echo "s = 'libroot/ambig.py'" > $TESTTMP/libroot/ambig.py
271 $ mkdir $TESTTMP/libroot/mod
271 $ mkdir $TESTTMP/libroot/mod
272 $ touch $TESTTMP/libroot/mod/__init__.py
272 $ touch $TESTTMP/libroot/mod/__init__.py
273 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
273 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
274
274
275 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
275 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
276 > from __future__ import absolute_import, print_function
276 > from __future__ import absolute_import, print_function
277 > import ambig # should load "libroot/ambig.py"
277 > import ambig # should load "libroot/ambig.py"
278 > s = ambig.s
278 > s = ambig.s
279 > NO_CHECK_EOF
279 > NO_CHECK_EOF
280 $ cat > loadabs.py <<NO_CHECK_EOF
280 $ cat > loadabs.py <<NO_CHECK_EOF
281 > import mod.ambigabs as ambigabs
281 > import mod.ambigabs as ambigabs
282 > def extsetup(ui):
282 > def extsetup(ui):
283 > print('ambigabs.s=%s' % ambigabs.s, flush=True)
283 > print('ambigabs.s=%s' % ambigabs.s, flush=True)
284 > NO_CHECK_EOF
284 > NO_CHECK_EOF
285 $ "$PYTHON" $TESTTMP/unflush.py loadabs.py
285 $ "$PYTHON" $TESTTMP/unflush.py loadabs.py
286 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
286 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadabs=loadabs.py root)
287 ambigabs.s=libroot/ambig.py
287 ambigabs.s=libroot/ambig.py
288 $TESTTMP/a
288 $TESTTMP/a
289
289
290 #if no-py3
290 #if no-py3
291 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
291 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
292 > from __future__ import print_function
292 > from __future__ import print_function
293 > import ambig # should load "libroot/mod/ambig.py"
293 > import ambig # should load "libroot/mod/ambig.py"
294 > s = ambig.s
294 > s = ambig.s
295 > NO_CHECK_EOF
295 > NO_CHECK_EOF
296 $ cat > loadrel.py <<NO_CHECK_EOF
296 $ cat > loadrel.py <<NO_CHECK_EOF
297 > import mod.ambigrel as ambigrel
297 > import mod.ambigrel as ambigrel
298 > def extsetup(ui):
298 > def extsetup(ui):
299 > print('ambigrel.s=%s' % ambigrel.s, flush=True)
299 > print('ambigrel.s=%s' % ambigrel.s, flush=True)
300 > NO_CHECK_EOF
300 > NO_CHECK_EOF
301 $ "$PYTHON" $TESTTMP/unflush.py loadrel.py
301 $ "$PYTHON" $TESTTMP/unflush.py loadrel.py
302 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
302 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}/libroot; hg --config extensions.loadrel=loadrel.py root)
303 ambigrel.s=libroot/mod/ambig.py
303 ambigrel.s=libroot/mod/ambig.py
304 $TESTTMP/a
304 $TESTTMP/a
305 #endif
305 #endif
306
306
307 Check absolute/relative import of extension specific modules
307 Check absolute/relative import of extension specific modules
308
308
309 $ mkdir $TESTTMP/extroot
309 $ mkdir $TESTTMP/extroot
310 $ cat > $TESTTMP/extroot/bar.py <<NO_CHECK_EOF
310 $ cat > $TESTTMP/extroot/bar.py <<NO_CHECK_EOF
311 > s = b'this is extroot.bar'
311 > s = b'this is extroot.bar'
312 > NO_CHECK_EOF
312 > NO_CHECK_EOF
313 $ mkdir $TESTTMP/extroot/sub1
313 $ mkdir $TESTTMP/extroot/sub1
314 $ cat > $TESTTMP/extroot/sub1/__init__.py <<NO_CHECK_EOF
314 $ cat > $TESTTMP/extroot/sub1/__init__.py <<NO_CHECK_EOF
315 > s = b'this is extroot.sub1.__init__'
315 > s = b'this is extroot.sub1.__init__'
316 > NO_CHECK_EOF
316 > NO_CHECK_EOF
317 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
317 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
318 > s = b'this is extroot.sub1.baz'
318 > s = b'this is extroot.sub1.baz'
319 > NO_CHECK_EOF
319 > NO_CHECK_EOF
320 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
320 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
321 > from __future__ import absolute_import
321 > from __future__ import absolute_import
322 > s = b'this is extroot.__init__'
322 > s = b'this is extroot.__init__'
323 > from . import foo
323 > from . import foo
324 > def extsetup(ui):
324 > def extsetup(ui):
325 > ui.write(b'(extroot) ', foo.func(), b'\n')
325 > ui.write(b'(extroot) ', foo.func(), b'\n')
326 > ui.flush()
326 > ui.flush()
327 > NO_CHECK_EOF
327 > NO_CHECK_EOF
328
328
329 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
329 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
330 > # test absolute import
330 > # test absolute import
331 > buf = []
331 > buf = []
332 > def func():
332 > def func():
333 > # "not locals" case
333 > # "not locals" case
334 > import extroot.bar
334 > import extroot.bar
335 > buf.append(b'import extroot.bar in func(): %s' % extroot.bar.s)
335 > buf.append(b'import extroot.bar in func(): %s' % extroot.bar.s)
336 > return b'\n(extroot) '.join(buf)
336 > return b'\n(extroot) '.join(buf)
337 > # b"fromlist == ('*',)" case
337 > # b"fromlist == ('*',)" case
338 > from extroot.bar import *
338 > from extroot.bar import *
339 > buf.append(b'from extroot.bar import *: %s' % s)
339 > buf.append(b'from extroot.bar import *: %s' % s)
340 > # "not fromlist" and "if '.' in name" case
340 > # "not fromlist" and "if '.' in name" case
341 > import extroot.sub1.baz
341 > import extroot.sub1.baz
342 > buf.append(b'import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
342 > buf.append(b'import extroot.sub1.baz: %s' % extroot.sub1.baz.s)
343 > # "not fromlist" and NOT "if '.' in name" case
343 > # "not fromlist" and NOT "if '.' in name" case
344 > import extroot
344 > import extroot
345 > buf.append(b'import extroot: %s' % extroot.s)
345 > buf.append(b'import extroot: %s' % extroot.s)
346 > # NOT "not fromlist" and NOT "level != -1" case
346 > # NOT "not fromlist" and NOT "level != -1" case
347 > from extroot.bar import s
347 > from extroot.bar import s
348 > buf.append(b'from extroot.bar import s: %s' % s)
348 > buf.append(b'from extroot.bar import s: %s' % s)
349 > NO_CHECK_EOF
349 > NO_CHECK_EOF
350 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
350 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.extroot=$TESTTMP/extroot root)
351 (extroot) from extroot.bar import *: this is extroot.bar
351 (extroot) from extroot.bar import *: this is extroot.bar
352 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
352 (extroot) import extroot.sub1.baz: this is extroot.sub1.baz
353 (extroot) import extroot: this is extroot.__init__
353 (extroot) import extroot: this is extroot.__init__
354 (extroot) from extroot.bar import s: this is extroot.bar
354 (extroot) from extroot.bar import s: this is extroot.bar
355 (extroot) import extroot.bar in func(): this is extroot.bar
355 (extroot) import extroot.bar in func(): this is extroot.bar
356 $TESTTMP/a
356 $TESTTMP/a
357
357
358 #if no-py3
358 #if no-py3
359 $ rm "$TESTTMP"/extroot/foo.*
359 $ rm "$TESTTMP"/extroot/foo.*
360 $ rm -Rf "$TESTTMP/extroot/__pycache__"
360 $ rm -Rf "$TESTTMP/extroot/__pycache__"
361 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
361 $ cat > $TESTTMP/extroot/foo.py <<NO_CHECK_EOF
362 > # test relative import
362 > # test relative import
363 > buf = []
363 > buf = []
364 > def func():
364 > def func():
365 > # "not locals" case
365 > # "not locals" case
366 > import bar
366 > import bar
367 > buf.append('import bar in func(): %s' % bar.s)
367 > buf.append('import bar in func(): %s' % bar.s)
368 > return '\n(extroot) '.join(buf)
368 > return '\n(extroot) '.join(buf)
369 > # "fromlist == ('*',)" case
369 > # "fromlist == ('*',)" case
370 > from bar import *
370 > from bar import *
371 > buf.append('from bar import *: %s' % s)
371 > buf.append('from bar import *: %s' % s)
372 > # "not fromlist" and "if '.' in name" case
372 > # "not fromlist" and "if '.' in name" case
373 > import sub1.baz
373 > import sub1.baz
374 > buf.append('import sub1.baz: %s' % sub1.baz.s)
374 > buf.append('import sub1.baz: %s' % sub1.baz.s)
375 > # "not fromlist" and NOT "if '.' in name" case
375 > # "not fromlist" and NOT "if '.' in name" case
376 > import sub1
376 > import sub1
377 > buf.append('import sub1: %s' % sub1.s)
377 > buf.append('import sub1: %s' % sub1.s)
378 > # NOT "not fromlist" and NOT "level != -1" case
378 > # NOT "not fromlist" and NOT "level != -1" case
379 > from bar import s
379 > from bar import s
380 > buf.append('from bar import s: %s' % s)
380 > buf.append('from bar import s: %s' % s)
381 > NO_CHECK_EOF
381 > NO_CHECK_EOF
382 $ hg --config extensions.extroot=$TESTTMP/extroot root
382 $ hg --config extensions.extroot=$TESTTMP/extroot root
383 (extroot) from bar import *: this is extroot.bar
383 (extroot) from bar import *: this is extroot.bar
384 (extroot) import sub1.baz: this is extroot.sub1.baz
384 (extroot) import sub1.baz: this is extroot.sub1.baz
385 (extroot) import sub1: this is extroot.sub1.__init__
385 (extroot) import sub1: this is extroot.sub1.__init__
386 (extroot) from bar import s: this is extroot.bar
386 (extroot) from bar import s: this is extroot.bar
387 (extroot) import bar in func(): this is extroot.bar
387 (extroot) import bar in func(): this is extroot.bar
388 $TESTTMP/a
388 $TESTTMP/a
389 #endif
389 #endif
390
390
391 #if demandimport
391 #if demandimport
392
392
393 Examine whether module loading is delayed until actual referring, even
393 Examine whether module loading is delayed until actual referring, even
394 though module is imported with "absolute_import" feature.
394 though module is imported with "absolute_import" feature.
395
395
396 Files below in each packages are used for described purpose:
396 Files below in each packages are used for described purpose:
397
397
398 - "called": examine whether "from MODULE import ATTR" works correctly
398 - "called": examine whether "from MODULE import ATTR" works correctly
399 - "unused": examine whether loading is delayed correctly
399 - "unused": examine whether loading is delayed correctly
400 - "used": examine whether "from PACKAGE import MODULE" works correctly
400 - "used": examine whether "from PACKAGE import MODULE" works correctly
401
401
402 Package hierarchy is needed to examine whether demand importing works
402 Package hierarchy is needed to examine whether demand importing works
403 as expected for "from SUB.PACK.AGE import MODULE".
403 as expected for "from SUB.PACK.AGE import MODULE".
404
404
405 Setup "external library" to be imported with "absolute_import"
405 Setup "external library" to be imported with "absolute_import"
406 feature.
406 feature.
407
407
408 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
408 $ mkdir -p $TESTTMP/extlibroot/lsub1/lsub2
409 $ touch $TESTTMP/extlibroot/__init__.py
409 $ touch $TESTTMP/extlibroot/__init__.py
410 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
410 $ touch $TESTTMP/extlibroot/lsub1/__init__.py
411 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
411 $ touch $TESTTMP/extlibroot/lsub1/lsub2/__init__.py
412
412
413 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<NO_CHECK_EOF
413 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/called.py <<NO_CHECK_EOF
414 > def func():
414 > def func():
415 > return b"this is extlibroot.lsub1.lsub2.called.func()"
415 > return b"this is extlibroot.lsub1.lsub2.called.func()"
416 > NO_CHECK_EOF
416 > NO_CHECK_EOF
417 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<NO_CHECK_EOF
417 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/unused.py <<NO_CHECK_EOF
418 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
418 > raise Exception("extlibroot.lsub1.lsub2.unused is loaded unintentionally")
419 > NO_CHECK_EOF
419 > NO_CHECK_EOF
420 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<NO_CHECK_EOF
420 $ cat > $TESTTMP/extlibroot/lsub1/lsub2/used.py <<NO_CHECK_EOF
421 > detail = b"this is extlibroot.lsub1.lsub2.used"
421 > detail = b"this is extlibroot.lsub1.lsub2.used"
422 > NO_CHECK_EOF
422 > NO_CHECK_EOF
423
423
424 Setup sub-package of "external library", which causes instantiation of
424 Setup sub-package of "external library", which causes instantiation of
425 demandmod in "recurse down the module chain" code path. Relative
425 demandmod in "recurse down the module chain" code path. Relative
426 importing with "absolute_import" feature isn't tested, because "level
426 importing with "absolute_import" feature isn't tested, because "level
427 >=1 " doesn't cause instantiation of demandmod.
427 >=1 " doesn't cause instantiation of demandmod.
428
428
429 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
429 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
430 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
430 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
431 > detail = b"this is extlibroot.recursedown.abs.used"
431 > detail = b"this is extlibroot.recursedown.abs.used"
432 > NO_CHECK_EOF
432 > NO_CHECK_EOF
433 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
433 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
434 > from __future__ import absolute_import
434 > from __future__ import absolute_import
435 > from extlibroot.recursedown.abs.used import detail
435 > from extlibroot.recursedown.abs.used import detail
436 > NO_CHECK_EOF
436 > NO_CHECK_EOF
437
437
438 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
438 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
439 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
439 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
440 > detail = b"this is extlibroot.recursedown.legacy.used"
440 > detail = b"this is extlibroot.recursedown.legacy.used"
441 > NO_CHECK_EOF
441 > NO_CHECK_EOF
442 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<NO_CHECK_EOF
442 $ cat > $TESTTMP/extlibroot/recursedown/legacy/__init__.py <<NO_CHECK_EOF
443 > # legacy style (level == -1) import
443 > # legacy style (level == -1) import
444 > from extlibroot.recursedown.legacy.used import detail
444 > from extlibroot.recursedown.legacy.used import detail
445 > NO_CHECK_EOF
445 > NO_CHECK_EOF
446
446
447 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
447 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
448 > from __future__ import absolute_import
448 > from __future__ import absolute_import
449 > from extlibroot.recursedown.abs import detail as absdetail
449 > from extlibroot.recursedown.abs import detail as absdetail
450 > from .legacy import detail as legacydetail
450 > from .legacy import detail as legacydetail
451 > NO_CHECK_EOF
451 > NO_CHECK_EOF
452
452
453 Setup package that re-exports an attribute of its submodule as the same
453 Setup package that re-exports an attribute of its submodule as the same
454 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
454 name. This leaves 'shadowing.used' pointing to 'used.detail', but still
455 the submodule 'used' should be somehow accessible. (issue5617)
455 the submodule 'used' should be somehow accessible. (issue5617)
456
456
457 $ mkdir -p $TESTTMP/extlibroot/shadowing
457 $ mkdir -p $TESTTMP/extlibroot/shadowing
458 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
458 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
459 > detail = b"this is extlibroot.shadowing.used"
459 > detail = b"this is extlibroot.shadowing.used"
460 > NO_CHECK_EOF
460 > NO_CHECK_EOF
461 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
461 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
462 > from __future__ import absolute_import
462 > from __future__ import absolute_import
463 > from extlibroot.shadowing.used import detail
463 > from extlibroot.shadowing.used import detail
464 > NO_CHECK_EOF
464 > NO_CHECK_EOF
465 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
465 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
466 > from __future__ import absolute_import
466 > from __future__ import absolute_import
467 > from .used import detail as used
467 > from .used import detail as used
468 > NO_CHECK_EOF
468 > NO_CHECK_EOF
469
469
470 Setup extension local modules to be imported with "absolute_import"
470 Setup extension local modules to be imported with "absolute_import"
471 feature.
471 feature.
472
472
473 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
473 $ mkdir -p $TESTTMP/absextroot/xsub1/xsub2
474 $ touch $TESTTMP/absextroot/xsub1/__init__.py
474 $ touch $TESTTMP/absextroot/xsub1/__init__.py
475 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
475 $ touch $TESTTMP/absextroot/xsub1/xsub2/__init__.py
476
476
477 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<NO_CHECK_EOF
477 $ cat > $TESTTMP/absextroot/xsub1/xsub2/called.py <<NO_CHECK_EOF
478 > def func():
478 > def func():
479 > return b"this is absextroot.xsub1.xsub2.called.func()"
479 > return b"this is absextroot.xsub1.xsub2.called.func()"
480 > NO_CHECK_EOF
480 > NO_CHECK_EOF
481 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<NO_CHECK_EOF
481 $ cat > $TESTTMP/absextroot/xsub1/xsub2/unused.py <<NO_CHECK_EOF
482 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
482 > raise Exception("absextroot.xsub1.xsub2.unused is loaded unintentionally")
483 > NO_CHECK_EOF
483 > NO_CHECK_EOF
484 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<NO_CHECK_EOF
484 $ cat > $TESTTMP/absextroot/xsub1/xsub2/used.py <<NO_CHECK_EOF
485 > detail = b"this is absextroot.xsub1.xsub2.used"
485 > detail = b"this is absextroot.xsub1.xsub2.used"
486 > NO_CHECK_EOF
486 > NO_CHECK_EOF
487
487
488 Setup extension local modules to examine whether demand importing
488 Setup extension local modules to examine whether demand importing
489 works as expected in "level > 1" case.
489 works as expected in "level > 1" case.
490
490
491 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
491 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
492 > detail = b"this is absextroot.relimportee"
492 > detail = b"this is absextroot.relimportee"
493 > NO_CHECK_EOF
493 > NO_CHECK_EOF
494 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
494 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
495 > from __future__ import absolute_import
495 > from __future__ import absolute_import
496 > from mercurial import pycompat
496 > from mercurial import pycompat
497 > from ... import relimportee
497 > from ... import relimportee
498 > detail = b"this relimporter imports %r" % (
498 > detail = b"this relimporter imports %r" % (
499 > pycompat.bytestr(relimportee.detail))
499 > pycompat.bytestr(relimportee.detail))
500 > NO_CHECK_EOF
500 > NO_CHECK_EOF
501
501
502 Setup modules, which actually import extension local modules at
502 Setup modules, which actually import extension local modules at
503 runtime.
503 runtime.
504
504
505 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
505 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
506 > from __future__ import absolute_import
506 > from __future__ import absolute_import
507 >
507 >
508 > # import extension local modules absolutely (level = 0)
508 > # import extension local modules absolutely (level = 0)
509 > from absextroot.xsub1.xsub2 import used, unused
509 > from absextroot.xsub1.xsub2 import used, unused
510 > from absextroot.xsub1.xsub2.called import func
510 > from absextroot.xsub1.xsub2.called import func
511 >
511 >
512 > def getresult():
512 > def getresult():
513 > result = []
513 > result = []
514 > result.append(used.detail)
514 > result.append(used.detail)
515 > result.append(func())
515 > result.append(func())
516 > return result
516 > return result
517 > NO_CHECK_EOF
517 > NO_CHECK_EOF
518
518
519 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
519 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
520 > from __future__ import absolute_import
520 > from __future__ import absolute_import
521 >
521 >
522 > # import extension local modules relatively (level == 1)
522 > # import extension local modules relatively (level == 1)
523 > from .xsub1.xsub2 import used, unused
523 > from .xsub1.xsub2 import used, unused
524 > from .xsub1.xsub2.called import func
524 > from .xsub1.xsub2.called import func
525 >
525 >
526 > # import a module, which implies "importing with level > 1"
526 > # import a module, which implies "importing with level > 1"
527 > from .xsub1.xsub2 import relimporter
527 > from .xsub1.xsub2 import relimporter
528 >
528 >
529 > def getresult():
529 > def getresult():
530 > result = []
530 > result = []
531 > result.append(used.detail)
531 > result.append(used.detail)
532 > result.append(func())
532 > result.append(func())
533 > result.append(relimporter.detail)
533 > result.append(relimporter.detail)
534 > return result
534 > return result
535 > NO_CHECK_EOF
535 > NO_CHECK_EOF
536
536
537 Setup main procedure of extension.
537 Setup main procedure of extension.
538
538
539 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
539 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
540 > from __future__ import absolute_import
540 > from __future__ import absolute_import
541 > from mercurial import registrar
541 > from mercurial import registrar
542 > cmdtable = {}
542 > cmdtable = {}
543 > command = registrar.command(cmdtable)
543 > command = registrar.command(cmdtable)
544 >
544 >
545 > # "absolute" and "relative" shouldn't be imported before actual
545 > # "absolute" and "relative" shouldn't be imported before actual
546 > # command execution, because (1) they import same modules, and (2)
546 > # command execution, because (1) they import same modules, and (2)
547 > # preceding import (= instantiate "demandmod" object instead of
547 > # preceding import (= instantiate "demandmod" object instead of
548 > # real "module" object) might hide problem of succeeding import.
548 > # real "module" object) might hide problem of succeeding import.
549 >
549 >
550 > @command(b'showabsolute', [], norepo=True)
550 > @command(b'showabsolute', [], norepo=True)
551 > def showabsolute(ui, *args, **opts):
551 > def showabsolute(ui, *args, **opts):
552 > from absextroot import absolute
552 > from absextroot import absolute
553 > ui.write(b'ABS: %s\n' % b'\nABS: '.join(absolute.getresult()))
553 > ui.write(b'ABS: %s\n' % b'\nABS: '.join(absolute.getresult()))
554 >
554 >
555 > @command(b'showrelative', [], norepo=True)
555 > @command(b'showrelative', [], norepo=True)
556 > def showrelative(ui, *args, **opts):
556 > def showrelative(ui, *args, **opts):
557 > from . import relative
557 > from . import relative
558 > ui.write(b'REL: %s\n' % b'\nREL: '.join(relative.getresult()))
558 > ui.write(b'REL: %s\n' % b'\nREL: '.join(relative.getresult()))
559 >
559 >
560 > # import modules from external library
560 > # import modules from external library
561 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
561 > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused
562 > from extlibroot.lsub1.lsub2.called import func as lfunc
562 > from extlibroot.lsub1.lsub2.called import func as lfunc
563 > from extlibroot.recursedown import absdetail, legacydetail
563 > from extlibroot.recursedown import absdetail, legacydetail
564 > from extlibroot.shadowing import proxied
564 > from extlibroot.shadowing import proxied
565 >
565 >
566 > def uisetup(ui):
566 > def uisetup(ui):
567 > result = []
567 > result = []
568 > result.append(lused.detail)
568 > result.append(lused.detail)
569 > result.append(lfunc())
569 > result.append(lfunc())
570 > result.append(absdetail)
570 > result.append(absdetail)
571 > result.append(legacydetail)
571 > result.append(legacydetail)
572 > result.append(proxied.detail)
572 > result.append(proxied.detail)
573 > ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
573 > ui.write(b'LIB: %s\n' % b'\nLIB: '.join(result))
574 > NO_CHECK_EOF
574 > NO_CHECK_EOF
575
575
576 Examine module importing.
576 Examine module importing.
577
577
578 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
578 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showabsolute)
579 LIB: this is extlibroot.lsub1.lsub2.used
579 LIB: this is extlibroot.lsub1.lsub2.used
580 LIB: this is extlibroot.lsub1.lsub2.called.func()
580 LIB: this is extlibroot.lsub1.lsub2.called.func()
581 LIB: this is extlibroot.recursedown.abs.used
581 LIB: this is extlibroot.recursedown.abs.used
582 LIB: this is extlibroot.recursedown.legacy.used
582 LIB: this is extlibroot.recursedown.legacy.used
583 LIB: this is extlibroot.shadowing.used
583 LIB: this is extlibroot.shadowing.used
584 ABS: this is absextroot.xsub1.xsub2.used
584 ABS: this is absextroot.xsub1.xsub2.used
585 ABS: this is absextroot.xsub1.xsub2.called.func()
585 ABS: this is absextroot.xsub1.xsub2.called.func()
586
586
587 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
587 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.absextroot=$TESTTMP/absextroot showrelative)
588 LIB: this is extlibroot.lsub1.lsub2.used
588 LIB: this is extlibroot.lsub1.lsub2.used
589 LIB: this is extlibroot.lsub1.lsub2.called.func()
589 LIB: this is extlibroot.lsub1.lsub2.called.func()
590 LIB: this is extlibroot.recursedown.abs.used
590 LIB: this is extlibroot.recursedown.abs.used
591 LIB: this is extlibroot.recursedown.legacy.used
591 LIB: this is extlibroot.recursedown.legacy.used
592 LIB: this is extlibroot.shadowing.used
592 LIB: this is extlibroot.shadowing.used
593 REL: this is absextroot.xsub1.xsub2.used
593 REL: this is absextroot.xsub1.xsub2.used
594 REL: this is absextroot.xsub1.xsub2.called.func()
594 REL: this is absextroot.xsub1.xsub2.called.func()
595 REL: this relimporter imports 'this is absextroot.relimportee'
595 REL: this relimporter imports 'this is absextroot.relimportee'
596
596
597 Examine whether sub-module is imported relatively as expected.
597 Examine whether sub-module is imported relatively as expected.
598
598
599 See also issue5208 for detail about example case on Python 3.x.
599 See also issue5208 for detail about example case on Python 3.x.
600
600
601 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
601 $ f -q $TESTTMP/extlibroot/lsub1/lsub2/notexist.py
602 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
602 $TESTTMP/extlibroot/lsub1/lsub2/notexist.py: file not found
603
603
604 $ cat > $TESTTMP/notexist.py <<NO_CHECK_EOF
604 $ cat > $TESTTMP/notexist.py <<NO_CHECK_EOF
605 > text = 'notexist.py at root is loaded unintentionally\n'
605 > text = 'notexist.py at root is loaded unintentionally\n'
606 > NO_CHECK_EOF
606 > NO_CHECK_EOF
607
607
608 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF
608 $ cat > $TESTTMP/checkrelativity.py <<NO_CHECK_EOF
609 > from mercurial import registrar
609 > from mercurial import registrar
610 > cmdtable = {}
610 > cmdtable = {}
611 > command = registrar.command(cmdtable)
611 > command = registrar.command(cmdtable)
612 >
612 >
613 > # demand import avoids failure of importing notexist here, but only on
613 > # demand import avoids failure of importing notexist here, but only on
614 > # Python 2.
614 > # Python 2.
615 > import extlibroot.lsub1.lsub2.notexist
615 > import extlibroot.lsub1.lsub2.notexist
616 >
616 >
617 > @command(b'checkrelativity', [], norepo=True)
617 > @command(b'checkrelativity', [], norepo=True)
618 > def checkrelativity(ui, *args, **opts):
618 > def checkrelativity(ui, *args, **opts):
619 > try:
619 > try:
620 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
620 > ui.write(extlibroot.lsub1.lsub2.notexist.text)
621 > return 1 # unintentional success
621 > return 1 # unintentional success
622 > except ImportError:
622 > except ImportError:
623 > pass # intentional failure
623 > pass # intentional failure
624 > NO_CHECK_EOF
624 > NO_CHECK_EOF
625
625
626 Python 3's lazy importer verifies modules exist before returning the lazy
626 Python 3's lazy importer verifies modules exist before returning the lazy
627 module stub. Our custom lazy importer for Python 2 always returns a stub.
627 module stub. Our custom lazy importer for Python 2 always returns a stub.
628
628
629 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) || true
629 $ (PYTHONPATH=${PYTHONPATH}${PATHSEP}${TESTTMP}; hg --config extensions.checkrelativity=$TESTTMP/checkrelativity.py checkrelativity) || true
630 *** failed to import extension checkrelativity from $TESTTMP/checkrelativity.py: No module named 'extlibroot.lsub1.lsub2.notexist' (py3 !)
630 *** failed to import extension checkrelativity from $TESTTMP/checkrelativity.py: No module named 'extlibroot.lsub1.lsub2.notexist' (py3 !)
631 hg: unknown command 'checkrelativity' (py3 !)
631 hg: unknown command 'checkrelativity' (py3 !)
632 (use 'hg help' for a list of commands) (py3 !)
632 (use 'hg help' for a list of commands) (py3 !)
633
633
634 #endif
634 #endif
635
635
636 (Here, module importing tests are finished. Therefore, use other than
636 (Here, module importing tests are finished. Therefore, use other than
637 NO_CHECK_* limit mark for heredoc python files, in order to apply
637 NO_CHECK_* limit mark for heredoc python files, in order to apply
638 import-checker.py or so on their contents)
638 import-checker.py or so on their contents)
639
639
640 Make sure a broken uisetup doesn't globally break hg:
640 Make sure a broken uisetup doesn't globally break hg:
641 $ cat > $TESTTMP/baduisetup.py <<EOF
641 $ cat > $TESTTMP/baduisetup.py <<EOF
642 > def uisetup(ui):
642 > def uisetup(ui):
643 > 1/0
643 > 1 / 0
644 > EOF
644 > EOF
645
645
646 Even though the extension fails during uisetup, hg is still basically usable:
646 Even though the extension fails during uisetup, hg is still basically usable:
647 $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version
647 $ hg --config extensions.baduisetup=$TESTTMP/baduisetup.py version
648 Traceback (most recent call last):
648 Traceback (most recent call last):
649 File "*/mercurial/extensions.py", line *, in _runuisetup (glob)
649 File "*/mercurial/extensions.py", line *, in _runuisetup (glob)
650 uisetup(ui)
650 uisetup(ui)
651 File "$TESTTMP/baduisetup.py", line 2, in uisetup
651 File "$TESTTMP/baduisetup.py", line 2, in uisetup
652 1/0
652 1 / 0
653 ZeroDivisionError: * by zero (glob)
653 ZeroDivisionError: * by zero (glob)
654 *** failed to set up extension baduisetup: * by zero (glob)
654 *** failed to set up extension baduisetup: * by zero (glob)
655 Mercurial Distributed SCM (version *) (glob)
655 Mercurial Distributed SCM (version *) (glob)
656 (see https://mercurial-scm.org for more information)
656 (see https://mercurial-scm.org for more information)
657
657
658 Copyright (C) 2005-* Matt Mackall and others (glob)
658 Copyright (C) 2005-* Matt Mackall and others (glob)
659 This is free software; see the source for copying conditions. There is NO
659 This is free software; see the source for copying conditions. There is NO
660 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
660 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
661
661
662 $ cd ..
662 $ cd ..
663
663
664 hide outer repo
664 hide outer repo
665 $ hg init
665 $ hg init
666
666
667 $ cat > empty.py <<EOF
667 $ cat > empty.py <<EOF
668 > '''empty cmdtable
668 > '''empty cmdtable
669 > '''
669 > '''
670 > cmdtable = {}
670 > cmdtable = {}
671 > EOF
671 > EOF
672 $ emptypath=`pwd`/empty.py
672 $ emptypath=`pwd`/empty.py
673 $ echo "empty = $emptypath" >> $HGRCPATH
673 $ echo "empty = $emptypath" >> $HGRCPATH
674 $ hg help empty
674 $ hg help empty
675 empty extension - empty cmdtable
675 empty extension - empty cmdtable
676
676
677 no commands defined
677 no commands defined
678
678
679
679
680 $ echo 'empty = !' >> $HGRCPATH
680 $ echo 'empty = !' >> $HGRCPATH
681
681
682 $ cat > debugextension.py <<EOF
682 $ cat > debugextension.py <<EOF
683 > '''only debugcommands
683 > '''only debugcommands
684 > '''
684 > '''
685 > from mercurial import registrar
685 > from mercurial import registrar
686 > cmdtable = {}
686 > cmdtable = {}
687 > command = registrar.command(cmdtable)
687 > command = registrar.command(cmdtable)
688 > @command(b'debugfoobar', [], b'hg debugfoobar')
688 > @command(b'debugfoobar', [], b'hg debugfoobar')
689 > def debugfoobar(ui, repo, *args, **opts):
689 > def debugfoobar(ui, repo, *args, **opts):
690 > "yet another debug command"
690 > "yet another debug command"
691 > @command(b'foo', [], b'hg foo')
691 > @command(b'foo', [], b'hg foo')
692 > def foo(ui, repo, *args, **opts):
692 > def foo(ui, repo, *args, **opts):
693 > """yet another foo command
693 > """yet another foo command
694 > This command has been DEPRECATED since forever.
694 > This command has been DEPRECATED since forever.
695 > """
695 > """
696 > EOF
696 > EOF
697 $ debugpath=`pwd`/debugextension.py
697 $ debugpath=`pwd`/debugextension.py
698 $ echo "debugextension = $debugpath" >> $HGRCPATH
698 $ echo "debugextension = $debugpath" >> $HGRCPATH
699
699
700 $ hg help debugextension
700 $ hg help debugextension
701 hg debugextensions
701 hg debugextensions
702
702
703 show information about active extensions
703 show information about active extensions
704
704
705 options:
705 options:
706
706
707 -T --template TEMPLATE display with template
707 -T --template TEMPLATE display with template
708
708
709 (some details hidden, use --verbose to show complete help)
709 (some details hidden, use --verbose to show complete help)
710
710
711
711
712 $ hg --verbose help debugextension
712 $ hg --verbose help debugextension
713 hg debugextensions
713 hg debugextensions
714
714
715 show information about active extensions
715 show information about active extensions
716
716
717 options:
717 options:
718
718
719 -T --template TEMPLATE display with template
719 -T --template TEMPLATE display with template
720
720
721 global options ([+] can be repeated):
721 global options ([+] can be repeated):
722
722
723 -R --repository REPO repository root directory or name of overlay bundle
723 -R --repository REPO repository root directory or name of overlay bundle
724 file
724 file
725 --cwd DIR change working directory
725 --cwd DIR change working directory
726 -y --noninteractive do not prompt, automatically pick the first choice for
726 -y --noninteractive do not prompt, automatically pick the first choice for
727 all prompts
727 all prompts
728 -q --quiet suppress output
728 -q --quiet suppress output
729 -v --verbose enable additional output
729 -v --verbose enable additional output
730 --color TYPE when to colorize (boolean, always, auto, never, or
730 --color TYPE when to colorize (boolean, always, auto, never, or
731 debug)
731 debug)
732 --config CONFIG [+] set/override config option (use 'section.name=value')
732 --config CONFIG [+] set/override config option (use 'section.name=value')
733 --debug enable debugging output
733 --debug enable debugging output
734 --debugger start debugger
734 --debugger start debugger
735 --encoding ENCODE set the charset encoding (default: ascii)
735 --encoding ENCODE set the charset encoding (default: ascii)
736 --encodingmode MODE set the charset encoding mode (default: strict)
736 --encodingmode MODE set the charset encoding mode (default: strict)
737 --traceback always print a traceback on exception
737 --traceback always print a traceback on exception
738 --time time how long the command takes
738 --time time how long the command takes
739 --profile print command execution profile
739 --profile print command execution profile
740 --version output version information and exit
740 --version output version information and exit
741 -h --help display help and exit
741 -h --help display help and exit
742 --hidden consider hidden changesets
742 --hidden consider hidden changesets
743 --pager TYPE when to paginate (boolean, always, auto, or never)
743 --pager TYPE when to paginate (boolean, always, auto, or never)
744 (default: auto)
744 (default: auto)
745
745
746
746
747
747
748
748
749
749
750
750
751 $ hg --debug help debugextension
751 $ hg --debug help debugextension
752 hg debugextensions
752 hg debugextensions
753
753
754 show information about active extensions
754 show information about active extensions
755
755
756 options:
756 options:
757
757
758 -T --template TEMPLATE display with template
758 -T --template TEMPLATE display with template
759
759
760 global options ([+] can be repeated):
760 global options ([+] can be repeated):
761
761
762 -R --repository REPO repository root directory or name of overlay bundle
762 -R --repository REPO repository root directory or name of overlay bundle
763 file
763 file
764 --cwd DIR change working directory
764 --cwd DIR change working directory
765 -y --noninteractive do not prompt, automatically pick the first choice for
765 -y --noninteractive do not prompt, automatically pick the first choice for
766 all prompts
766 all prompts
767 -q --quiet suppress output
767 -q --quiet suppress output
768 -v --verbose enable additional output
768 -v --verbose enable additional output
769 --color TYPE when to colorize (boolean, always, auto, never, or
769 --color TYPE when to colorize (boolean, always, auto, never, or
770 debug)
770 debug)
771 --config CONFIG [+] set/override config option (use 'section.name=value')
771 --config CONFIG [+] set/override config option (use 'section.name=value')
772 --debug enable debugging output
772 --debug enable debugging output
773 --debugger start debugger
773 --debugger start debugger
774 --encoding ENCODE set the charset encoding (default: ascii)
774 --encoding ENCODE set the charset encoding (default: ascii)
775 --encodingmode MODE set the charset encoding mode (default: strict)
775 --encodingmode MODE set the charset encoding mode (default: strict)
776 --traceback always print a traceback on exception
776 --traceback always print a traceback on exception
777 --time time how long the command takes
777 --time time how long the command takes
778 --profile print command execution profile
778 --profile print command execution profile
779 --version output version information and exit
779 --version output version information and exit
780 -h --help display help and exit
780 -h --help display help and exit
781 --hidden consider hidden changesets
781 --hidden consider hidden changesets
782 --pager TYPE when to paginate (boolean, always, auto, or never)
782 --pager TYPE when to paginate (boolean, always, auto, or never)
783 (default: auto)
783 (default: auto)
784
784
785
785
786
786
787
787
788
788
789 $ echo 'debugextension = !' >> $HGRCPATH
789 $ echo 'debugextension = !' >> $HGRCPATH
790
790
791 Asking for help about a deprecated extension should do something useful:
791 Asking for help about a deprecated extension should do something useful:
792
792
793 $ hg help glog
793 $ hg help glog
794 'glog' is provided by the following extension:
794 'glog' is provided by the following extension:
795
795
796 graphlog command to view revision graphs from a shell (DEPRECATED)
796 graphlog command to view revision graphs from a shell (DEPRECATED)
797
797
798 (use 'hg help extensions' for information on enabling extensions)
798 (use 'hg help extensions' for information on enabling extensions)
799
799
800 Extension module help vs command help:
800 Extension module help vs command help:
801
801
802 $ echo 'extdiff =' >> $HGRCPATH
802 $ echo 'extdiff =' >> $HGRCPATH
803 $ hg help extdiff
803 $ hg help extdiff
804 hg extdiff [OPT]... [FILE]...
804 hg extdiff [OPT]... [FILE]...
805
805
806 use external program to diff repository (or selected files)
806 use external program to diff repository (or selected files)
807
807
808 Show differences between revisions for the specified files, using an
808 Show differences between revisions for the specified files, using an
809 external program. The default program used is diff, with default options
809 external program. The default program used is diff, with default options
810 "-Npru".
810 "-Npru".
811
811
812 To select a different program, use the -p/--program option. The program
812 To select a different program, use the -p/--program option. The program
813 will be passed the names of two directories to compare, unless the --per-
813 will be passed the names of two directories to compare, unless the --per-
814 file option is specified (see below). To pass additional options to the
814 file option is specified (see below). To pass additional options to the
815 program, use -o/--option. These will be passed before the names of the
815 program, use -o/--option. These will be passed before the names of the
816 directories or files to compare.
816 directories or files to compare.
817
817
818 When two revision arguments are given, then changes are shown between
818 When two revision arguments are given, then changes are shown between
819 those revisions. If only one revision is specified then that revision is
819 those revisions. If only one revision is specified then that revision is
820 compared to the working directory, and, when no revisions are specified,
820 compared to the working directory, and, when no revisions are specified,
821 the working directory files are compared to its parent.
821 the working directory files are compared to its parent.
822
822
823 The --per-file option runs the external program repeatedly on each file to
823 The --per-file option runs the external program repeatedly on each file to
824 diff, instead of once on two directories. By default, this happens one by
824 diff, instead of once on two directories. By default, this happens one by
825 one, where the next file diff is open in the external program only once
825 one, where the next file diff is open in the external program only once
826 the previous external program (for the previous file diff) has exited. If
826 the previous external program (for the previous file diff) has exited. If
827 the external program has a graphical interface, it can open all the file
827 the external program has a graphical interface, it can open all the file
828 diffs at once instead of one by one. See 'hg help -e extdiff' for
828 diffs at once instead of one by one. See 'hg help -e extdiff' for
829 information about how to tell Mercurial that a given program has a
829 information about how to tell Mercurial that a given program has a
830 graphical interface.
830 graphical interface.
831
831
832 The --confirm option will prompt the user before each invocation of the
832 The --confirm option will prompt the user before each invocation of the
833 external program. It is ignored if --per-file isn't specified.
833 external program. It is ignored if --per-file isn't specified.
834
834
835 (use 'hg help -e extdiff' to show help for the extdiff extension)
835 (use 'hg help -e extdiff' to show help for the extdiff extension)
836
836
837 options ([+] can be repeated):
837 options ([+] can be repeated):
838
838
839 -p --program CMD comparison program to run
839 -p --program CMD comparison program to run
840 -o --option OPT [+] pass option to comparison program
840 -o --option OPT [+] pass option to comparison program
841 -r --rev REV [+] revision
841 -r --rev REV [+] revision
842 -c --change REV change made by revision
842 -c --change REV change made by revision
843 --per-file compare each file instead of revision snapshots
843 --per-file compare each file instead of revision snapshots
844 --confirm prompt user before each external program invocation
844 --confirm prompt user before each external program invocation
845 --patch compare patches for two revisions
845 --patch compare patches for two revisions
846 -I --include PATTERN [+] include names matching the given patterns
846 -I --include PATTERN [+] include names matching the given patterns
847 -X --exclude PATTERN [+] exclude names matching the given patterns
847 -X --exclude PATTERN [+] exclude names matching the given patterns
848 -S --subrepos recurse into subrepositories
848 -S --subrepos recurse into subrepositories
849
849
850 (some details hidden, use --verbose to show complete help)
850 (some details hidden, use --verbose to show complete help)
851
851
852
852
853
853
854
854
855
855
856
856
857
857
858
858
859
859
860
860
861 $ hg help --extension extdiff
861 $ hg help --extension extdiff
862 extdiff extension - command to allow external programs to compare revisions
862 extdiff extension - command to allow external programs to compare revisions
863
863
864 The extdiff Mercurial extension allows you to use external programs to compare
864 The extdiff Mercurial extension allows you to use external programs to compare
865 revisions, or revision with working directory. The external diff programs are
865 revisions, or revision with working directory. The external diff programs are
866 called with a configurable set of options and two non-option arguments: paths
866 called with a configurable set of options and two non-option arguments: paths
867 to directories containing snapshots of files to compare.
867 to directories containing snapshots of files to compare.
868
868
869 If there is more than one file being compared and the "child" revision is the
869 If there is more than one file being compared and the "child" revision is the
870 working directory, any modifications made in the external diff program will be
870 working directory, any modifications made in the external diff program will be
871 copied back to the working directory from the temporary directory.
871 copied back to the working directory from the temporary directory.
872
872
873 The extdiff extension also allows you to configure new diff commands, so you
873 The extdiff extension also allows you to configure new diff commands, so you
874 do not need to type 'hg extdiff -p kdiff3' always.
874 do not need to type 'hg extdiff -p kdiff3' always.
875
875
876 [extdiff]
876 [extdiff]
877 # add new command that runs GNU diff(1) in 'context diff' mode
877 # add new command that runs GNU diff(1) in 'context diff' mode
878 cdiff = gdiff -Nprc5
878 cdiff = gdiff -Nprc5
879 ## or the old way:
879 ## or the old way:
880 #cmd.cdiff = gdiff
880 #cmd.cdiff = gdiff
881 #opts.cdiff = -Nprc5
881 #opts.cdiff = -Nprc5
882
882
883 # add new command called meld, runs meld (no need to name twice). If
883 # add new command called meld, runs meld (no need to name twice). If
884 # the meld executable is not available, the meld tool in [merge-tools]
884 # the meld executable is not available, the meld tool in [merge-tools]
885 # will be used, if available
885 # will be used, if available
886 meld =
886 meld =
887
887
888 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
888 # add new command called vimdiff, runs gvimdiff with DirDiff plugin
889 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
889 # (see http://www.vim.org/scripts/script.php?script_id=102) Non
890 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
890 # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
891 # your .vimrc
891 # your .vimrc
892 vimdiff = gvim -f "+next" \
892 vimdiff = gvim -f "+next" \
893 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
893 "+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
894
894
895 Tool arguments can include variables that are expanded at runtime:
895 Tool arguments can include variables that are expanded at runtime:
896
896
897 $parent1, $plabel1 - filename, descriptive label of first parent
897 $parent1, $plabel1 - filename, descriptive label of first parent
898 $child, $clabel - filename, descriptive label of child revision
898 $child, $clabel - filename, descriptive label of child revision
899 $parent2, $plabel2 - filename, descriptive label of second parent
899 $parent2, $plabel2 - filename, descriptive label of second parent
900 $root - repository root
900 $root - repository root
901 $parent is an alias for $parent1.
901 $parent is an alias for $parent1.
902
902
903 The extdiff extension will look in your [diff-tools] and [merge-tools]
903 The extdiff extension will look in your [diff-tools] and [merge-tools]
904 sections for diff tool arguments, when none are specified in [extdiff].
904 sections for diff tool arguments, when none are specified in [extdiff].
905
905
906 [extdiff]
906 [extdiff]
907 kdiff3 =
907 kdiff3 =
908
908
909 [diff-tools]
909 [diff-tools]
910 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
910 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
911
911
912 If a program has a graphical interface, it might be interesting to tell
912 If a program has a graphical interface, it might be interesting to tell
913 Mercurial about it. It will prevent the program from being mistakenly used in
913 Mercurial about it. It will prevent the program from being mistakenly used in
914 a terminal-only environment (such as an SSH terminal session), and will make
914 a terminal-only environment (such as an SSH terminal session), and will make
915 'hg extdiff --per-file' open multiple file diffs at once instead of one by one
915 'hg extdiff --per-file' open multiple file diffs at once instead of one by one
916 (if you still want to open file diffs one by one, you can use the --confirm
916 (if you still want to open file diffs one by one, you can use the --confirm
917 option).
917 option).
918
918
919 Declaring that a tool has a graphical interface can be done with the "gui"
919 Declaring that a tool has a graphical interface can be done with the "gui"
920 flag next to where "diffargs" are specified:
920 flag next to where "diffargs" are specified:
921
921
922 [diff-tools]
922 [diff-tools]
923 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
923 kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
924 kdiff3.gui = true
924 kdiff3.gui = true
925
925
926 You can use -I/-X and list of file or directory names like normal 'hg diff'
926 You can use -I/-X and list of file or directory names like normal 'hg diff'
927 command. The extdiff extension makes snapshots of only needed files, so
927 command. The extdiff extension makes snapshots of only needed files, so
928 running the external diff program will actually be pretty fast (at least
928 running the external diff program will actually be pretty fast (at least
929 faster than having to compare the entire tree).
929 faster than having to compare the entire tree).
930
930
931 list of commands:
931 list of commands:
932
932
933 extdiff use external program to diff repository (or selected files)
933 extdiff use external program to diff repository (or selected files)
934
934
935 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
935 (use 'hg help -v -e extdiff' to show built-in aliases and global options)
936
936
937
937
938
938
939
939
940
940
941
941
942
942
943
943
944
944
945
945
946
946
947
947
948
948
949
949
950
950
951
951
952 $ echo 'extdiff = !' >> $HGRCPATH
952 $ echo 'extdiff = !' >> $HGRCPATH
953
953
954 Test help topic with same name as extension
954 Test help topic with same name as extension
955
955
956 $ cat > multirevs.py <<EOF
956 $ cat > multirevs.py <<EOF
957 > from mercurial import commands, registrar
957 > from mercurial import commands, registrar
958 > cmdtable = {}
958 > cmdtable = {}
959 > command = registrar.command(cmdtable)
959 > command = registrar.command(cmdtable)
960 > """multirevs extension
960 > """multirevs extension
961 > Big multi-line module docstring."""
961 > Big multi-line module docstring."""
962 > @command(b'multirevs', [], b'ARG', norepo=True)
962 > @command(b'multirevs', [], b'ARG', norepo=True)
963 > def multirevs(ui, repo, arg, *args, **opts):
963 > def multirevs(ui, repo, arg, *args, **opts):
964 > """multirevs command"""
964 > """multirevs command"""
965 > EOF
965 > EOF
966 $ echo "multirevs = multirevs.py" >> $HGRCPATH
966 $ echo "multirevs = multirevs.py" >> $HGRCPATH
967
967
968 $ hg help multirevs | tail
968 $ hg help multirevs | tail
969 used):
969 used):
970
970
971 hg update :@
971 hg update :@
972
972
973 - Show diff between tags 1.3 and 1.5 (this works because the first and the
973 - Show diff between tags 1.3 and 1.5 (this works because the first and the
974 last revisions of the revset are used):
974 last revisions of the revset are used):
975
975
976 hg diff -r 1.3::1.5
976 hg diff -r 1.3::1.5
977
977
978 use 'hg help -c multirevs' to see help for the multirevs command
978 use 'hg help -c multirevs' to see help for the multirevs command
979
979
980
980
981
981
982
982
983
983
984
984
985 $ hg help -c multirevs
985 $ hg help -c multirevs
986 hg multirevs ARG
986 hg multirevs ARG
987
987
988 multirevs command
988 multirevs command
989
989
990 (some details hidden, use --verbose to show complete help)
990 (some details hidden, use --verbose to show complete help)
991
991
992
992
993
993
994 $ hg multirevs
994 $ hg multirevs
995 hg multirevs: invalid arguments
995 hg multirevs: invalid arguments
996 hg multirevs ARG
996 hg multirevs ARG
997
997
998 multirevs command
998 multirevs command
999
999
1000 (use 'hg multirevs -h' to show more help)
1000 (use 'hg multirevs -h' to show more help)
1001 [255]
1001 [255]
1002
1002
1003
1003
1004
1004
1005 $ echo "multirevs = !" >> $HGRCPATH
1005 $ echo "multirevs = !" >> $HGRCPATH
1006
1006
1007 Issue811: Problem loading extensions twice (by site and by user)
1007 Issue811: Problem loading extensions twice (by site and by user)
1008
1008
1009 $ cat <<EOF >> $HGRCPATH
1009 $ cat <<EOF >> $HGRCPATH
1010 > mq =
1010 > mq =
1011 > strip =
1011 > strip =
1012 > hgext.mq =
1012 > hgext.mq =
1013 > hgext/mq =
1013 > hgext/mq =
1014 > EOF
1014 > EOF
1015
1015
1016 Show extensions:
1016 Show extensions:
1017 (note that mq force load strip, also checking it's not loaded twice)
1017 (note that mq force load strip, also checking it's not loaded twice)
1018
1018
1019 #if no-extraextensions
1019 #if no-extraextensions
1020 $ hg debugextensions
1020 $ hg debugextensions
1021 mq
1021 mq
1022 strip
1022 strip
1023 #endif
1023 #endif
1024
1024
1025 For extensions, which name matches one of its commands, help
1025 For extensions, which name matches one of its commands, help
1026 message should ask '-v -e' to get list of built-in aliases
1026 message should ask '-v -e' to get list of built-in aliases
1027 along with extension help itself
1027 along with extension help itself
1028
1028
1029 $ mkdir $TESTTMP/d
1029 $ mkdir $TESTTMP/d
1030 $ cat > $TESTTMP/d/dodo.py <<EOF
1030 $ cat > $TESTTMP/d/dodo.py <<EOF
1031 > """
1031 > """
1032 > This is an awesome 'dodo' extension. It does nothing and
1032 > This is an awesome 'dodo' extension. It does nothing and
1033 > writes 'Foo foo'
1033 > writes 'Foo foo'
1034 > """
1034 > """
1035 > from mercurial import commands, registrar
1035 > from mercurial import commands, registrar
1036 > cmdtable = {}
1036 > cmdtable = {}
1037 > command = registrar.command(cmdtable)
1037 > command = registrar.command(cmdtable)
1038 > @command(b'dodo', [], b'hg dodo')
1038 > @command(b'dodo', [], b'hg dodo')
1039 > def dodo(ui, *args, **kwargs):
1039 > def dodo(ui, *args, **kwargs):
1040 > """Does nothing"""
1040 > """Does nothing"""
1041 > ui.write(b"I do nothing. Yay\\n")
1041 > ui.write(b"I do nothing. Yay\\n")
1042 > @command(b'foofoo', [], b'hg foofoo')
1042 > @command(b'foofoo', [], b'hg foofoo')
1043 > def foofoo(ui, *args, **kwargs):
1043 > def foofoo(ui, *args, **kwargs):
1044 > """Writes 'Foo foo'"""
1044 > """Writes 'Foo foo'"""
1045 > ui.write(b"Foo foo\\n")
1045 > ui.write(b"Foo foo\\n")
1046 > EOF
1046 > EOF
1047 $ dodopath=$TESTTMP/d/dodo.py
1047 $ dodopath=$TESTTMP/d/dodo.py
1048
1048
1049 $ echo "dodo = $dodopath" >> $HGRCPATH
1049 $ echo "dodo = $dodopath" >> $HGRCPATH
1050
1050
1051 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
1051 Make sure that user is asked to enter '-v -e' to get list of built-in aliases
1052 $ hg help -e dodo
1052 $ hg help -e dodo
1053 dodo extension -
1053 dodo extension -
1054
1054
1055 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1055 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1056
1056
1057 list of commands:
1057 list of commands:
1058
1058
1059 dodo Does nothing
1059 dodo Does nothing
1060 foofoo Writes 'Foo foo'
1060 foofoo Writes 'Foo foo'
1061
1061
1062 (use 'hg help -v -e dodo' to show built-in aliases and global options)
1062 (use 'hg help -v -e dodo' to show built-in aliases and global options)
1063
1063
1064 Make sure that '-v -e' prints list of built-in aliases along with
1064 Make sure that '-v -e' prints list of built-in aliases along with
1065 extension help itself
1065 extension help itself
1066 $ hg help -v -e dodo
1066 $ hg help -v -e dodo
1067 dodo extension -
1067 dodo extension -
1068
1068
1069 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1069 This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
1070
1070
1071 list of commands:
1071 list of commands:
1072
1072
1073 dodo Does nothing
1073 dodo Does nothing
1074 foofoo Writes 'Foo foo'
1074 foofoo Writes 'Foo foo'
1075
1075
1076 global options ([+] can be repeated):
1076 global options ([+] can be repeated):
1077
1077
1078 -R --repository REPO repository root directory or name of overlay bundle
1078 -R --repository REPO repository root directory or name of overlay bundle
1079 file
1079 file
1080 --cwd DIR change working directory
1080 --cwd DIR change working directory
1081 -y --noninteractive do not prompt, automatically pick the first choice for
1081 -y --noninteractive do not prompt, automatically pick the first choice for
1082 all prompts
1082 all prompts
1083 -q --quiet suppress output
1083 -q --quiet suppress output
1084 -v --verbose enable additional output
1084 -v --verbose enable additional output
1085 --color TYPE when to colorize (boolean, always, auto, never, or
1085 --color TYPE when to colorize (boolean, always, auto, never, or
1086 debug)
1086 debug)
1087 --config CONFIG [+] set/override config option (use 'section.name=value')
1087 --config CONFIG [+] set/override config option (use 'section.name=value')
1088 --debug enable debugging output
1088 --debug enable debugging output
1089 --debugger start debugger
1089 --debugger start debugger
1090 --encoding ENCODE set the charset encoding (default: ascii)
1090 --encoding ENCODE set the charset encoding (default: ascii)
1091 --encodingmode MODE set the charset encoding mode (default: strict)
1091 --encodingmode MODE set the charset encoding mode (default: strict)
1092 --traceback always print a traceback on exception
1092 --traceback always print a traceback on exception
1093 --time time how long the command takes
1093 --time time how long the command takes
1094 --profile print command execution profile
1094 --profile print command execution profile
1095 --version output version information and exit
1095 --version output version information and exit
1096 -h --help display help and exit
1096 -h --help display help and exit
1097 --hidden consider hidden changesets
1097 --hidden consider hidden changesets
1098 --pager TYPE when to paginate (boolean, always, auto, or never)
1098 --pager TYPE when to paginate (boolean, always, auto, or never)
1099 (default: auto)
1099 (default: auto)
1100
1100
1101 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
1101 Make sure that single '-v' option shows help and built-ins only for 'dodo' command
1102 $ hg help -v dodo
1102 $ hg help -v dodo
1103 hg dodo
1103 hg dodo
1104
1104
1105 Does nothing
1105 Does nothing
1106
1106
1107 (use 'hg help -e dodo' to show help for the dodo extension)
1107 (use 'hg help -e dodo' to show help for the dodo extension)
1108
1108
1109 options:
1109 options:
1110
1110
1111 --mq operate on patch repository
1111 --mq operate on patch repository
1112
1112
1113 global options ([+] can be repeated):
1113 global options ([+] can be repeated):
1114
1114
1115 -R --repository REPO repository root directory or name of overlay bundle
1115 -R --repository REPO repository root directory or name of overlay bundle
1116 file
1116 file
1117 --cwd DIR change working directory
1117 --cwd DIR change working directory
1118 -y --noninteractive do not prompt, automatically pick the first choice for
1118 -y --noninteractive do not prompt, automatically pick the first choice for
1119 all prompts
1119 all prompts
1120 -q --quiet suppress output
1120 -q --quiet suppress output
1121 -v --verbose enable additional output
1121 -v --verbose enable additional output
1122 --color TYPE when to colorize (boolean, always, auto, never, or
1122 --color TYPE when to colorize (boolean, always, auto, never, or
1123 debug)
1123 debug)
1124 --config CONFIG [+] set/override config option (use 'section.name=value')
1124 --config CONFIG [+] set/override config option (use 'section.name=value')
1125 --debug enable debugging output
1125 --debug enable debugging output
1126 --debugger start debugger
1126 --debugger start debugger
1127 --encoding ENCODE set the charset encoding (default: ascii)
1127 --encoding ENCODE set the charset encoding (default: ascii)
1128 --encodingmode MODE set the charset encoding mode (default: strict)
1128 --encodingmode MODE set the charset encoding mode (default: strict)
1129 --traceback always print a traceback on exception
1129 --traceback always print a traceback on exception
1130 --time time how long the command takes
1130 --time time how long the command takes
1131 --profile print command execution profile
1131 --profile print command execution profile
1132 --version output version information and exit
1132 --version output version information and exit
1133 -h --help display help and exit
1133 -h --help display help and exit
1134 --hidden consider hidden changesets
1134 --hidden consider hidden changesets
1135 --pager TYPE when to paginate (boolean, always, auto, or never)
1135 --pager TYPE when to paginate (boolean, always, auto, or never)
1136 (default: auto)
1136 (default: auto)
1137
1137
1138 In case when extension name doesn't match any of its commands,
1138 In case when extension name doesn't match any of its commands,
1139 help message should ask for '-v' to get list of built-in aliases
1139 help message should ask for '-v' to get list of built-in aliases
1140 along with extension help
1140 along with extension help
1141 $ cat > $TESTTMP/d/dudu.py <<EOF
1141 $ cat > $TESTTMP/d/dudu.py <<EOF
1142 > """
1142 > """
1143 > This is an awesome 'dudu' extension. It does something and
1143 > This is an awesome 'dudu' extension. It does something and
1144 > also writes 'Beep beep'
1144 > also writes 'Beep beep'
1145 > """
1145 > """
1146 > from mercurial import commands, registrar
1146 > from mercurial import commands, registrar
1147 > cmdtable = {}
1147 > cmdtable = {}
1148 > command = registrar.command(cmdtable)
1148 > command = registrar.command(cmdtable)
1149 > @command(b'something', [], b'hg something')
1149 > @command(b'something', [], b'hg something')
1150 > def something(ui, *args, **kwargs):
1150 > def something(ui, *args, **kwargs):
1151 > """Does something"""
1151 > """Does something"""
1152 > ui.write(b"I do something. Yaaay\\n")
1152 > ui.write(b"I do something. Yaaay\\n")
1153 > @command(b'beep', [], b'hg beep')
1153 > @command(b'beep', [], b'hg beep')
1154 > def beep(ui, *args, **kwargs):
1154 > def beep(ui, *args, **kwargs):
1155 > """Writes 'Beep beep'"""
1155 > """Writes 'Beep beep'"""
1156 > ui.write(b"Beep beep\\n")
1156 > ui.write(b"Beep beep\\n")
1157 > EOF
1157 > EOF
1158 $ dudupath=$TESTTMP/d/dudu.py
1158 $ dudupath=$TESTTMP/d/dudu.py
1159
1159
1160 $ echo "dudu = $dudupath" >> $HGRCPATH
1160 $ echo "dudu = $dudupath" >> $HGRCPATH
1161
1161
1162 $ hg help -e dudu
1162 $ hg help -e dudu
1163 dudu extension -
1163 dudu extension -
1164
1164
1165 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1165 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1166 beep'
1166 beep'
1167
1167
1168 list of commands:
1168 list of commands:
1169
1169
1170 beep Writes 'Beep beep'
1170 beep Writes 'Beep beep'
1171 something Does something
1171 something Does something
1172
1172
1173 (use 'hg help -v dudu' to show built-in aliases and global options)
1173 (use 'hg help -v dudu' to show built-in aliases and global options)
1174
1174
1175 In case when extension name doesn't match any of its commands,
1175 In case when extension name doesn't match any of its commands,
1176 help options '-v' and '-v -e' should be equivalent
1176 help options '-v' and '-v -e' should be equivalent
1177 $ hg help -v dudu
1177 $ hg help -v dudu
1178 dudu extension -
1178 dudu extension -
1179
1179
1180 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1180 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1181 beep'
1181 beep'
1182
1182
1183 list of commands:
1183 list of commands:
1184
1184
1185 beep Writes 'Beep beep'
1185 beep Writes 'Beep beep'
1186 something Does something
1186 something Does something
1187
1187
1188 global options ([+] can be repeated):
1188 global options ([+] can be repeated):
1189
1189
1190 -R --repository REPO repository root directory or name of overlay bundle
1190 -R --repository REPO repository root directory or name of overlay bundle
1191 file
1191 file
1192 --cwd DIR change working directory
1192 --cwd DIR change working directory
1193 -y --noninteractive do not prompt, automatically pick the first choice for
1193 -y --noninteractive do not prompt, automatically pick the first choice for
1194 all prompts
1194 all prompts
1195 -q --quiet suppress output
1195 -q --quiet suppress output
1196 -v --verbose enable additional output
1196 -v --verbose enable additional output
1197 --color TYPE when to colorize (boolean, always, auto, never, or
1197 --color TYPE when to colorize (boolean, always, auto, never, or
1198 debug)
1198 debug)
1199 --config CONFIG [+] set/override config option (use 'section.name=value')
1199 --config CONFIG [+] set/override config option (use 'section.name=value')
1200 --debug enable debugging output
1200 --debug enable debugging output
1201 --debugger start debugger
1201 --debugger start debugger
1202 --encoding ENCODE set the charset encoding (default: ascii)
1202 --encoding ENCODE set the charset encoding (default: ascii)
1203 --encodingmode MODE set the charset encoding mode (default: strict)
1203 --encodingmode MODE set the charset encoding mode (default: strict)
1204 --traceback always print a traceback on exception
1204 --traceback always print a traceback on exception
1205 --time time how long the command takes
1205 --time time how long the command takes
1206 --profile print command execution profile
1206 --profile print command execution profile
1207 --version output version information and exit
1207 --version output version information and exit
1208 -h --help display help and exit
1208 -h --help display help and exit
1209 --hidden consider hidden changesets
1209 --hidden consider hidden changesets
1210 --pager TYPE when to paginate (boolean, always, auto, or never)
1210 --pager TYPE when to paginate (boolean, always, auto, or never)
1211 (default: auto)
1211 (default: auto)
1212
1212
1213 $ hg help -v -e dudu
1213 $ hg help -v -e dudu
1214 dudu extension -
1214 dudu extension -
1215
1215
1216 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1216 This is an awesome 'dudu' extension. It does something and also writes 'Beep
1217 beep'
1217 beep'
1218
1218
1219 list of commands:
1219 list of commands:
1220
1220
1221 beep Writes 'Beep beep'
1221 beep Writes 'Beep beep'
1222 something Does something
1222 something Does something
1223
1223
1224 global options ([+] can be repeated):
1224 global options ([+] can be repeated):
1225
1225
1226 -R --repository REPO repository root directory or name of overlay bundle
1226 -R --repository REPO repository root directory or name of overlay bundle
1227 file
1227 file
1228 --cwd DIR change working directory
1228 --cwd DIR change working directory
1229 -y --noninteractive do not prompt, automatically pick the first choice for
1229 -y --noninteractive do not prompt, automatically pick the first choice for
1230 all prompts
1230 all prompts
1231 -q --quiet suppress output
1231 -q --quiet suppress output
1232 -v --verbose enable additional output
1232 -v --verbose enable additional output
1233 --color TYPE when to colorize (boolean, always, auto, never, or
1233 --color TYPE when to colorize (boolean, always, auto, never, or
1234 debug)
1234 debug)
1235 --config CONFIG [+] set/override config option (use 'section.name=value')
1235 --config CONFIG [+] set/override config option (use 'section.name=value')
1236 --debug enable debugging output
1236 --debug enable debugging output
1237 --debugger start debugger
1237 --debugger start debugger
1238 --encoding ENCODE set the charset encoding (default: ascii)
1238 --encoding ENCODE set the charset encoding (default: ascii)
1239 --encodingmode MODE set the charset encoding mode (default: strict)
1239 --encodingmode MODE set the charset encoding mode (default: strict)
1240 --traceback always print a traceback on exception
1240 --traceback always print a traceback on exception
1241 --time time how long the command takes
1241 --time time how long the command takes
1242 --profile print command execution profile
1242 --profile print command execution profile
1243 --version output version information and exit
1243 --version output version information and exit
1244 -h --help display help and exit
1244 -h --help display help and exit
1245 --hidden consider hidden changesets
1245 --hidden consider hidden changesets
1246 --pager TYPE when to paginate (boolean, always, auto, or never)
1246 --pager TYPE when to paginate (boolean, always, auto, or never)
1247 (default: auto)
1247 (default: auto)
1248
1248
1249 Disabled extension commands:
1249 Disabled extension commands:
1250
1250
1251 $ ORGHGRCPATH=$HGRCPATH
1251 $ ORGHGRCPATH=$HGRCPATH
1252 $ HGRCPATH=
1252 $ HGRCPATH=
1253 $ export HGRCPATH
1253 $ export HGRCPATH
1254 $ hg help email
1254 $ hg help email
1255 'email' is provided by the following extension:
1255 'email' is provided by the following extension:
1256
1256
1257 patchbomb command to send changesets as (a series of) patch emails
1257 patchbomb command to send changesets as (a series of) patch emails
1258
1258
1259 (use 'hg help extensions' for information on enabling extensions)
1259 (use 'hg help extensions' for information on enabling extensions)
1260
1260
1261
1261
1262 $ hg qdel
1262 $ hg qdel
1263 hg: unknown command 'qdel'
1263 hg: unknown command 'qdel'
1264 'qdelete' is provided by the following extension:
1264 'qdelete' is provided by the following extension:
1265
1265
1266 mq manage a stack of patches
1266 mq manage a stack of patches
1267
1267
1268 (use 'hg help extensions' for information on enabling extensions)
1268 (use 'hg help extensions' for information on enabling extensions)
1269 [255]
1269 [255]
1270
1270
1271
1271
1272 $ hg churn
1272 $ hg churn
1273 hg: unknown command 'churn'
1273 hg: unknown command 'churn'
1274 'churn' is provided by the following extension:
1274 'churn' is provided by the following extension:
1275
1275
1276 churn command to display statistics about repository history
1276 churn command to display statistics about repository history
1277
1277
1278 (use 'hg help extensions' for information on enabling extensions)
1278 (use 'hg help extensions' for information on enabling extensions)
1279 [255]
1279 [255]
1280
1280
1281
1281
1282
1282
1283 Disabled extensions:
1283 Disabled extensions:
1284
1284
1285 $ hg help churn
1285 $ hg help churn
1286 churn extension - command to display statistics about repository history
1286 churn extension - command to display statistics about repository history
1287
1287
1288 (use 'hg help extensions' for information on enabling extensions)
1288 (use 'hg help extensions' for information on enabling extensions)
1289
1289
1290 $ hg help patchbomb
1290 $ hg help patchbomb
1291 patchbomb extension - command to send changesets as (a series of) patch emails
1291 patchbomb extension - command to send changesets as (a series of) patch emails
1292
1292
1293 The series is started off with a "[PATCH 0 of N]" introduction, which
1293 The series is started off with a "[PATCH 0 of N]" introduction, which
1294 describes the series as a whole.
1294 describes the series as a whole.
1295
1295
1296 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1296 Each patch email has a Subject line of "[PATCH M of N] ...", using the first
1297 line of the changeset description as the subject text. The message contains
1297 line of the changeset description as the subject text. The message contains
1298 two or three body parts:
1298 two or three body parts:
1299
1299
1300 - The changeset description.
1300 - The changeset description.
1301 - [Optional] The result of running diffstat on the patch.
1301 - [Optional] The result of running diffstat on the patch.
1302 - The patch itself, as generated by 'hg export'.
1302 - The patch itself, as generated by 'hg export'.
1303
1303
1304 Each message refers to the first in the series using the In-Reply-To and
1304 Each message refers to the first in the series using the In-Reply-To and
1305 References headers, so they will show up as a sequence in threaded mail and
1305 References headers, so they will show up as a sequence in threaded mail and
1306 news readers, and in mail archives.
1306 news readers, and in mail archives.
1307
1307
1308 To configure other defaults, add a section like this to your configuration
1308 To configure other defaults, add a section like this to your configuration
1309 file:
1309 file:
1310
1310
1311 [email]
1311 [email]
1312 from = My Name <my@email>
1312 from = My Name <my@email>
1313 to = recipient1, recipient2, ...
1313 to = recipient1, recipient2, ...
1314 cc = cc1, cc2, ...
1314 cc = cc1, cc2, ...
1315 bcc = bcc1, bcc2, ...
1315 bcc = bcc1, bcc2, ...
1316 reply-to = address1, address2, ...
1316 reply-to = address1, address2, ...
1317
1317
1318 Use "[patchbomb]" as configuration section name if you need to override global
1318 Use "[patchbomb]" as configuration section name if you need to override global
1319 "[email]" address settings.
1319 "[email]" address settings.
1320
1320
1321 Then you can use the 'hg email' command to mail a series of changesets as a
1321 Then you can use the 'hg email' command to mail a series of changesets as a
1322 patchbomb.
1322 patchbomb.
1323
1323
1324 You can also either configure the method option in the email section to be a
1324 You can also either configure the method option in the email section to be a
1325 sendmail compatible mailer or fill out the [smtp] section so that the
1325 sendmail compatible mailer or fill out the [smtp] section so that the
1326 patchbomb extension can automatically send patchbombs directly from the
1326 patchbomb extension can automatically send patchbombs directly from the
1327 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1327 commandline. See the [email] and [smtp] sections in hgrc(5) for details.
1328
1328
1329 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1329 By default, 'hg email' will prompt for a "To" or "CC" header if you do not
1330 supply one via configuration or the command line. You can override this to
1330 supply one via configuration or the command line. You can override this to
1331 never prompt by configuring an empty value:
1331 never prompt by configuring an empty value:
1332
1332
1333 [email]
1333 [email]
1334 cc =
1334 cc =
1335
1335
1336 You can control the default inclusion of an introduction message with the
1336 You can control the default inclusion of an introduction message with the
1337 "patchbomb.intro" configuration option. The configuration is always
1337 "patchbomb.intro" configuration option. The configuration is always
1338 overwritten by command line flags like --intro and --desc:
1338 overwritten by command line flags like --intro and --desc:
1339
1339
1340 [patchbomb]
1340 [patchbomb]
1341 intro=auto # include introduction message if more than 1 patch (default)
1341 intro=auto # include introduction message if more than 1 patch (default)
1342 intro=never # never include an introduction message
1342 intro=never # never include an introduction message
1343 intro=always # always include an introduction message
1343 intro=always # always include an introduction message
1344
1344
1345 You can specify a template for flags to be added in subject prefixes. Flags
1345 You can specify a template for flags to be added in subject prefixes. Flags
1346 specified by --flag option are exported as "{flags}" keyword:
1346 specified by --flag option are exported as "{flags}" keyword:
1347
1347
1348 [patchbomb]
1348 [patchbomb]
1349 flagtemplate = "{separate(' ',
1349 flagtemplate = "{separate(' ',
1350 ifeq(branch, 'default', '', branch|upper),
1350 ifeq(branch, 'default', '', branch|upper),
1351 flags)}"
1351 flags)}"
1352
1352
1353 You can set patchbomb to always ask for confirmation by setting
1353 You can set patchbomb to always ask for confirmation by setting
1354 "patchbomb.confirm" to true.
1354 "patchbomb.confirm" to true.
1355
1355
1356 (use 'hg help extensions' for information on enabling extensions)
1356 (use 'hg help extensions' for information on enabling extensions)
1357
1357
1358
1358
1359 Broken disabled extension and command:
1359 Broken disabled extension and command:
1360
1360
1361 $ mkdir hgext
1361 $ mkdir hgext
1362 $ echo > hgext/__init__.py
1362 $ echo > hgext/__init__.py
1363 $ cat > hgext/broken.py <<NO_CHECK_EOF
1363 $ cat > hgext/broken.py <<NO_CHECK_EOF
1364 > "broken extension'
1364 > "broken extension'
1365 > NO_CHECK_EOF
1365 > NO_CHECK_EOF
1366 $ cat > path.py <<EOF
1366 $ cat > path.py <<EOF
1367 > import os
1367 > import os
1368 > import sys
1368 > import sys
1369 > sys.path.insert(0, os.environ['HGEXTPATH'])
1369 > sys.path.insert(0, os.environ['HGEXTPATH'])
1370 > EOF
1370 > EOF
1371 $ HGEXTPATH=`pwd`
1371 $ HGEXTPATH=`pwd`
1372 $ export HGEXTPATH
1372 $ export HGEXTPATH
1373
1373
1374 $ hg --config extensions.path=./path.py help broken
1374 $ hg --config extensions.path=./path.py help broken
1375 broken extension - (no help text available)
1375 broken extension - (no help text available)
1376
1376
1377 (use 'hg help extensions' for information on enabling extensions)
1377 (use 'hg help extensions' for information on enabling extensions)
1378
1378
1379
1379
1380 $ cat > hgext/forest.py <<EOF
1380 $ cat > hgext/forest.py <<EOF
1381 > cmdtable = None
1381 > cmdtable = None
1382 > @command()
1382 > @command()
1383 > def f():
1383 > def f():
1384 > pass
1384 > pass
1385 > @command(123)
1385 > @command(123)
1386 > def g():
1386 > def g():
1387 > pass
1387 > pass
1388 > EOF
1388 > EOF
1389 $ hg --config extensions.path=./path.py help foo
1389 $ hg --config extensions.path=./path.py help foo
1390 abort: no such help topic: foo
1390 abort: no such help topic: foo
1391 (try 'hg help --keyword foo')
1391 (try 'hg help --keyword foo')
1392 [255]
1392 [255]
1393
1393
1394 $ cat > throw.py <<EOF
1394 $ cat > throw.py <<EOF
1395 > from mercurial import commands, registrar, util
1395 > from mercurial import commands, registrar, util
1396 > cmdtable = {}
1396 > cmdtable = {}
1397 > command = registrar.command(cmdtable)
1397 > command = registrar.command(cmdtable)
1398 > class Bogon(Exception): pass
1398 > class Bogon(Exception): pass
1399 > @command(b'throw', [], b'hg throw', norepo=True)
1399 > @command(b'throw', [], b'hg throw', norepo=True)
1400 > def throw(ui, **opts):
1400 > def throw(ui, **opts):
1401 > """throws an exception"""
1401 > """throws an exception"""
1402 > raise Bogon()
1402 > raise Bogon()
1403 > EOF
1403 > EOF
1404
1404
1405 No declared supported version, extension complains:
1405 No declared supported version, extension complains:
1406 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1406 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1407 ** Unknown exception encountered with possibly-broken third-party extension throw
1407 ** Unknown exception encountered with possibly-broken third-party extension throw
1408 ** which supports versions unknown of Mercurial.
1408 ** which supports versions unknown of Mercurial.
1409 ** Please disable throw and try your action again.
1409 ** Please disable throw and try your action again.
1410 ** If that fixes the bug please report it to the extension author.
1410 ** If that fixes the bug please report it to the extension author.
1411 ** Python * (glob)
1411 ** Python * (glob)
1412 ** Mercurial Distributed SCM * (glob)
1412 ** Mercurial Distributed SCM * (glob)
1413 ** Extensions loaded: throw
1413 ** Extensions loaded: throw
1414
1414
1415 empty declaration of supported version, extension complains:
1415 empty declaration of supported version, extension complains:
1416 $ echo "testedwith = ''" >> throw.py
1416 $ echo "testedwith = ''" >> throw.py
1417 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1417 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1418 ** Unknown exception encountered with possibly-broken third-party extension throw
1418 ** Unknown exception encountered with possibly-broken third-party extension throw
1419 ** which supports versions unknown of Mercurial.
1419 ** which supports versions unknown of Mercurial.
1420 ** Please disable throw and try your action again.
1420 ** Please disable throw and try your action again.
1421 ** If that fixes the bug please report it to the extension author.
1421 ** If that fixes the bug please report it to the extension author.
1422 ** Python * (glob)
1422 ** Python * (glob)
1423 ** Mercurial Distributed SCM (*) (glob)
1423 ** Mercurial Distributed SCM (*) (glob)
1424 ** Extensions loaded: throw
1424 ** Extensions loaded: throw
1425
1425
1426 If the extension specifies a buglink, show that:
1426 If the extension specifies a buglink, show that:
1427 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1427 $ echo 'buglink = "http://example.com/bts"' >> throw.py
1428 $ rm -f throw.pyc throw.pyo
1428 $ rm -f throw.pyc throw.pyo
1429 $ rm -Rf __pycache__
1429 $ rm -Rf __pycache__
1430 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1430 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1431 ** Unknown exception encountered with possibly-broken third-party extension throw
1431 ** Unknown exception encountered with possibly-broken third-party extension throw
1432 ** which supports versions unknown of Mercurial.
1432 ** which supports versions unknown of Mercurial.
1433 ** Please disable throw and try your action again.
1433 ** Please disable throw and try your action again.
1434 ** If that fixes the bug please report it to http://example.com/bts
1434 ** If that fixes the bug please report it to http://example.com/bts
1435 ** Python * (glob)
1435 ** Python * (glob)
1436 ** Mercurial Distributed SCM (*) (glob)
1436 ** Mercurial Distributed SCM (*) (glob)
1437 ** Extensions loaded: throw
1437 ** Extensions loaded: throw
1438
1438
1439 If the extensions declare outdated versions, accuse the older extension first:
1439 If the extensions declare outdated versions, accuse the older extension first:
1440 $ echo "from mercurial import util" >> older.py
1440 $ echo "from mercurial import util" >> older.py
1441 $ echo "util.version = lambda:b'2.2'" >> older.py
1441 $ echo "util.version = lambda:b'2.2'" >> older.py
1442 $ echo "testedwith = b'1.9.3'" >> older.py
1442 $ echo "testedwith = b'1.9.3'" >> older.py
1443 $ echo "testedwith = b'2.1.1'" >> throw.py
1443 $ echo "testedwith = b'2.1.1'" >> throw.py
1444 $ rm -f throw.pyc throw.pyo
1444 $ rm -f throw.pyc throw.pyo
1445 $ rm -Rf __pycache__
1445 $ rm -Rf __pycache__
1446 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1446 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1447 > throw 2>&1 | egrep '^\*\*'
1447 > throw 2>&1 | egrep '^\*\*'
1448 ** Unknown exception encountered with possibly-broken third-party extension older
1448 ** Unknown exception encountered with possibly-broken third-party extension older
1449 ** which supports versions 1.9 of Mercurial.
1449 ** which supports versions 1.9 of Mercurial.
1450 ** Please disable older and try your action again.
1450 ** Please disable older and try your action again.
1451 ** If that fixes the bug please report it to the extension author.
1451 ** If that fixes the bug please report it to the extension author.
1452 ** Python * (glob)
1452 ** Python * (glob)
1453 ** Mercurial Distributed SCM (version 2.2)
1453 ** Mercurial Distributed SCM (version 2.2)
1454 ** Extensions loaded: throw, older
1454 ** Extensions loaded: throw, older
1455
1455
1456 One extension only tested with older, one only with newer versions:
1456 One extension only tested with older, one only with newer versions:
1457 $ echo "util.version = lambda:b'2.1'" >> older.py
1457 $ echo "util.version = lambda:b'2.1'" >> older.py
1458 $ rm -f older.pyc older.pyo
1458 $ rm -f older.pyc older.pyo
1459 $ rm -Rf __pycache__
1459 $ rm -Rf __pycache__
1460 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1460 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1461 > throw 2>&1 | egrep '^\*\*'
1461 > throw 2>&1 | egrep '^\*\*'
1462 ** Unknown exception encountered with possibly-broken third-party extension older
1462 ** Unknown exception encountered with possibly-broken third-party extension older
1463 ** which supports versions 1.9 of Mercurial.
1463 ** which supports versions 1.9 of Mercurial.
1464 ** Please disable older and try your action again.
1464 ** Please disable older and try your action again.
1465 ** If that fixes the bug please report it to the extension author.
1465 ** If that fixes the bug please report it to the extension author.
1466 ** Python * (glob)
1466 ** Python * (glob)
1467 ** Mercurial Distributed SCM (version 2.1)
1467 ** Mercurial Distributed SCM (version 2.1)
1468 ** Extensions loaded: throw, older
1468 ** Extensions loaded: throw, older
1469
1469
1470 Older extension is tested with current version, the other only with newer:
1470 Older extension is tested with current version, the other only with newer:
1471 $ echo "util.version = lambda:b'1.9.3'" >> older.py
1471 $ echo "util.version = lambda:b'1.9.3'" >> older.py
1472 $ rm -f older.pyc older.pyo
1472 $ rm -f older.pyc older.pyo
1473 $ rm -Rf __pycache__
1473 $ rm -Rf __pycache__
1474 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1474 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1475 > throw 2>&1 | egrep '^\*\*'
1475 > throw 2>&1 | egrep '^\*\*'
1476 ** Unknown exception encountered with possibly-broken third-party extension throw
1476 ** Unknown exception encountered with possibly-broken third-party extension throw
1477 ** which supports versions 2.1 of Mercurial.
1477 ** which supports versions 2.1 of Mercurial.
1478 ** Please disable throw and try your action again.
1478 ** Please disable throw and try your action again.
1479 ** If that fixes the bug please report it to http://example.com/bts
1479 ** If that fixes the bug please report it to http://example.com/bts
1480 ** Python * (glob)
1480 ** Python * (glob)
1481 ** Mercurial Distributed SCM (version 1.9.3)
1481 ** Mercurial Distributed SCM (version 1.9.3)
1482 ** Extensions loaded: throw, older
1482 ** Extensions loaded: throw, older
1483
1483
1484 Ability to point to a different point
1484 Ability to point to a different point
1485 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1485 $ hg --config extensions.throw=throw.py --config extensions.older=older.py \
1486 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1486 > --config ui.supportcontact='Your Local Goat Lenders' throw 2>&1 | egrep '^\*\*'
1487 ** unknown exception encountered, please report by visiting
1487 ** unknown exception encountered, please report by visiting
1488 ** Your Local Goat Lenders
1488 ** Your Local Goat Lenders
1489 ** Python * (glob)
1489 ** Python * (glob)
1490 ** Mercurial Distributed SCM (*) (glob)
1490 ** Mercurial Distributed SCM (*) (glob)
1491 ** Extensions loaded: throw, older
1491 ** Extensions loaded: throw, older
1492
1492
1493 Declare the version as supporting this hg version, show regular bts link:
1493 Declare the version as supporting this hg version, show regular bts link:
1494 $ hgver=`hg debuginstall -T '{hgver}'`
1494 $ hgver=`hg debuginstall -T '{hgver}'`
1495 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1495 $ echo 'testedwith = """'"$hgver"'"""' >> throw.py
1496 $ if [ -z "$hgver" ]; then
1496 $ if [ -z "$hgver" ]; then
1497 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1497 > echo "unable to fetch a mercurial version. Make sure __version__ is correct";
1498 > fi
1498 > fi
1499 $ rm -f throw.pyc throw.pyo
1499 $ rm -f throw.pyc throw.pyo
1500 $ rm -Rf __pycache__
1500 $ rm -Rf __pycache__
1501 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1501 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1502 ** unknown exception encountered, please report by visiting
1502 ** unknown exception encountered, please report by visiting
1503 ** https://mercurial-scm.org/wiki/BugTracker
1503 ** https://mercurial-scm.org/wiki/BugTracker
1504 ** Python * (glob)
1504 ** Python * (glob)
1505 ** Mercurial Distributed SCM (*) (glob)
1505 ** Mercurial Distributed SCM (*) (glob)
1506 ** Extensions loaded: throw
1506 ** Extensions loaded: throw
1507
1507
1508 Patch version is ignored during compatibility check
1508 Patch version is ignored during compatibility check
1509 $ echo "testedwith = b'3.2'" >> throw.py
1509 $ echo "testedwith = b'3.2'" >> throw.py
1510 $ echo "util.version = lambda:b'3.2.2'" >> throw.py
1510 $ echo "util.version = lambda:b'3.2.2'" >> throw.py
1511 $ rm -f throw.pyc throw.pyo
1511 $ rm -f throw.pyc throw.pyo
1512 $ rm -Rf __pycache__
1512 $ rm -Rf __pycache__
1513 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1513 $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
1514 ** unknown exception encountered, please report by visiting
1514 ** unknown exception encountered, please report by visiting
1515 ** https://mercurial-scm.org/wiki/BugTracker
1515 ** https://mercurial-scm.org/wiki/BugTracker
1516 ** Python * (glob)
1516 ** Python * (glob)
1517 ** Mercurial Distributed SCM (*) (glob)
1517 ** Mercurial Distributed SCM (*) (glob)
1518 ** Extensions loaded: throw
1518 ** Extensions loaded: throw
1519
1519
1520 Test version number support in 'hg version':
1520 Test version number support in 'hg version':
1521 $ echo '__version__ = (1, 2, 3)' >> throw.py
1521 $ echo '__version__ = (1, 2, 3)' >> throw.py
1522 $ rm -f throw.pyc throw.pyo
1522 $ rm -f throw.pyc throw.pyo
1523 $ rm -Rf __pycache__
1523 $ rm -Rf __pycache__
1524 $ hg version -v
1524 $ hg version -v
1525 Mercurial Distributed SCM (version *) (glob)
1525 Mercurial Distributed SCM (version *) (glob)
1526 (see https://mercurial-scm.org for more information)
1526 (see https://mercurial-scm.org for more information)
1527
1527
1528 Copyright (C) 2005-* Matt Mackall and others (glob)
1528 Copyright (C) 2005-* Matt Mackall and others (glob)
1529 This is free software; see the source for copying conditions. There is NO
1529 This is free software; see the source for copying conditions. There is NO
1530 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1530 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1531
1531
1532 Enabled extensions:
1532 Enabled extensions:
1533
1533
1534
1534
1535 $ hg version -v --config extensions.throw=throw.py
1535 $ hg version -v --config extensions.throw=throw.py
1536 Mercurial Distributed SCM (version *) (glob)
1536 Mercurial Distributed SCM (version *) (glob)
1537 (see https://mercurial-scm.org for more information)
1537 (see https://mercurial-scm.org for more information)
1538
1538
1539 Copyright (C) 2005-* Matt Mackall and others (glob)
1539 Copyright (C) 2005-* Matt Mackall and others (glob)
1540 This is free software; see the source for copying conditions. There is NO
1540 This is free software; see the source for copying conditions. There is NO
1541 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1541 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1542
1542
1543 Enabled extensions:
1543 Enabled extensions:
1544
1544
1545 throw external 1.2.3
1545 throw external 1.2.3
1546 $ echo 'getversion = lambda: b"1.twentythree"' >> throw.py
1546 $ echo 'getversion = lambda: b"1.twentythree"' >> throw.py
1547 $ rm -f throw.pyc throw.pyo
1547 $ rm -f throw.pyc throw.pyo
1548 $ rm -Rf __pycache__
1548 $ rm -Rf __pycache__
1549 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1549 $ hg version -v --config extensions.throw=throw.py --config extensions.strip=
1550 Mercurial Distributed SCM (version *) (glob)
1550 Mercurial Distributed SCM (version *) (glob)
1551 (see https://mercurial-scm.org for more information)
1551 (see https://mercurial-scm.org for more information)
1552
1552
1553 Copyright (C) 2005-* Matt Mackall and others (glob)
1553 Copyright (C) 2005-* Matt Mackall and others (glob)
1554 This is free software; see the source for copying conditions. There is NO
1554 This is free software; see the source for copying conditions. There is NO
1555 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1555 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1556
1556
1557 Enabled extensions:
1557 Enabled extensions:
1558
1558
1559 throw external 1.twentythree
1559 throw external 1.twentythree
1560 strip internal
1560 strip internal
1561
1561
1562 $ hg version -q --config extensions.throw=throw.py
1562 $ hg version -q --config extensions.throw=throw.py
1563 Mercurial Distributed SCM (version *) (glob)
1563 Mercurial Distributed SCM (version *) (glob)
1564
1564
1565 Test template output:
1565 Test template output:
1566
1566
1567 $ hg version --config extensions.strip= -T'{extensions}'
1567 $ hg version --config extensions.strip= -T'{extensions}'
1568 strip
1568 strip
1569
1569
1570 Test JSON output of version:
1570 Test JSON output of version:
1571
1571
1572 $ hg version -Tjson
1572 $ hg version -Tjson
1573 [
1573 [
1574 {
1574 {
1575 "extensions": [],
1575 "extensions": [],
1576 "ver": "*" (glob)
1576 "ver": "*" (glob)
1577 }
1577 }
1578 ]
1578 ]
1579
1579
1580 $ hg version --config extensions.throw=throw.py -Tjson
1580 $ hg version --config extensions.throw=throw.py -Tjson
1581 [
1581 [
1582 {
1582 {
1583 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1583 "extensions": [{"bundled": false, "name": "throw", "ver": "1.twentythree"}],
1584 "ver": "3.2.2"
1584 "ver": "3.2.2"
1585 }
1585 }
1586 ]
1586 ]
1587
1587
1588 $ hg version --config extensions.strip= -Tjson
1588 $ hg version --config extensions.strip= -Tjson
1589 [
1589 [
1590 {
1590 {
1591 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1591 "extensions": [{"bundled": true, "name": "strip", "ver": null}],
1592 "ver": "*" (glob)
1592 "ver": "*" (glob)
1593 }
1593 }
1594 ]
1594 ]
1595
1595
1596 Test template output of version:
1596 Test template output of version:
1597
1597
1598 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1598 $ hg version --config extensions.throw=throw.py --config extensions.strip= \
1599 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1599 > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}'
1600 throw 1.twentythree (external)
1600 throw 1.twentythree (external)
1601 strip (internal)
1601 strip (internal)
1602
1602
1603 Refuse to load extensions with minimum version requirements
1603 Refuse to load extensions with minimum version requirements
1604
1604
1605 $ cat > minversion1.py << EOF
1605 $ cat > minversion1.py << EOF
1606 > from mercurial import util
1606 > from mercurial import util
1607 > util.version = lambda: b'3.5.2'
1607 > util.version = lambda: b'3.5.2'
1608 > minimumhgversion = b'3.6'
1608 > minimumhgversion = b'3.6'
1609 > EOF
1609 > EOF
1610 $ hg --config extensions.minversion=minversion1.py version
1610 $ hg --config extensions.minversion=minversion1.py version
1611 (third party extension minversion requires version 3.6 or newer of Mercurial (current: 3.5.2); disabling)
1611 (third party extension minversion requires version 3.6 or newer of Mercurial (current: 3.5.2); disabling)
1612 Mercurial Distributed SCM (version 3.5.2)
1612 Mercurial Distributed SCM (version 3.5.2)
1613 (see https://mercurial-scm.org for more information)
1613 (see https://mercurial-scm.org for more information)
1614
1614
1615 Copyright (C) 2005-* Matt Mackall and others (glob)
1615 Copyright (C) 2005-* Matt Mackall and others (glob)
1616 This is free software; see the source for copying conditions. There is NO
1616 This is free software; see the source for copying conditions. There is NO
1617 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1617 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1618
1618
1619 $ cat > minversion2.py << EOF
1619 $ cat > minversion2.py << EOF
1620 > from mercurial import util
1620 > from mercurial import util
1621 > util.version = lambda: b'3.6'
1621 > util.version = lambda: b'3.6'
1622 > minimumhgversion = b'3.7'
1622 > minimumhgversion = b'3.7'
1623 > EOF
1623 > EOF
1624 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1624 $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third'
1625 (third party extension minversion requires version 3.7 or newer of Mercurial (current: 3.6); disabling)
1625 (third party extension minversion requires version 3.7 or newer of Mercurial (current: 3.6); disabling)
1626
1626
1627 Can load version that is only off by point release
1627 Can load version that is only off by point release
1628
1628
1629 $ cat > minversion2.py << EOF
1629 $ cat > minversion2.py << EOF
1630 > from mercurial import util
1630 > from mercurial import util
1631 > util.version = lambda: b'3.6.1'
1631 > util.version = lambda: b'3.6.1'
1632 > minimumhgversion = b'3.6'
1632 > minimumhgversion = b'3.6'
1633 > EOF
1633 > EOF
1634 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1634 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1635 [1]
1635 [1]
1636
1636
1637 Can load minimum version identical to current
1637 Can load minimum version identical to current
1638
1638
1639 $ cat > minversion3.py << EOF
1639 $ cat > minversion3.py << EOF
1640 > from mercurial import util
1640 > from mercurial import util
1641 > util.version = lambda: b'3.5'
1641 > util.version = lambda: b'3.5'
1642 > minimumhgversion = b'3.5'
1642 > minimumhgversion = b'3.5'
1643 > EOF
1643 > EOF
1644 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1644 $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third'
1645 [1]
1645 [1]
1646
1646
1647 Restore HGRCPATH
1647 Restore HGRCPATH
1648
1648
1649 $ HGRCPATH=$ORGHGRCPATH
1649 $ HGRCPATH=$ORGHGRCPATH
1650 $ export HGRCPATH
1650 $ export HGRCPATH
1651
1651
1652 Commands handling multiple repositories at a time should invoke only
1652 Commands handling multiple repositories at a time should invoke only
1653 "reposetup()" of extensions enabling in the target repository.
1653 "reposetup()" of extensions enabling in the target repository.
1654
1654
1655 $ mkdir reposetup-test
1655 $ mkdir reposetup-test
1656 $ cd reposetup-test
1656 $ cd reposetup-test
1657
1657
1658 $ cat > $TESTTMP/reposetuptest.py <<EOF
1658 $ cat > $TESTTMP/reposetuptest.py <<EOF
1659 > from mercurial import extensions
1659 > from mercurial import extensions
1660 > def reposetup(ui, repo):
1660 > def reposetup(ui, repo):
1661 > ui.write(b'reposetup() for %s\n' % (repo.root))
1661 > ui.write(b'reposetup() for %s\n' % (repo.root))
1662 > ui.flush()
1662 > ui.flush()
1663 > EOF
1663 > EOF
1664 $ hg init src
1664 $ hg init src
1665 $ echo a > src/a
1665 $ echo a > src/a
1666 $ hg -R src commit -Am '#0 at src/a'
1666 $ hg -R src commit -Am '#0 at src/a'
1667 adding a
1667 adding a
1668 $ echo '[extensions]' >> src/.hg/hgrc
1668 $ echo '[extensions]' >> src/.hg/hgrc
1669 $ echo '# enable extension locally' >> src/.hg/hgrc
1669 $ echo '# enable extension locally' >> src/.hg/hgrc
1670 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1670 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> src/.hg/hgrc
1671 $ hg -R src status
1671 $ hg -R src status
1672 reposetup() for $TESTTMP/reposetup-test/src
1672 reposetup() for $TESTTMP/reposetup-test/src
1673 reposetup() for $TESTTMP/reposetup-test/src (chg !)
1673 reposetup() for $TESTTMP/reposetup-test/src (chg !)
1674
1674
1675 #if no-extraextensions
1675 #if no-extraextensions
1676 $ hg --cwd src debugextensions
1676 $ hg --cwd src debugextensions
1677 reposetup() for $TESTTMP/reposetup-test/src
1677 reposetup() for $TESTTMP/reposetup-test/src
1678 dodo (untested!)
1678 dodo (untested!)
1679 dudu (untested!)
1679 dudu (untested!)
1680 mq
1680 mq
1681 reposetuptest (untested!)
1681 reposetuptest (untested!)
1682 strip
1682 strip
1683 #endif
1683 #endif
1684
1684
1685 $ hg clone -U src clone-dst1
1685 $ hg clone -U src clone-dst1
1686 reposetup() for $TESTTMP/reposetup-test/src
1686 reposetup() for $TESTTMP/reposetup-test/src
1687 $ hg init push-dst1
1687 $ hg init push-dst1
1688 $ hg -q -R src push push-dst1
1688 $ hg -q -R src push push-dst1
1689 reposetup() for $TESTTMP/reposetup-test/src
1689 reposetup() for $TESTTMP/reposetup-test/src
1690 $ hg init pull-src1
1690 $ hg init pull-src1
1691 $ hg -q -R pull-src1 pull src
1691 $ hg -q -R pull-src1 pull src
1692 reposetup() for $TESTTMP/reposetup-test/src
1692 reposetup() for $TESTTMP/reposetup-test/src
1693
1693
1694 $ cat <<EOF >> $HGRCPATH
1694 $ cat <<EOF >> $HGRCPATH
1695 > [extensions]
1695 > [extensions]
1696 > # disable extension globally and explicitly
1696 > # disable extension globally and explicitly
1697 > reposetuptest = !
1697 > reposetuptest = !
1698 > EOF
1698 > EOF
1699 $ hg clone -U src clone-dst2
1699 $ hg clone -U src clone-dst2
1700 reposetup() for $TESTTMP/reposetup-test/src
1700 reposetup() for $TESTTMP/reposetup-test/src
1701 $ hg init push-dst2
1701 $ hg init push-dst2
1702 $ hg -q -R src push push-dst2
1702 $ hg -q -R src push push-dst2
1703 reposetup() for $TESTTMP/reposetup-test/src
1703 reposetup() for $TESTTMP/reposetup-test/src
1704 $ hg init pull-src2
1704 $ hg init pull-src2
1705 $ hg -q -R pull-src2 pull src
1705 $ hg -q -R pull-src2 pull src
1706 reposetup() for $TESTTMP/reposetup-test/src
1706 reposetup() for $TESTTMP/reposetup-test/src
1707
1707
1708 $ cat <<EOF >> $HGRCPATH
1708 $ cat <<EOF >> $HGRCPATH
1709 > [extensions]
1709 > [extensions]
1710 > # enable extension globally
1710 > # enable extension globally
1711 > reposetuptest = $TESTTMP/reposetuptest.py
1711 > reposetuptest = $TESTTMP/reposetuptest.py
1712 > EOF
1712 > EOF
1713 $ hg clone -U src clone-dst3
1713 $ hg clone -U src clone-dst3
1714 reposetup() for $TESTTMP/reposetup-test/src
1714 reposetup() for $TESTTMP/reposetup-test/src
1715 reposetup() for $TESTTMP/reposetup-test/clone-dst3
1715 reposetup() for $TESTTMP/reposetup-test/clone-dst3
1716 $ hg init push-dst3
1716 $ hg init push-dst3
1717 reposetup() for $TESTTMP/reposetup-test/push-dst3
1717 reposetup() for $TESTTMP/reposetup-test/push-dst3
1718 $ hg -q -R src push push-dst3
1718 $ hg -q -R src push push-dst3
1719 reposetup() for $TESTTMP/reposetup-test/src
1719 reposetup() for $TESTTMP/reposetup-test/src
1720 reposetup() for $TESTTMP/reposetup-test/push-dst3
1720 reposetup() for $TESTTMP/reposetup-test/push-dst3
1721 $ hg init pull-src3
1721 $ hg init pull-src3
1722 reposetup() for $TESTTMP/reposetup-test/pull-src3
1722 reposetup() for $TESTTMP/reposetup-test/pull-src3
1723 $ hg -q -R pull-src3 pull src
1723 $ hg -q -R pull-src3 pull src
1724 reposetup() for $TESTTMP/reposetup-test/pull-src3
1724 reposetup() for $TESTTMP/reposetup-test/pull-src3
1725 reposetup() for $TESTTMP/reposetup-test/src
1725 reposetup() for $TESTTMP/reposetup-test/src
1726
1726
1727 $ echo '[extensions]' >> src/.hg/hgrc
1727 $ echo '[extensions]' >> src/.hg/hgrc
1728 $ echo '# disable extension locally' >> src/.hg/hgrc
1728 $ echo '# disable extension locally' >> src/.hg/hgrc
1729 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1729 $ echo 'reposetuptest = !' >> src/.hg/hgrc
1730 $ hg clone -U src clone-dst4
1730 $ hg clone -U src clone-dst4
1731 reposetup() for $TESTTMP/reposetup-test/clone-dst4
1731 reposetup() for $TESTTMP/reposetup-test/clone-dst4
1732 $ hg init push-dst4
1732 $ hg init push-dst4
1733 reposetup() for $TESTTMP/reposetup-test/push-dst4
1733 reposetup() for $TESTTMP/reposetup-test/push-dst4
1734 $ hg -q -R src push push-dst4
1734 $ hg -q -R src push push-dst4
1735 reposetup() for $TESTTMP/reposetup-test/push-dst4
1735 reposetup() for $TESTTMP/reposetup-test/push-dst4
1736 $ hg init pull-src4
1736 $ hg init pull-src4
1737 reposetup() for $TESTTMP/reposetup-test/pull-src4
1737 reposetup() for $TESTTMP/reposetup-test/pull-src4
1738 $ hg -q -R pull-src4 pull src
1738 $ hg -q -R pull-src4 pull src
1739 reposetup() for $TESTTMP/reposetup-test/pull-src4
1739 reposetup() for $TESTTMP/reposetup-test/pull-src4
1740
1740
1741 disabling in command line overlays with all configuration
1741 disabling in command line overlays with all configuration
1742 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1742 $ hg --config extensions.reposetuptest=! clone -U src clone-dst5
1743 $ hg --config extensions.reposetuptest=! init push-dst5
1743 $ hg --config extensions.reposetuptest=! init push-dst5
1744 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1744 $ hg --config extensions.reposetuptest=! -q -R src push push-dst5
1745 $ hg --config extensions.reposetuptest=! init pull-src5
1745 $ hg --config extensions.reposetuptest=! init pull-src5
1746 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1746 $ hg --config extensions.reposetuptest=! -q -R pull-src5 pull src
1747
1747
1748 $ cat <<EOF >> $HGRCPATH
1748 $ cat <<EOF >> $HGRCPATH
1749 > [extensions]
1749 > [extensions]
1750 > # disable extension globally and explicitly
1750 > # disable extension globally and explicitly
1751 > reposetuptest = !
1751 > reposetuptest = !
1752 > EOF
1752 > EOF
1753 $ hg init parent
1753 $ hg init parent
1754 $ hg init parent/sub1
1754 $ hg init parent/sub1
1755 $ echo 1 > parent/sub1/1
1755 $ echo 1 > parent/sub1/1
1756 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1756 $ hg -R parent/sub1 commit -Am '#0 at parent/sub1'
1757 adding 1
1757 adding 1
1758 $ hg init parent/sub2
1758 $ hg init parent/sub2
1759 $ hg init parent/sub2/sub21
1759 $ hg init parent/sub2/sub21
1760 $ echo 21 > parent/sub2/sub21/21
1760 $ echo 21 > parent/sub2/sub21/21
1761 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1761 $ hg -R parent/sub2/sub21 commit -Am '#0 at parent/sub2/sub21'
1762 adding 21
1762 adding 21
1763 $ cat > parent/sub2/.hgsub <<EOF
1763 $ cat > parent/sub2/.hgsub <<EOF
1764 > sub21 = sub21
1764 > sub21 = sub21
1765 > EOF
1765 > EOF
1766 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1766 $ hg -R parent/sub2 commit -Am '#0 at parent/sub2'
1767 adding .hgsub
1767 adding .hgsub
1768 $ hg init parent/sub3
1768 $ hg init parent/sub3
1769 $ echo 3 > parent/sub3/3
1769 $ echo 3 > parent/sub3/3
1770 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1770 $ hg -R parent/sub3 commit -Am '#0 at parent/sub3'
1771 adding 3
1771 adding 3
1772 $ cat > parent/.hgsub <<EOF
1772 $ cat > parent/.hgsub <<EOF
1773 > sub1 = sub1
1773 > sub1 = sub1
1774 > sub2 = sub2
1774 > sub2 = sub2
1775 > sub3 = sub3
1775 > sub3 = sub3
1776 > EOF
1776 > EOF
1777 $ hg -R parent commit -Am '#0 at parent'
1777 $ hg -R parent commit -Am '#0 at parent'
1778 adding .hgsub
1778 adding .hgsub
1779 $ echo '[extensions]' >> parent/.hg/hgrc
1779 $ echo '[extensions]' >> parent/.hg/hgrc
1780 $ echo '# enable extension locally' >> parent/.hg/hgrc
1780 $ echo '# enable extension locally' >> parent/.hg/hgrc
1781 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1781 $ echo "reposetuptest = $TESTTMP/reposetuptest.py" >> parent/.hg/hgrc
1782 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1782 $ cp parent/.hg/hgrc parent/sub2/.hg/hgrc
1783 $ hg -R parent status -S -A
1783 $ hg -R parent status -S -A
1784 reposetup() for $TESTTMP/reposetup-test/parent
1784 reposetup() for $TESTTMP/reposetup-test/parent
1785 reposetup() for $TESTTMP/reposetup-test/parent/sub2
1785 reposetup() for $TESTTMP/reposetup-test/parent/sub2
1786 C .hgsub
1786 C .hgsub
1787 C .hgsubstate
1787 C .hgsubstate
1788 C sub1/1
1788 C sub1/1
1789 C sub2/.hgsub
1789 C sub2/.hgsub
1790 C sub2/.hgsubstate
1790 C sub2/.hgsubstate
1791 C sub2/sub21/21
1791 C sub2/sub21/21
1792 C sub3/3
1792 C sub3/3
1793
1793
1794 $ cd ..
1794 $ cd ..
1795
1795
1796 Prohibit registration of commands that don't use @command (issue5137)
1796 Prohibit registration of commands that don't use @command (issue5137)
1797
1797
1798 $ hg init deprecated
1798 $ hg init deprecated
1799 $ cd deprecated
1799 $ cd deprecated
1800
1800
1801 $ cat <<EOF > deprecatedcmd.py
1801 $ cat <<EOF > deprecatedcmd.py
1802 > def deprecatedcmd(repo, ui):
1802 > def deprecatedcmd(repo, ui):
1803 > pass
1803 > pass
1804 > cmdtable = {
1804 > cmdtable = {
1805 > b'deprecatedcmd': (deprecatedcmd, [], b''),
1805 > b'deprecatedcmd': (deprecatedcmd, [], b''),
1806 > }
1806 > }
1807 > EOF
1807 > EOF
1808 $ cat <<EOF > .hg/hgrc
1808 $ cat <<EOF > .hg/hgrc
1809 > [extensions]
1809 > [extensions]
1810 > deprecatedcmd = `pwd`/deprecatedcmd.py
1810 > deprecatedcmd = `pwd`/deprecatedcmd.py
1811 > mq = !
1811 > mq = !
1812 > hgext.mq = !
1812 > hgext.mq = !
1813 > hgext/mq = !
1813 > hgext/mq = !
1814 > EOF
1814 > EOF
1815
1815
1816 $ hg deprecatedcmd > /dev/null
1816 $ hg deprecatedcmd > /dev/null
1817 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1817 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1818 *** (use @command decorator to register 'deprecatedcmd')
1818 *** (use @command decorator to register 'deprecatedcmd')
1819 hg: unknown command 'deprecatedcmd'
1819 hg: unknown command 'deprecatedcmd'
1820 (use 'hg help' for a list of commands)
1820 (use 'hg help' for a list of commands)
1821 [255]
1821 [255]
1822
1822
1823 the extension shouldn't be loaded at all so the mq works:
1823 the extension shouldn't be loaded at all so the mq works:
1824
1824
1825 $ hg qseries --config extensions.mq= > /dev/null
1825 $ hg qseries --config extensions.mq= > /dev/null
1826 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1826 *** failed to import extension deprecatedcmd from $TESTTMP/deprecated/deprecatedcmd.py: missing attributes: norepo, optionalrepo, inferrepo
1827 *** (use @command decorator to register 'deprecatedcmd')
1827 *** (use @command decorator to register 'deprecatedcmd')
1828
1828
1829 $ cd ..
1829 $ cd ..
1830
1830
1831 Test synopsis and docstring extending
1831 Test synopsis and docstring extending
1832
1832
1833 $ hg init exthelp
1833 $ hg init exthelp
1834 $ cat > exthelp.py <<EOF
1834 $ cat > exthelp.py <<EOF
1835 > from mercurial import commands, extensions
1835 > from mercurial import commands, extensions
1836 > def exbookmarks(orig, *args, **opts):
1836 > def exbookmarks(orig, *args, **opts):
1837 > return orig(*args, **opts)
1837 > return orig(*args, **opts)
1838 > def uisetup(ui):
1838 > def uisetup(ui):
1839 > synopsis = b' GREPME [--foo] [-x]'
1839 > synopsis = b' GREPME [--foo] [-x]'
1840 > docstring = '''
1840 > docstring = '''
1841 > GREPME make sure that this is in the help!
1841 > GREPME make sure that this is in the help!
1842 > '''
1842 > '''
1843 > extensions.wrapcommand(commands.table, b'bookmarks', exbookmarks,
1843 > extensions.wrapcommand(commands.table, b'bookmarks', exbookmarks,
1844 > synopsis, docstring)
1844 > synopsis, docstring)
1845 > EOF
1845 > EOF
1846 $ abspath=`pwd`/exthelp.py
1846 $ abspath=`pwd`/exthelp.py
1847 $ echo '[extensions]' >> $HGRCPATH
1847 $ echo '[extensions]' >> $HGRCPATH
1848 $ echo "exthelp = $abspath" >> $HGRCPATH
1848 $ echo "exthelp = $abspath" >> $HGRCPATH
1849 $ cd exthelp
1849 $ cd exthelp
1850 $ hg help bookmarks | grep GREPME
1850 $ hg help bookmarks | grep GREPME
1851 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1851 hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x]
1852 GREPME make sure that this is in the help!
1852 GREPME make sure that this is in the help!
1853 $ cd ..
1853 $ cd ..
1854
1854
1855 Show deprecation warning for the use of cmdutil.command
1855 Show deprecation warning for the use of cmdutil.command
1856
1856
1857 $ cat > nonregistrar.py <<EOF
1857 $ cat > nonregistrar.py <<EOF
1858 > from mercurial import cmdutil
1858 > from mercurial import cmdutil
1859 > cmdtable = {}
1859 > cmdtable = {}
1860 > command = cmdutil.command(cmdtable)
1860 > command = cmdutil.command(cmdtable)
1861 > @command(b'foo', [], norepo=True)
1861 > @command(b'foo', [], norepo=True)
1862 > def foo(ui):
1862 > def foo(ui):
1863 > pass
1863 > pass
1864 > EOF
1864 > EOF
1865
1865
1866 Prohibit the use of unicode strings as the default value of options
1866 Prohibit the use of unicode strings as the default value of options
1867
1867
1868 $ hg init $TESTTMP/opt-unicode-default
1868 $ hg init $TESTTMP/opt-unicode-default
1869
1869
1870 $ cat > $TESTTMP/test_unicode_default_value.py << EOF
1870 $ cat > $TESTTMP/test_unicode_default_value.py << EOF
1871 > from __future__ import print_function
1871 > from __future__ import print_function
1872 > from mercurial import registrar
1872 > from mercurial import registrar
1873 > cmdtable = {}
1873 > cmdtable = {}
1874 > command = registrar.command(cmdtable)
1874 > command = registrar.command(cmdtable)
1875 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]')
1875 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]')
1876 > def ext(*args, **opts):
1876 > def ext(*args, **opts):
1877 > print(opts[b'opt'], flush=True)
1877 > print(opts[b'opt'], flush=True)
1878 > EOF
1878 > EOF
1879 $ "$PYTHON" $TESTTMP/unflush.py $TESTTMP/test_unicode_default_value.py
1879 $ "$PYTHON" $TESTTMP/unflush.py $TESTTMP/test_unicode_default_value.py
1880 $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF
1880 $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF
1881 > [extensions]
1881 > [extensions]
1882 > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py
1882 > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py
1883 > EOF
1883 > EOF
1884 $ hg -R $TESTTMP/opt-unicode-default dummy
1884 $ hg -R $TESTTMP/opt-unicode-default dummy
1885 *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode *'value' found in cmdtable.dummy (glob)
1885 *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode *'value' found in cmdtable.dummy (glob)
1886 *** (use b'' to make it byte string)
1886 *** (use b'' to make it byte string)
1887 hg: unknown command 'dummy'
1887 hg: unknown command 'dummy'
1888 (did you mean summary?)
1888 (did you mean summary?)
1889 [255]
1889 [255]
@@ -1,177 +1,177 b''
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
1 This tests if hgweb and hgwebdir still work if the REQUEST_URI variable is
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
2 no longer passed with the request. Instead, SCRIPT_NAME and PATH_INFO
3 should be used from d74fc8dec2b4 onward to route the request.
3 should be used from d74fc8dec2b4 onward to route the request.
4
4
5 $ hg init repo
5 $ hg init repo
6 $ cd repo
6 $ cd repo
7 $ echo foo > bar
7 $ echo foo > bar
8 $ hg add bar
8 $ hg add bar
9 $ hg commit -m "test"
9 $ hg commit -m "test"
10 $ hg tip
10 $ hg tip
11 changeset: 0:61c9426e69fe
11 changeset: 0:61c9426e69fe
12 tag: tip
12 tag: tip
13 user: test
13 user: test
14 date: Thu Jan 01 00:00:00 1970 +0000
14 date: Thu Jan 01 00:00:00 1970 +0000
15 summary: test
15 summary: test
16
16
17 $ cat > request.py <<EOF
17 $ cat > request.py <<EOF
18 > from __future__ import absolute_import
18 > from __future__ import absolute_import
19 > import os
19 > import os
20 > import sys
20 > import sys
21 > from mercurial import (
21 > from mercurial import (
22 > encoding,
22 > encoding,
23 > hgweb,
23 > hgweb,
24 > util,
24 > util,
25 > )
25 > )
26 > stringio = util.stringio
26 > stringio = util.stringio
27 >
27 >
28 > errors = stringio()
28 > errors = stringio()
29 > input = stringio()
29 > input = stringio()
30 >
30 >
31 > def startrsp(status, headers):
31 > def startrsp(status, headers):
32 > print('---- STATUS')
32 > print('---- STATUS')
33 > print(status)
33 > print(status)
34 > print('---- HEADERS')
34 > print('---- HEADERS')
35 > print([i for i in headers if i[0] != 'ETag'])
35 > print([i for i in headers if i[0] != 'ETag'])
36 > print('---- DATA')
36 > print('---- DATA')
37 > return output.write
37 > return output.write
38 >
38 >
39 > env = {
39 > env = {
40 > 'wsgi.version': (1, 0),
40 > 'wsgi.version': (1, 0),
41 > 'wsgi.url_scheme': 'http',
41 > 'wsgi.url_scheme': 'http',
42 > 'wsgi.errors': errors,
42 > 'wsgi.errors': errors,
43 > 'wsgi.input': input,
43 > 'wsgi.input': input,
44 > 'wsgi.multithread': False,
44 > 'wsgi.multithread': False,
45 > 'wsgi.multiprocess': False,
45 > 'wsgi.multiprocess': False,
46 > 'wsgi.run_once': False,
46 > 'wsgi.run_once': False,
47 > 'REQUEST_METHOD': 'GET',
47 > 'REQUEST_METHOD': 'GET',
48 > 'SCRIPT_NAME': '',
48 > 'SCRIPT_NAME': '',
49 > 'SERVER_NAME': '$LOCALIP',
49 > 'SERVER_NAME': '$LOCALIP',
50 > 'SERVER_PORT': os.environ['HGPORT'],
50 > 'SERVER_PORT': os.environ['HGPORT'],
51 > 'SERVER_PROTOCOL': 'HTTP/1.0'
51 > 'SERVER_PROTOCOL': 'HTTP/1.0'
52 > }
52 > }
53 >
53 >
54 > def process(app):
54 > def process(app):
55 > content = app(env, startrsp)
55 > content = app(env, startrsp)
56 > sys.stdout.write(encoding.strfromlocal(output.getvalue()))
56 > sys.stdout.write(encoding.strfromlocal(output.getvalue()))
57 > sys.stdout.write(encoding.strfromlocal(b''.join(content)))
57 > sys.stdout.write(encoding.strfromlocal(b''.join(content)))
58 > getattr(content, 'close', lambda : None)()
58 > getattr(content, 'close', lambda : None)()
59 > print('---- ERRORS')
59 > print('---- ERRORS')
60 > print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff
60 > print(encoding.strfromlocal(errors.getvalue())) # avoid b'' output diff
61 >
61 >
62 > output = stringio()
62 > output = stringio()
63 > env['PATH_INFO'] = '/'
63 > env['PATH_INFO'] = '/'
64 > env['QUERY_STRING'] = 'style=atom'
64 > env['QUERY_STRING'] = 'style=atom'
65 > process(hgweb.hgweb(b'.', name = b'repo'))
65 > process(hgweb.hgweb(b'.', name=b'repo'))
66 >
66 >
67 > output = stringio()
67 > output = stringio()
68 > env['PATH_INFO'] = '/file/tip/'
68 > env['PATH_INFO'] = '/file/tip/'
69 > env['QUERY_STRING'] = 'style=raw'
69 > env['QUERY_STRING'] = 'style=raw'
70 > process(hgweb.hgweb(b'.', name = b'repo'))
70 > process(hgweb.hgweb(b'.', name=b'repo'))
71 >
71 >
72 > output = stringio()
72 > output = stringio()
73 > env['PATH_INFO'] = '/'
73 > env['PATH_INFO'] = '/'
74 > env['QUERY_STRING'] = 'style=raw'
74 > env['QUERY_STRING'] = 'style=raw'
75 > process(hgweb.hgwebdir({b'repo': b'.'}))
75 > process(hgweb.hgwebdir({b'repo': b'.'}))
76 >
76 >
77 > output = stringio()
77 > output = stringio()
78 > env['PATH_INFO'] = '/repo/file/tip/'
78 > env['PATH_INFO'] = '/repo/file/tip/'
79 > env['QUERY_STRING'] = 'style=raw'
79 > env['QUERY_STRING'] = 'style=raw'
80 > process(hgweb.hgwebdir({b'repo': b'.'}))
80 > process(hgweb.hgwebdir({b'repo': b'.'}))
81 > EOF
81 > EOF
82 $ "$PYTHON" request.py
82 $ "$PYTHON" request.py
83 ---- STATUS
83 ---- STATUS
84 200 Script output follows
84 200 Script output follows
85 ---- HEADERS
85 ---- HEADERS
86 [('Content-Type', 'application/atom+xml; charset=ascii')]
86 [('Content-Type', 'application/atom+xml; charset=ascii')]
87 ---- DATA
87 ---- DATA
88 <?xml version="1.0" encoding="ascii"?>
88 <?xml version="1.0" encoding="ascii"?>
89 <feed xmlns="http://www.w3.org/2005/Atom">
89 <feed xmlns="http://www.w3.org/2005/Atom">
90 <!-- Changelog -->
90 <!-- Changelog -->
91 <id>http://$LOCALIP:$HGPORT/</id> (glob)
91 <id>http://$LOCALIP:$HGPORT/</id> (glob)
92 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
92 <link rel="self" href="http://$LOCALIP:$HGPORT/atom-log"/> (glob)
93 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
93 <link rel="alternate" href="http://$LOCALIP:$HGPORT/"/> (glob)
94 <title>repo Changelog</title>
94 <title>repo Changelog</title>
95 <updated>1970-01-01T00:00:00+00:00</updated>
95 <updated>1970-01-01T00:00:00+00:00</updated>
96
96
97 <entry>
97 <entry>
98 <title>[default] test</title>
98 <title>[default] test</title>
99 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
99 <id>http://$LOCALIP:$HGPORT/#changeset-61c9426e69fef294feed5e2bbfc97d39944a5b1c</id> (glob)
100 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
100 <link href="http://$LOCALIP:$HGPORT/rev/61c9426e69fe"/> (glob)
101 <author>
101 <author>
102 <name>test</name>
102 <name>test</name>
103 <email>&#116;&#101;&#115;&#116;</email>
103 <email>&#116;&#101;&#115;&#116;</email>
104 </author>
104 </author>
105 <updated>1970-01-01T00:00:00+00:00</updated>
105 <updated>1970-01-01T00:00:00+00:00</updated>
106 <published>1970-01-01T00:00:00+00:00</published>
106 <published>1970-01-01T00:00:00+00:00</published>
107 <content type="xhtml">
107 <content type="xhtml">
108 <table xmlns="http://www.w3.org/1999/xhtml">
108 <table xmlns="http://www.w3.org/1999/xhtml">
109 <tr>
109 <tr>
110 <th style="text-align:left;">changeset</th>
110 <th style="text-align:left;">changeset</th>
111 <td>61c9426e69fe</td>
111 <td>61c9426e69fe</td>
112 </tr>
112 </tr>
113 <tr>
113 <tr>
114 <th style="text-align:left;">branch</th>
114 <th style="text-align:left;">branch</th>
115 <td>default</td>
115 <td>default</td>
116 </tr>
116 </tr>
117 <tr>
117 <tr>
118 <th style="text-align:left;">bookmark</th>
118 <th style="text-align:left;">bookmark</th>
119 <td></td>
119 <td></td>
120 </tr>
120 </tr>
121 <tr>
121 <tr>
122 <th style="text-align:left;">tag</th>
122 <th style="text-align:left;">tag</th>
123 <td>tip</td>
123 <td>tip</td>
124 </tr>
124 </tr>
125 <tr>
125 <tr>
126 <th style="text-align:left;">user</th>
126 <th style="text-align:left;">user</th>
127 <td>&#116;&#101;&#115;&#116;</td>
127 <td>&#116;&#101;&#115;&#116;</td>
128 </tr>
128 </tr>
129 <tr>
129 <tr>
130 <th style="text-align:left;vertical-align:top;">description</th>
130 <th style="text-align:left;vertical-align:top;">description</th>
131 <td>test</td>
131 <td>test</td>
132 </tr>
132 </tr>
133 <tr>
133 <tr>
134 <th style="text-align:left;vertical-align:top;">files</th>
134 <th style="text-align:left;vertical-align:top;">files</th>
135 <td>bar<br /></td>
135 <td>bar<br /></td>
136 </tr>
136 </tr>
137 </table>
137 </table>
138 </content>
138 </content>
139 </entry>
139 </entry>
140
140
141 </feed>
141 </feed>
142 ---- ERRORS
142 ---- ERRORS
143
143
144 ---- STATUS
144 ---- STATUS
145 200 Script output follows
145 200 Script output follows
146 ---- HEADERS
146 ---- HEADERS
147 [('Content-Type', 'text/plain; charset=ascii')]
147 [('Content-Type', 'text/plain; charset=ascii')]
148 ---- DATA
148 ---- DATA
149
149
150 -rw-r--r-- 4 bar
150 -rw-r--r-- 4 bar
151
151
152
152
153 ---- ERRORS
153 ---- ERRORS
154
154
155 ---- STATUS
155 ---- STATUS
156 200 Script output follows
156 200 Script output follows
157 ---- HEADERS
157 ---- HEADERS
158 [('Content-Type', 'text/plain; charset=ascii')]
158 [('Content-Type', 'text/plain; charset=ascii')]
159 ---- DATA
159 ---- DATA
160
160
161 /repo/
161 /repo/
162
162
163 ---- ERRORS
163 ---- ERRORS
164
164
165 ---- STATUS
165 ---- STATUS
166 200 Script output follows
166 200 Script output follows
167 ---- HEADERS
167 ---- HEADERS
168 [('Content-Type', 'text/plain; charset=ascii')]
168 [('Content-Type', 'text/plain; charset=ascii')]
169 ---- DATA
169 ---- DATA
170
170
171 -rw-r--r-- 4 bar
171 -rw-r--r-- 4 bar
172
172
173
173
174 ---- ERRORS
174 ---- ERRORS
175
175
176
176
177 $ cd ..
177 $ cd ..
@@ -1,129 +1,129 b''
1 Test applying context diffs
1 Test applying context diffs
2
2
3 $ cat > writepatterns.py <<EOF
3 $ cat > writepatterns.py <<EOF
4 > import sys
4 > import sys
5 >
5 >
6 > path = sys.argv[1]
6 > path = sys.argv[1]
7 > lasteol = sys.argv[2] == '1'
7 > lasteol = sys.argv[2] == '1'
8 > patterns = sys.argv[3:]
8 > patterns = sys.argv[3:]
9 >
9 >
10 > fp = open(path, 'wb')
10 > fp = open(path, 'wb')
11 > for i, pattern in enumerate(patterns):
11 > for i, pattern in enumerate(patterns):
12 > count = int(pattern[0:-1])
12 > count = int(pattern[0:-1])
13 > char = pattern[-1].encode('utf8') + b'\n'
13 > char = pattern[-1].encode('utf8') + b'\n'
14 > if not lasteol and i == len(patterns) - 1:
14 > if not lasteol and i == len(patterns) - 1:
15 > fp.write((char*count)[:-1])
15 > fp.write((char * count)[:-1])
16 > else:
16 > else:
17 > fp.write(char*count)
17 > fp.write(char * count)
18 > fp.close()
18 > fp.close()
19 > EOF
19 > EOF
20 $ cat > cat.py <<EOF
20 $ cat > cat.py <<EOF
21 > import sys
21 > import sys
22 > from mercurial import pycompat
22 > from mercurial import pycompat
23 > from mercurial.utils import stringutil
23 > from mercurial.utils import stringutil
24 > pycompat.stdout.write(b'%s\n'
24 > pycompat.stdout.write(b'%s\n'
25 > % stringutil.pprint(open(sys.argv[1], 'rb').read()))
25 > % stringutil.pprint(open(sys.argv[1], 'rb').read()))
26 > EOF
26 > EOF
27
27
28 Initialize the test repository
28 Initialize the test repository
29
29
30 $ hg init repo
30 $ hg init repo
31 $ cd repo
31 $ cd repo
32 $ "$PYTHON" ../writepatterns.py a 0 5A 1B 5C 1D
32 $ "$PYTHON" ../writepatterns.py a 0 5A 1B 5C 1D
33 $ "$PYTHON" ../writepatterns.py b 1 1A 1B
33 $ "$PYTHON" ../writepatterns.py b 1 1A 1B
34 $ "$PYTHON" ../writepatterns.py c 1 5A
34 $ "$PYTHON" ../writepatterns.py c 1 5A
35 $ "$PYTHON" ../writepatterns.py d 1 5A 1B
35 $ "$PYTHON" ../writepatterns.py d 1 5A 1B
36 $ hg add
36 $ hg add
37 adding a
37 adding a
38 adding b
38 adding b
39 adding c
39 adding c
40 adding d
40 adding d
41 $ hg ci -m addfiles
41 $ hg ci -m addfiles
42
42
43 Add file, missing a last end of line
43 Add file, missing a last end of line
44
44
45 $ hg import --no-commit - <<EOF
45 $ hg import --no-commit - <<EOF
46 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200
46 > *** /dev/null 2010-10-16 18:05:49.000000000 +0200
47 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200
47 > --- b/newnoeol 2010-10-16 18:23:26.000000000 +0200
48 > ***************
48 > ***************
49 > *** 0 ****
49 > *** 0 ****
50 > --- 1,2 ----
50 > --- 1,2 ----
51 > + a
51 > + a
52 > + b
52 > + b
53 > \ No newline at end of file
53 > \ No newline at end of file
54 > *** a/a Sat Oct 16 16:35:51 2010
54 > *** a/a Sat Oct 16 16:35:51 2010
55 > --- b/a Sat Oct 16 16:35:51 2010
55 > --- b/a Sat Oct 16 16:35:51 2010
56 > ***************
56 > ***************
57 > *** 3,12 ****
57 > *** 3,12 ****
58 > A
58 > A
59 > A
59 > A
60 > A
60 > A
61 > ! B
61 > ! B
62 > C
62 > C
63 > C
63 > C
64 > C
64 > C
65 > C
65 > C
66 > C
66 > C
67 > ! D
67 > ! D
68 > \ No newline at end of file
68 > \ No newline at end of file
69 > --- 3,13 ----
69 > --- 3,13 ----
70 > A
70 > A
71 > A
71 > A
72 > A
72 > A
73 > ! E
73 > ! E
74 > C
74 > C
75 > C
75 > C
76 > C
76 > C
77 > C
77 > C
78 > C
78 > C
79 > ! F
79 > ! F
80 > ! F
80 > ! F
81 >
81 >
82 > *** a/b 2010-10-16 18:40:38.000000000 +0200
82 > *** a/b 2010-10-16 18:40:38.000000000 +0200
83 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200
83 > --- /dev/null 2010-10-16 18:05:49.000000000 +0200
84 > ***************
84 > ***************
85 > *** 1,2 ****
85 > *** 1,2 ****
86 > - A
86 > - A
87 > - B
87 > - B
88 > --- 0 ----
88 > --- 0 ----
89 > *** a/c Sat Oct 16 21:34:26 2010
89 > *** a/c Sat Oct 16 21:34:26 2010
90 > --- b/c Sat Oct 16 21:34:27 2010
90 > --- b/c Sat Oct 16 21:34:27 2010
91 > ***************
91 > ***************
92 > *** 3,5 ****
92 > *** 3,5 ****
93 > --- 3,7 ----
93 > --- 3,7 ----
94 > A
94 > A
95 > A
95 > A
96 > A
96 > A
97 > + B
97 > + B
98 > + B
98 > + B
99 > *** a/d Sat Oct 16 21:47:20 2010
99 > *** a/d Sat Oct 16 21:47:20 2010
100 > --- b/d Sat Oct 16 21:47:22 2010
100 > --- b/d Sat Oct 16 21:47:22 2010
101 > ***************
101 > ***************
102 > *** 2,6 ****
102 > *** 2,6 ****
103 > A
103 > A
104 > A
104 > A
105 > A
105 > A
106 > - A
106 > - A
107 > - B
107 > - B
108 > --- 2,4 ----
108 > --- 2,4 ----
109 > EOF
109 > EOF
110 applying patch from stdin
110 applying patch from stdin
111 $ hg st
111 $ hg st
112 M a
112 M a
113 M c
113 M c
114 M d
114 M d
115 A newnoeol
115 A newnoeol
116 R b
116 R b
117
117
118 What's in a
118 What's in a
119
119
120 $ "$PYTHON" ../cat.py a
120 $ "$PYTHON" ../cat.py a
121 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n'
121 'A\nA\nA\nA\nA\nE\nC\nC\nC\nC\nC\nF\nF\n'
122 $ "$PYTHON" ../cat.py newnoeol
122 $ "$PYTHON" ../cat.py newnoeol
123 'a\nb'
123 'a\nb'
124 $ "$PYTHON" ../cat.py c
124 $ "$PYTHON" ../cat.py c
125 'A\nA\nA\nA\nA\nB\nB\n'
125 'A\nA\nA\nA\nA\nB\nB\n'
126 $ "$PYTHON" ../cat.py d
126 $ "$PYTHON" ../cat.py d
127 'A\nA\nA\nA\n'
127 'A\nA\nA\nA\n'
128
128
129 $ cd ..
129 $ cd ..
@@ -1,75 +1,75 b''
1 Test how largefiles abort in case the disk runs full
1 Test how largefiles abort in case the disk runs full
2
2
3 $ cat > criple.py <<EOF
3 $ cat > criple.py <<EOF
4 > from __future__ import absolute_import
4 > from __future__ import absolute_import
5 > import errno
5 > import errno
6 > import os
6 > import os
7 > import shutil
7 > import shutil
8 > from mercurial import util
8 > from mercurial import util
9 > #
9 > #
10 > # this makes the original largefiles code abort:
10 > # this makes the original largefiles code abort:
11 > _origcopyfileobj = shutil.copyfileobj
11 > _origcopyfileobj = shutil.copyfileobj
12 > def copyfileobj(fsrc, fdst, length=16*1024):
12 > def copyfileobj(fsrc, fdst, length=16 * 1024):
13 > # allow journal files (used by transaction) to be written
13 > # allow journal files (used by transaction) to be written
14 > if b'journal.' in fdst.name:
14 > if b'journal.' in fdst.name:
15 > return _origcopyfileobj(fsrc, fdst, length)
15 > return _origcopyfileobj(fsrc, fdst, length)
16 > fdst.write(fsrc.read(4))
16 > fdst.write(fsrc.read(4))
17 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
17 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
18 > shutil.copyfileobj = copyfileobj
18 > shutil.copyfileobj = copyfileobj
19 > #
19 > #
20 > # this makes the rewritten code abort:
20 > # this makes the rewritten code abort:
21 > def filechunkiter(f, size=131072, limit=None):
21 > def filechunkiter(f, size=131072, limit=None):
22 > yield f.read(4)
22 > yield f.read(4)
23 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
23 > raise IOError(errno.ENOSPC, os.strerror(errno.ENOSPC))
24 > util.filechunkiter = filechunkiter
24 > util.filechunkiter = filechunkiter
25 > #
25 > #
26 > def oslink(src, dest):
26 > def oslink(src, dest):
27 > raise OSError("no hardlinks, try copying instead")
27 > raise OSError("no hardlinks, try copying instead")
28 > util.oslink = oslink
28 > util.oslink = oslink
29 > EOF
29 > EOF
30
30
31 $ echo "[extensions]" >> $HGRCPATH
31 $ echo "[extensions]" >> $HGRCPATH
32 $ echo "largefiles =" >> $HGRCPATH
32 $ echo "largefiles =" >> $HGRCPATH
33
33
34 $ hg init alice
34 $ hg init alice
35 $ cd alice
35 $ cd alice
36 $ echo "this is a very big file" > big
36 $ echo "this is a very big file" > big
37 $ hg add --large big
37 $ hg add --large big
38 $ hg commit --config extensions.criple=$TESTTMP/criple.py -m big
38 $ hg commit --config extensions.criple=$TESTTMP/criple.py -m big
39 abort: No space left on device
39 abort: No space left on device
40 [255]
40 [255]
41
41
42 The largefile is not created in .hg/largefiles:
42 The largefile is not created in .hg/largefiles:
43
43
44 $ ls .hg/largefiles
44 $ ls .hg/largefiles
45 dirstate
45 dirstate
46
46
47 The user cache is not even created:
47 The user cache is not even created:
48
48
49 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
49 >>> import os; os.path.exists("$HOME/.cache/largefiles/")
50 False
50 False
51
51
52 Make the commit with space on the device:
52 Make the commit with space on the device:
53
53
54 $ hg commit -m big
54 $ hg commit -m big
55
55
56 Now make a clone with a full disk, and make sure lfutil.link function
56 Now make a clone with a full disk, and make sure lfutil.link function
57 makes copies instead of hardlinks:
57 makes copies instead of hardlinks:
58
58
59 $ cd ..
59 $ cd ..
60 $ hg --config extensions.criple=$TESTTMP/criple.py clone --pull alice bob
60 $ hg --config extensions.criple=$TESTTMP/criple.py clone --pull alice bob
61 requesting all changes
61 requesting all changes
62 adding changesets
62 adding changesets
63 adding manifests
63 adding manifests
64 adding file changes
64 adding file changes
65 added 1 changesets with 1 changes to 1 files
65 added 1 changesets with 1 changes to 1 files
66 new changesets 390cf214e9ac
66 new changesets 390cf214e9ac
67 updating to branch default
67 updating to branch default
68 getting changed largefiles
68 getting changed largefiles
69 abort: No space left on device
69 abort: No space left on device
70 [255]
70 [255]
71
71
72 The largefile is not created in .hg/largefiles:
72 The largefile is not created in .hg/largefiles:
73
73
74 $ ls bob/.hg/largefiles
74 $ ls bob/.hg/largefiles
75 dirstate
75 dirstate
@@ -1,201 +1,201 b''
1
1
2 Issue835: qpush fails immediately when patching a missing file, but
2 Issue835: qpush fails immediately when patching a missing file, but
3 remaining added files are still created empty which will trick a
3 remaining added files are still created empty which will trick a
4 future qrefresh.
4 future qrefresh.
5
5
6 $ cat > writelines.py <<EOF
6 $ cat > writelines.py <<EOF
7 > import sys
7 > import sys
8 > if sys.version_info[0] >= 3:
8 > if sys.version_info[0] >= 3:
9 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
9 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
10 > else:
10 > else:
11 > encode = lambda x: x.decode('string_escape')
11 > encode = lambda x: x.decode('string_escape')
12 > path = sys.argv[1]
12 > path = sys.argv[1]
13 > args = sys.argv[2:]
13 > args = sys.argv[2:]
14 > assert (len(args) % 2) == 0
14 > assert (len(args) % 2) == 0
15 >
15 >
16 > f = open(path, 'wb')
16 > f = open(path, 'wb')
17 > for i in range(len(args) // 2):
17 > for i in range(len(args) // 2):
18 > count, s = args[2*i:2*i+2]
18 > count, s = args[2 * i:2 * i + 2]
19 > count = int(count)
19 > count = int(count)
20 > s = encode(s)
20 > s = encode(s)
21 > f.write(s*count)
21 > f.write(s * count)
22 > f.close()
22 > f.close()
23 > EOF
23 > EOF
24
24
25 $ echo "[extensions]" >> $HGRCPATH
25 $ echo "[extensions]" >> $HGRCPATH
26 $ echo "mq=" >> $HGRCPATH
26 $ echo "mq=" >> $HGRCPATH
27
27
28 $ hg init normal
28 $ hg init normal
29 $ cd normal
29 $ cd normal
30 $ "$PYTHON" ../writelines.py b 10 'a\n'
30 $ "$PYTHON" ../writelines.py b 10 'a\n'
31 $ hg ci -Am addb
31 $ hg ci -Am addb
32 adding b
32 adding b
33 $ echo a > a
33 $ echo a > a
34 $ "$PYTHON" ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
34 $ "$PYTHON" ../writelines.py b 2 'b\n' 10 'a\n' 2 'c\n'
35 $ echo c > c
35 $ echo c > c
36 $ hg add a c
36 $ hg add a c
37 $ hg qnew -f changeb
37 $ hg qnew -f changeb
38 $ hg qpop
38 $ hg qpop
39 popping changeb
39 popping changeb
40 patch queue now empty
40 patch queue now empty
41 $ hg rm b
41 $ hg rm b
42 $ hg ci -Am rmb
42 $ hg ci -Am rmb
43
43
44 Push patch with missing target:
44 Push patch with missing target:
45
45
46 $ hg qpush
46 $ hg qpush
47 applying changeb
47 applying changeb
48 unable to find 'b' for patching
48 unable to find 'b' for patching
49 (use '--prefix' to apply patch relative to the current directory)
49 (use '--prefix' to apply patch relative to the current directory)
50 2 out of 2 hunks FAILED -- saving rejects to file b.rej
50 2 out of 2 hunks FAILED -- saving rejects to file b.rej
51 patch failed, unable to continue (try -v)
51 patch failed, unable to continue (try -v)
52 patch failed, rejects left in working directory
52 patch failed, rejects left in working directory
53 errors during apply, please fix and qrefresh changeb
53 errors during apply, please fix and qrefresh changeb
54 [2]
54 [2]
55
55
56 Display added files:
56 Display added files:
57
57
58 $ cat a
58 $ cat a
59 a
59 a
60 $ cat c
60 $ cat c
61 c
61 c
62
62
63 Display rejections:
63 Display rejections:
64
64
65 $ cat b.rej
65 $ cat b.rej
66 --- b
66 --- b
67 +++ b
67 +++ b
68 @@ -1,3 +1,5 @@
68 @@ -1,3 +1,5 @@
69 +b
69 +b
70 +b
70 +b
71 a
71 a
72 a
72 a
73 a
73 a
74 @@ -8,3 +10,5 @@
74 @@ -8,3 +10,5 @@
75 a
75 a
76 a
76 a
77 a
77 a
78 +c
78 +c
79 +c
79 +c
80
80
81 Test missing renamed file
81 Test missing renamed file
82
82
83 $ hg qpop
83 $ hg qpop
84 popping changeb
84 popping changeb
85 patch queue now empty
85 patch queue now empty
86 $ hg up -qC 0
86 $ hg up -qC 0
87 $ echo a > a
87 $ echo a > a
88 $ hg mv b bb
88 $ hg mv b bb
89 $ "$PYTHON" ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
89 $ "$PYTHON" ../writelines.py bb 2 'b\n' 10 'a\n' 2 'c\n'
90 $ echo c > c
90 $ echo c > c
91 $ hg add a c
91 $ hg add a c
92 $ hg qnew changebb
92 $ hg qnew changebb
93 $ hg qpop
93 $ hg qpop
94 popping changebb
94 popping changebb
95 patch queue now empty
95 patch queue now empty
96 $ hg up -qC 1
96 $ hg up -qC 1
97 $ hg qpush
97 $ hg qpush
98 applying changebb
98 applying changebb
99 patching file bb
99 patching file bb
100 Hunk #1 FAILED at 0
100 Hunk #1 FAILED at 0
101 Hunk #2 FAILED at 7
101 Hunk #2 FAILED at 7
102 2 out of 2 hunks FAILED -- saving rejects to file bb.rej
102 2 out of 2 hunks FAILED -- saving rejects to file bb.rej
103 b not tracked!
103 b not tracked!
104 patch failed, unable to continue (try -v)
104 patch failed, unable to continue (try -v)
105 patch failed, rejects left in working directory
105 patch failed, rejects left in working directory
106 errors during apply, please fix and qrefresh changebb
106 errors during apply, please fix and qrefresh changebb
107 [2]
107 [2]
108 $ cat a
108 $ cat a
109 a
109 a
110 $ cat c
110 $ cat c
111 c
111 c
112 $ cat bb.rej
112 $ cat bb.rej
113 --- bb
113 --- bb
114 +++ bb
114 +++ bb
115 @@ -1,3 +1,5 @@
115 @@ -1,3 +1,5 @@
116 +b
116 +b
117 +b
117 +b
118 a
118 a
119 a
119 a
120 a
120 a
121 @@ -8,3 +10,5 @@
121 @@ -8,3 +10,5 @@
122 a
122 a
123 a
123 a
124 a
124 a
125 +c
125 +c
126 +c
126 +c
127
127
128 $ cd ..
128 $ cd ..
129
129
130
130
131 $ echo "[diff]" >> $HGRCPATH
131 $ echo "[diff]" >> $HGRCPATH
132 $ echo "git=1" >> $HGRCPATH
132 $ echo "git=1" >> $HGRCPATH
133
133
134 $ hg init git
134 $ hg init git
135 $ cd git
135 $ cd git
136 $ "$PYTHON" ../writelines.py b 1 '\x00'
136 $ "$PYTHON" ../writelines.py b 1 '\x00'
137 $ hg ci -Am addb
137 $ hg ci -Am addb
138 adding b
138 adding b
139 $ echo a > a
139 $ echo a > a
140 $ "$PYTHON" ../writelines.py b 1 '\x01' 1 '\x00'
140 $ "$PYTHON" ../writelines.py b 1 '\x01' 1 '\x00'
141 $ echo c > c
141 $ echo c > c
142 $ hg add a c
142 $ hg add a c
143 $ hg qnew -f changeb
143 $ hg qnew -f changeb
144 $ hg qpop
144 $ hg qpop
145 popping changeb
145 popping changeb
146 patch queue now empty
146 patch queue now empty
147 $ hg rm b
147 $ hg rm b
148 $ hg ci -Am rmb
148 $ hg ci -Am rmb
149
149
150 Push git patch with missing target:
150 Push git patch with missing target:
151
151
152 $ hg qpush
152 $ hg qpush
153 applying changeb
153 applying changeb
154 unable to find 'b' for patching
154 unable to find 'b' for patching
155 (use '--prefix' to apply patch relative to the current directory)
155 (use '--prefix' to apply patch relative to the current directory)
156 1 out of 1 hunks FAILED -- saving rejects to file b.rej
156 1 out of 1 hunks FAILED -- saving rejects to file b.rej
157 patch failed, unable to continue (try -v)
157 patch failed, unable to continue (try -v)
158 patch failed, rejects left in working directory
158 patch failed, rejects left in working directory
159 errors during apply, please fix and qrefresh changeb
159 errors during apply, please fix and qrefresh changeb
160 [2]
160 [2]
161 $ hg st
161 $ hg st
162 ? b.rej
162 ? b.rej
163
163
164 Display added files:
164 Display added files:
165
165
166 $ cat a
166 $ cat a
167 a
167 a
168 $ cat c
168 $ cat c
169 c
169 c
170
170
171 Display rejections:
171 Display rejections:
172
172
173 $ cat b.rej
173 $ cat b.rej
174 --- b
174 --- b
175 +++ b
175 +++ b
176 GIT binary patch
176 GIT binary patch
177 literal 2
177 literal 2
178 Jc${No0000400IC2
178 Jc${No0000400IC2
179
179
180 $ cd ..
180 $ cd ..
181
181
182 Test push creating directory during git copy or rename:
182 Test push creating directory during git copy or rename:
183
183
184 $ hg init missingdir
184 $ hg init missingdir
185 $ cd missingdir
185 $ cd missingdir
186 $ echo a > a
186 $ echo a > a
187 $ hg ci -Am adda
187 $ hg ci -Am adda
188 adding a
188 adding a
189 $ mkdir d
189 $ mkdir d
190 $ hg copy a d/a2
190 $ hg copy a d/a2
191 $ hg mv a d/a
191 $ hg mv a d/a
192 $ hg qnew -g -f patch
192 $ hg qnew -g -f patch
193 $ hg qpop
193 $ hg qpop
194 popping patch
194 popping patch
195 patch queue now empty
195 patch queue now empty
196 $ hg qpush
196 $ hg qpush
197 applying patch
197 applying patch
198 now at: patch
198 now at: patch
199
199
200 $ cd ..
200 $ cd ..
201
201
@@ -1,361 +1,361 b''
1 $ cat > writelines.py <<EOF
1 $ cat > writelines.py <<EOF
2 > import sys
2 > import sys
3 > if sys.version_info[0] >= 3:
3 > if sys.version_info[0] >= 3:
4 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
4 > encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8')
5 > else:
5 > else:
6 > encode = lambda x: x.decode('string_escape')
6 > encode = lambda x: x.decode('string_escape')
7 > path = sys.argv[1]
7 > path = sys.argv[1]
8 > args = sys.argv[2:]
8 > args = sys.argv[2:]
9 > assert (len(args) % 2) == 0
9 > assert (len(args) % 2) == 0
10 >
10 >
11 > f = open(path, 'wb')
11 > f = open(path, 'wb')
12 > for i in range(len(args)//2):
12 > for i in range(len(args) // 2):
13 > count, s = args[2*i:2*i+2]
13 > count, s = args[2 * i:2 * i + 2]
14 > count = int(count)
14 > count = int(count)
15 > s = encode(s)
15 > s = encode(s)
16 > f.write(s*count)
16 > f.write(s * count)
17 > f.close()
17 > f.close()
18 >
18 >
19 > EOF
19 > EOF
20 > cat <<EOF >> $HGRCPATH
20 > cat <<EOF >> $HGRCPATH
21 > [extensions]
21 > [extensions]
22 > mq =
22 > mq =
23 > [diff]
23 > [diff]
24 > git = 1
24 > git = 1
25 > EOF
25 > EOF
26 $ hg init repo
26 $ hg init repo
27 $ cd repo
27 $ cd repo
28
28
29 qimport without file or revision
29 qimport without file or revision
30
30
31 $ hg qimport
31 $ hg qimport
32 abort: no files or revisions specified
32 abort: no files or revisions specified
33 [255]
33 [255]
34
34
35 qimport non-existing-file
35 qimport non-existing-file
36
36
37 $ hg qimport non-existing-file
37 $ hg qimport non-existing-file
38 abort: unable to read file non-existing-file
38 abort: unable to read file non-existing-file
39 [255]
39 [255]
40
40
41 qimport null revision
41 qimport null revision
42
42
43 $ hg qimport -r null
43 $ hg qimport -r null
44 abort: revision -1 is not mutable
44 abort: revision -1 is not mutable
45 (see 'hg help phases' for details)
45 (see 'hg help phases' for details)
46 [255]
46 [255]
47 $ hg qseries
47 $ hg qseries
48
48
49 import email
49 import email
50
50
51 $ hg qimport --push -n email - <<EOF
51 $ hg qimport --push -n email - <<EOF
52 > From: Username in email <test@example.net>
52 > From: Username in email <test@example.net>
53 > Subject: [PATCH] Message in email
53 > Subject: [PATCH] Message in email
54 > Date: Fri, 02 Jan 1970 00:00:00 +0000
54 > Date: Fri, 02 Jan 1970 00:00:00 +0000
55 >
55 >
56 > Text before patch.
56 > Text before patch.
57 >
57 >
58 > # HG changeset patch
58 > # HG changeset patch
59 > # User Username in patch <test@example.net>
59 > # User Username in patch <test@example.net>
60 > # Date 0 0
60 > # Date 0 0
61 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
61 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
62 > # Parent 0000000000000000000000000000000000000000
62 > # Parent 0000000000000000000000000000000000000000
63 > First line of commit message.
63 > First line of commit message.
64 >
64 >
65 > More text in commit message.
65 > More text in commit message.
66 > --- confuse the diff detection
66 > --- confuse the diff detection
67 >
67 >
68 > diff --git a/x b/x
68 > diff --git a/x b/x
69 > new file mode 100644
69 > new file mode 100644
70 > --- /dev/null
70 > --- /dev/null
71 > +++ b/x
71 > +++ b/x
72 > @@ -0,0 +1,1 @@
72 > @@ -0,0 +1,1 @@
73 > +new file
73 > +new file
74 > Text after patch.
74 > Text after patch.
75 >
75 >
76 > EOF
76 > EOF
77 adding email to series file
77 adding email to series file
78 applying email
78 applying email
79 now at: email
79 now at: email
80
80
81 hg tip -v
81 hg tip -v
82
82
83 $ hg tip -v
83 $ hg tip -v
84 changeset: 0:1a706973a7d8
84 changeset: 0:1a706973a7d8
85 tag: email
85 tag: email
86 tag: qbase
86 tag: qbase
87 tag: qtip
87 tag: qtip
88 tag: tip
88 tag: tip
89 user: Username in patch <test@example.net>
89 user: Username in patch <test@example.net>
90 date: Thu Jan 01 00:00:00 1970 +0000
90 date: Thu Jan 01 00:00:00 1970 +0000
91 files: x
91 files: x
92 description:
92 description:
93 First line of commit message.
93 First line of commit message.
94
94
95 More text in commit message.
95 More text in commit message.
96
96
97
97
98 $ hg qpop
98 $ hg qpop
99 popping email
99 popping email
100 patch queue now empty
100 patch queue now empty
101 $ hg qdelete email
101 $ hg qdelete email
102
102
103 import URL
103 import URL
104
104
105 $ echo foo >> foo
105 $ echo foo >> foo
106 $ hg add foo
106 $ hg add foo
107 $ hg diff > url.diff
107 $ hg diff > url.diff
108 $ hg revert --no-backup foo
108 $ hg revert --no-backup foo
109 $ rm foo
109 $ rm foo
110
110
111 Under unix: file:///foobar/blah
111 Under unix: file:///foobar/blah
112 Under windows: file:///c:/foobar/blah
112 Under windows: file:///c:/foobar/blah
113
113
114 $ patchurl=`pwd | tr '\\\\' /`/url.diff
114 $ patchurl=`pwd | tr '\\\\' /`/url.diff
115 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
115 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
116 $ hg qimport file://"$patchurl"
116 $ hg qimport file://"$patchurl"
117 adding url.diff to series file
117 adding url.diff to series file
118 $ rm url.diff
118 $ rm url.diff
119 $ hg qun
119 $ hg qun
120 url.diff
120 url.diff
121
121
122 import patch that already exists
122 import patch that already exists
123
123
124 $ echo foo2 >> foo
124 $ echo foo2 >> foo
125 $ hg add foo
125 $ hg add foo
126 $ hg diff > ../url.diff
126 $ hg diff > ../url.diff
127 $ hg revert --no-backup foo
127 $ hg revert --no-backup foo
128 $ rm foo
128 $ rm foo
129 $ hg qimport ../url.diff
129 $ hg qimport ../url.diff
130 abort: patch "url.diff" already exists
130 abort: patch "url.diff" already exists
131 [255]
131 [255]
132 $ hg qpush
132 $ hg qpush
133 applying url.diff
133 applying url.diff
134 now at: url.diff
134 now at: url.diff
135 $ cat foo
135 $ cat foo
136 foo
136 foo
137 $ hg qpop
137 $ hg qpop
138 popping url.diff
138 popping url.diff
139 patch queue now empty
139 patch queue now empty
140
140
141 qimport -f
141 qimport -f
142
142
143 $ hg qimport -f ../url.diff
143 $ hg qimport -f ../url.diff
144 adding url.diff to series file
144 adding url.diff to series file
145 $ hg qpush
145 $ hg qpush
146 applying url.diff
146 applying url.diff
147 now at: url.diff
147 now at: url.diff
148 $ cat foo
148 $ cat foo
149 foo2
149 foo2
150 $ hg qpop
150 $ hg qpop
151 popping url.diff
151 popping url.diff
152 patch queue now empty
152 patch queue now empty
153
153
154 build diff with CRLF
154 build diff with CRLF
155
155
156 $ "$PYTHON" ../writelines.py b 5 'a\n' 5 'a\r\n'
156 $ "$PYTHON" ../writelines.py b 5 'a\n' 5 'a\r\n'
157 $ hg ci -Am addb
157 $ hg ci -Am addb
158 adding b
158 adding b
159 $ "$PYTHON" ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
159 $ "$PYTHON" ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
160 $ hg diff > b.diff
160 $ hg diff > b.diff
161 $ hg up -C
161 $ hg up -C
162 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
162 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
163
163
164 qimport CRLF diff
164 qimport CRLF diff
165
165
166 $ hg qimport b.diff
166 $ hg qimport b.diff
167 adding b.diff to series file
167 adding b.diff to series file
168 $ hg qpush
168 $ hg qpush
169 applying b.diff
169 applying b.diff
170 now at: b.diff
170 now at: b.diff
171
171
172 try to import --push
172 try to import --push
173
173
174 $ cat > appendfoo.diff <<EOF
174 $ cat > appendfoo.diff <<EOF
175 > append foo
175 > append foo
176 >
176 >
177 > diff -r 07f494440405 -r 261500830e46 baz
177 > diff -r 07f494440405 -r 261500830e46 baz
178 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
178 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
179 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
179 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
180 > @@ -0,0 +1,1 @@
180 > @@ -0,0 +1,1 @@
181 > +foo
181 > +foo
182 > EOF
182 > EOF
183
183
184 $ cat > appendbar.diff <<EOF
184 $ cat > appendbar.diff <<EOF
185 > append bar
185 > append bar
186 >
186 >
187 > diff -r 07f494440405 -r 261500830e46 baz
187 > diff -r 07f494440405 -r 261500830e46 baz
188 > --- a/baz Thu Jan 01 00:00:00 1970 +0000
188 > --- a/baz Thu Jan 01 00:00:00 1970 +0000
189 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
189 > +++ b/baz Thu Jan 01 00:00:00 1970 +0000
190 > @@ -1,1 +1,2 @@
190 > @@ -1,1 +1,2 @@
191 > foo
191 > foo
192 > +bar
192 > +bar
193 > EOF
193 > EOF
194
194
195 $ hg qimport --push appendfoo.diff appendbar.diff
195 $ hg qimport --push appendfoo.diff appendbar.diff
196 adding appendfoo.diff to series file
196 adding appendfoo.diff to series file
197 adding appendbar.diff to series file
197 adding appendbar.diff to series file
198 applying appendfoo.diff
198 applying appendfoo.diff
199 applying appendbar.diff
199 applying appendbar.diff
200 now at: appendbar.diff
200 now at: appendbar.diff
201 $ hg qfin -a
201 $ hg qfin -a
202 patch b.diff finalized without changeset message
202 patch b.diff finalized without changeset message
203 $ touch .hg/patches/append_foo
203 $ touch .hg/patches/append_foo
204 $ hg qimport -r 'p1(.)::'
204 $ hg qimport -r 'p1(.)::'
205 $ hg qapplied
205 $ hg qapplied
206 append_foo__1
206 append_foo__1
207 append_bar
207 append_bar
208 $ hg qfin -a
208 $ hg qfin -a
209 $ rm .hg/patches/append_foo
209 $ rm .hg/patches/append_foo
210 $ hg qimport -r 'p1(.)::' -P
210 $ hg qimport -r 'p1(.)::' -P
211 $ hg qpop -a
211 $ hg qpop -a
212 popping append_bar
212 popping append_bar
213 popping append_foo
213 popping append_foo
214 patch queue now empty
214 patch queue now empty
215 $ hg qdel append_foo
215 $ hg qdel append_foo
216 $ hg qdel -k append_bar
216 $ hg qdel -k append_bar
217
217
218 qimport -e
218 qimport -e
219
219
220 $ hg qimport -e append_bar
220 $ hg qimport -e append_bar
221 adding append_bar to series file
221 adding append_bar to series file
222 $ hg qdel -k append_bar
222 $ hg qdel -k append_bar
223
223
224 qimport -e --name newname oldexisitingpatch
224 qimport -e --name newname oldexisitingpatch
225
225
226 $ hg qimport -e --name this-name-is-better append_bar
226 $ hg qimport -e --name this-name-is-better append_bar
227 renaming append_bar to this-name-is-better
227 renaming append_bar to this-name-is-better
228 adding this-name-is-better to series file
228 adding this-name-is-better to series file
229 $ hg qser
229 $ hg qser
230 this-name-is-better
230 this-name-is-better
231 url.diff
231 url.diff
232
232
233 qimport -e --name without --force
233 qimport -e --name without --force
234
234
235 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
235 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
236 $ hg qimport -e --name this-name-is-better 3.diff
236 $ hg qimport -e --name this-name-is-better 3.diff
237 abort: patch "this-name-is-better" already exists
237 abort: patch "this-name-is-better" already exists
238 [255]
238 [255]
239 $ hg qser
239 $ hg qser
240 this-name-is-better
240 this-name-is-better
241 url.diff
241 url.diff
242
242
243 qimport -e --name with --force
243 qimport -e --name with --force
244
244
245 $ hg qimport --force -e --name this-name-is-better 3.diff
245 $ hg qimport --force -e --name this-name-is-better 3.diff
246 renaming 3.diff to this-name-is-better
246 renaming 3.diff to this-name-is-better
247 adding this-name-is-better to series file
247 adding this-name-is-better to series file
248 $ hg qser
248 $ hg qser
249 this-name-is-better
249 this-name-is-better
250 url.diff
250 url.diff
251
251
252 import patch of bad filename
252 import patch of bad filename
253
253
254 $ touch '../ bad.diff'
254 $ touch '../ bad.diff'
255 $ hg qimport '../ bad.diff'
255 $ hg qimport '../ bad.diff'
256 abort: patch name cannot begin or end with whitespace
256 abort: patch name cannot begin or end with whitespace
257 [255]
257 [255]
258 $ touch '.hg/patches/ bad.diff'
258 $ touch '.hg/patches/ bad.diff'
259 $ hg qimport -e ' bad.diff'
259 $ hg qimport -e ' bad.diff'
260 abort: patch name cannot begin or end with whitespace
260 abort: patch name cannot begin or end with whitespace
261 [255]
261 [255]
262
262
263 qimport with bad name, should abort before reading file
263 qimport with bad name, should abort before reading file
264
264
265 $ hg qimport non-existent-file --name .hg
265 $ hg qimport non-existent-file --name .hg
266 abort: patch name cannot begin with ".hg"
266 abort: patch name cannot begin with ".hg"
267 [255]
267 [255]
268 $ hg qimport non-existent-file --name ' foo'
268 $ hg qimport non-existent-file --name ' foo'
269 abort: patch name cannot begin or end with whitespace
269 abort: patch name cannot begin or end with whitespace
270 [255]
270 [255]
271 $ hg qimport non-existent-file --name 'foo '
271 $ hg qimport non-existent-file --name 'foo '
272 abort: patch name cannot begin or end with whitespace
272 abort: patch name cannot begin or end with whitespace
273 [255]
273 [255]
274
274
275 qimport http:// patch with leading slashes in url
275 qimport http:// patch with leading slashes in url
276
276
277 set up hgweb
277 set up hgweb
278
278
279 $ cd ..
279 $ cd ..
280 $ hg init served
280 $ hg init served
281 $ cd served
281 $ cd served
282 $ echo a > a
282 $ echo a > a
283 $ hg ci -Am patch
283 $ hg ci -Am patch
284 adding a
284 adding a
285 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
285 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
286 $ cat hg.pid >> $DAEMON_PIDS
286 $ cat hg.pid >> $DAEMON_PIDS
287
287
288 $ cd ../repo
288 $ cd ../repo
289 $ hg qimport http://localhost:$HGPORT/raw-rev/0///
289 $ hg qimport http://localhost:$HGPORT/raw-rev/0///
290 adding 0 to series file
290 adding 0 to series file
291
291
292 check qimport phase:
292 check qimport phase:
293
293
294 $ hg -q qpush
294 $ hg -q qpush
295 now at: 0
295 now at: 0
296 $ hg phase qparent
296 $ hg phase qparent
297 1: draft
297 1: draft
298 $ hg qimport -r qparent
298 $ hg qimport -r qparent
299 $ hg phase qbase
299 $ hg phase qbase
300 1: draft
300 1: draft
301 $ hg qfinish qbase
301 $ hg qfinish qbase
302 $ echo '[mq]' >> $HGRCPATH
302 $ echo '[mq]' >> $HGRCPATH
303 $ echo 'secret=true' >> $HGRCPATH
303 $ echo 'secret=true' >> $HGRCPATH
304 $ hg qimport -r qparent
304 $ hg qimport -r qparent
305 $ hg phase qbase
305 $ hg phase qbase
306 1: secret
306 1: secret
307
307
308 $ cd ..
308 $ cd ..
309
309
310 $ killdaemons.py
310 $ killdaemons.py
311
311
312 check patch name generation for non-alpha-numeric summary line
312 check patch name generation for non-alpha-numeric summary line
313
313
314 $ cd repo
314 $ cd repo
315
315
316 $ hg qpop -a -q
316 $ hg qpop -a -q
317 patch queue now empty
317 patch queue now empty
318 $ hg qseries -v
318 $ hg qseries -v
319 0 U imported_patch_b_diff
319 0 U imported_patch_b_diff
320 1 U 0
320 1 U 0
321 2 U this-name-is-better
321 2 U this-name-is-better
322 3 U url.diff
322 3 U url.diff
323
323
324 $ echo bb >> b
324 $ echo bb >> b
325 $ hg commit -m '==++--=='
325 $ hg commit -m '==++--=='
326
326
327 $ hg qimport -r tip
327 $ hg qimport -r tip
328 $ hg qseries -v
328 $ hg qseries -v
329 0 A 1.diff
329 0 A 1.diff
330 1 U imported_patch_b_diff
330 1 U imported_patch_b_diff
331 2 U 0
331 2 U 0
332 3 U this-name-is-better
332 3 U this-name-is-better
333 4 U url.diff
333 4 U url.diff
334
334
335 check reserved patch names
335 check reserved patch names
336
336
337 $ hg qpop -qa
337 $ hg qpop -qa
338 patch queue now empty
338 patch queue now empty
339 $ echo >> b
339 $ echo >> b
340 $ hg commit -m 'status'
340 $ hg commit -m 'status'
341 $ echo >> b
341 $ echo >> b
342 $ hg commit -m '.'
342 $ hg commit -m '.'
343 $ echo >> b
343 $ echo >> b
344 $ hg commit -m 'taken'
344 $ hg commit -m 'taken'
345 $ mkdir .hg/patches/taken
345 $ mkdir .hg/patches/taken
346 $ touch .hg/patches/taken__1
346 $ touch .hg/patches/taken__1
347 $ hg qimport -r -3::
347 $ hg qimport -r -3::
348 $ hg qap
348 $ hg qap
349 1.diff__1
349 1.diff__1
350 2.diff
350 2.diff
351 taken__2
351 taken__2
352
352
353 check very long patch name
353 check very long patch name
354
354
355 $ hg qpop -qa
355 $ hg qpop -qa
356 patch queue now empty
356 patch queue now empty
357 $ echo >> b
357 $ echo >> b
358 $ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
358 $ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
359 $ hg qimport -r .
359 $ hg qimport -r .
360 $ hg qap
360 $ hg qap
361 abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg
361 abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg
@@ -1,82 +1,82 b''
1
1
2 $ cat > writepatterns.py <<EOF
2 $ cat > writepatterns.py <<EOF
3 > import sys
3 > import sys
4 >
4 >
5 > path = sys.argv[1]
5 > path = sys.argv[1]
6 > patterns = sys.argv[2:]
6 > patterns = sys.argv[2:]
7 >
7 >
8 > fp = open(path, 'wb')
8 > fp = open(path, 'wb')
9 > for pattern in patterns:
9 > for pattern in patterns:
10 > count = int(pattern[0:-1])
10 > count = int(pattern[0:-1])
11 > char = pattern[-1].encode('utf8') + b'\n'
11 > char = pattern[-1].encode('utf8') + b'\n'
12 > fp.write(char*count)
12 > fp.write(char * count)
13 > fp.close()
13 > fp.close()
14 > EOF
14 > EOF
15
15
16 prepare repo
16 prepare repo
17
17
18 $ hg init a
18 $ hg init a
19 $ cd a
19 $ cd a
20
20
21 These initial lines of Xs were not in the original file used to generate
21 These initial lines of Xs were not in the original file used to generate
22 the patch. So all the patch hunks need to be applied to a constant offset
22 the patch. So all the patch hunks need to be applied to a constant offset
23 within this file. If the offset isn't tracked then the hunks can be
23 within this file. If the offset isn't tracked then the hunks can be
24 applied to the wrong lines of this file.
24 applied to the wrong lines of this file.
25
25
26 $ "$PYTHON" ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
26 $ "$PYTHON" ../writepatterns.py a 34X 10A 1B 10A 1C 10A 1B 10A 1D 10A 1B 10A 1E 10A 1B 10A
27 $ hg commit -Am adda
27 $ hg commit -Am adda
28 adding a
28 adding a
29
29
30 This is a cleaner patch generated via diff
30 This is a cleaner patch generated via diff
31 In this case it reproduces the problem when
31 In this case it reproduces the problem when
32 the output of hg export does not
32 the output of hg export does not
33 import patch
33 import patch
34
34
35 $ hg import -v -m 'b' -d '2 0' - <<EOF
35 $ hg import -v -m 'b' -d '2 0' - <<EOF
36 > --- a/a 2009-12-08 19:26:17.000000000 -0800
36 > --- a/a 2009-12-08 19:26:17.000000000 -0800
37 > +++ b/a 2009-12-08 19:26:17.000000000 -0800
37 > +++ b/a 2009-12-08 19:26:17.000000000 -0800
38 > @@ -9,7 +9,7 @@
38 > @@ -9,7 +9,7 @@
39 > A
39 > A
40 > A
40 > A
41 > B
41 > B
42 > -A
42 > -A
43 > +a
43 > +a
44 > A
44 > A
45 > A
45 > A
46 > A
46 > A
47 > @@ -53,7 +53,7 @@
47 > @@ -53,7 +53,7 @@
48 > A
48 > A
49 > A
49 > A
50 > B
50 > B
51 > -A
51 > -A
52 > +a
52 > +a
53 > A
53 > A
54 > A
54 > A
55 > A
55 > A
56 > @@ -75,7 +75,7 @@
56 > @@ -75,7 +75,7 @@
57 > A
57 > A
58 > A
58 > A
59 > B
59 > B
60 > -A
60 > -A
61 > +a
61 > +a
62 > A
62 > A
63 > A
63 > A
64 > A
64 > A
65 > EOF
65 > EOF
66 applying patch from stdin
66 applying patch from stdin
67 patching file a
67 patching file a
68 Hunk #1 succeeded at 43 (offset 34 lines).
68 Hunk #1 succeeded at 43 (offset 34 lines).
69 Hunk #2 succeeded at 87 (offset 34 lines).
69 Hunk #2 succeeded at 87 (offset 34 lines).
70 Hunk #3 succeeded at 109 (offset 34 lines).
70 Hunk #3 succeeded at 109 (offset 34 lines).
71 committing files:
71 committing files:
72 a
72 a
73 committing manifest
73 committing manifest
74 committing changelog
74 committing changelog
75 created 189885cecb41
75 created 189885cecb41
76
76
77 compare imported changes against reference file
77 compare imported changes against reference file
78
78
79 $ "$PYTHON" ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
79 $ "$PYTHON" ../writepatterns.py aref 34X 10A 1B 1a 9A 1C 10A 1B 10A 1D 10A 1B 1a 9A 1E 10A 1B 1a 9A
80 $ diff aref a
80 $ diff aref a
81
81
82 $ cd ..
82 $ cd ..
@@ -1,265 +1,265 b''
1 $ cat <<EOF >> $HGRCPATH
1 $ cat <<EOF >> $HGRCPATH
2 > [extensions]
2 > [extensions]
3 > purge =
3 > purge =
4 > EOF
4 > EOF
5
5
6 init
6 init
7
7
8 $ hg init t
8 $ hg init t
9 $ cd t
9 $ cd t
10
10
11 setup
11 setup
12
12
13 $ echo r1 > r1
13 $ echo r1 > r1
14 $ hg ci -qAmr1 -d'0 0'
14 $ hg ci -qAmr1 -d'0 0'
15 $ mkdir directory
15 $ mkdir directory
16 $ echo r2 > directory/r2
16 $ echo r2 > directory/r2
17 $ hg ci -qAmr2 -d'1 0'
17 $ hg ci -qAmr2 -d'1 0'
18 $ echo 'ignored' > .hgignore
18 $ echo 'ignored' > .hgignore
19 $ hg ci -qAmr3 -d'2 0'
19 $ hg ci -qAmr3 -d'2 0'
20
20
21 delete an empty directory
21 delete an empty directory
22
22
23 $ mkdir empty_dir
23 $ mkdir empty_dir
24 $ hg purge -p -v
24 $ hg purge -p -v
25 empty_dir
25 empty_dir
26 $ hg purge -v
26 $ hg purge -v
27 removing directory empty_dir
27 removing directory empty_dir
28 $ ls
28 $ ls
29 directory
29 directory
30 r1
30 r1
31
31
32 delete an untracked directory
32 delete an untracked directory
33
33
34 $ mkdir untracked_dir
34 $ mkdir untracked_dir
35 $ touch untracked_dir/untracked_file1
35 $ touch untracked_dir/untracked_file1
36 $ touch untracked_dir/untracked_file2
36 $ touch untracked_dir/untracked_file2
37 $ hg purge -p
37 $ hg purge -p
38 untracked_dir/untracked_file1
38 untracked_dir/untracked_file1
39 untracked_dir/untracked_file2
39 untracked_dir/untracked_file2
40 $ hg purge -v
40 $ hg purge -v
41 removing file untracked_dir/untracked_file1
41 removing file untracked_dir/untracked_file1
42 removing file untracked_dir/untracked_file2
42 removing file untracked_dir/untracked_file2
43 removing directory untracked_dir
43 removing directory untracked_dir
44 $ ls
44 $ ls
45 directory
45 directory
46 r1
46 r1
47
47
48 delete an untracked file
48 delete an untracked file
49
49
50 $ touch untracked_file
50 $ touch untracked_file
51 $ touch untracked_file_readonly
51 $ touch untracked_file_readonly
52 $ "$PYTHON" <<EOF
52 $ "$PYTHON" <<EOF
53 > import os
53 > import os
54 > import stat
54 > import stat
55 > f= 'untracked_file_readonly'
55 > f = 'untracked_file_readonly'
56 > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
56 > os.chmod(f, stat.S_IMODE(os.stat(f).st_mode) & ~stat.S_IWRITE)
57 > EOF
57 > EOF
58 $ hg purge -p
58 $ hg purge -p
59 untracked_file
59 untracked_file
60 untracked_file_readonly
60 untracked_file_readonly
61 $ hg purge -v
61 $ hg purge -v
62 removing file untracked_file
62 removing file untracked_file
63 removing file untracked_file_readonly
63 removing file untracked_file_readonly
64 $ ls
64 $ ls
65 directory
65 directory
66 r1
66 r1
67
67
68 delete an untracked file in a tracked directory
68 delete an untracked file in a tracked directory
69
69
70 $ touch directory/untracked_file
70 $ touch directory/untracked_file
71 $ hg purge -p
71 $ hg purge -p
72 directory/untracked_file
72 directory/untracked_file
73 $ hg purge -v
73 $ hg purge -v
74 removing file directory/untracked_file
74 removing file directory/untracked_file
75 $ ls
75 $ ls
76 directory
76 directory
77 r1
77 r1
78
78
79 delete nested directories
79 delete nested directories
80
80
81 $ mkdir -p untracked_directory/nested_directory
81 $ mkdir -p untracked_directory/nested_directory
82 $ hg purge -p
82 $ hg purge -p
83 untracked_directory/nested_directory
83 untracked_directory/nested_directory
84 $ hg purge -v
84 $ hg purge -v
85 removing directory untracked_directory/nested_directory
85 removing directory untracked_directory/nested_directory
86 removing directory untracked_directory
86 removing directory untracked_directory
87 $ ls
87 $ ls
88 directory
88 directory
89 r1
89 r1
90
90
91 delete nested directories from a subdir
91 delete nested directories from a subdir
92
92
93 $ mkdir -p untracked_directory/nested_directory
93 $ mkdir -p untracked_directory/nested_directory
94 $ cd directory
94 $ cd directory
95 $ hg purge -p
95 $ hg purge -p
96 untracked_directory/nested_directory
96 untracked_directory/nested_directory
97 $ hg purge -v
97 $ hg purge -v
98 removing directory untracked_directory/nested_directory
98 removing directory untracked_directory/nested_directory
99 removing directory untracked_directory
99 removing directory untracked_directory
100 $ cd ..
100 $ cd ..
101 $ ls
101 $ ls
102 directory
102 directory
103 r1
103 r1
104
104
105 delete only part of the tree
105 delete only part of the tree
106
106
107 $ mkdir -p untracked_directory/nested_directory
107 $ mkdir -p untracked_directory/nested_directory
108 $ touch directory/untracked_file
108 $ touch directory/untracked_file
109 $ cd directory
109 $ cd directory
110 $ hg purge -p ../untracked_directory
110 $ hg purge -p ../untracked_directory
111 untracked_directory/nested_directory
111 untracked_directory/nested_directory
112 $ hg purge -v ../untracked_directory
112 $ hg purge -v ../untracked_directory
113 removing directory untracked_directory/nested_directory
113 removing directory untracked_directory/nested_directory
114 removing directory untracked_directory
114 removing directory untracked_directory
115 $ cd ..
115 $ cd ..
116 $ ls
116 $ ls
117 directory
117 directory
118 r1
118 r1
119 $ ls directory/untracked_file
119 $ ls directory/untracked_file
120 directory/untracked_file
120 directory/untracked_file
121 $ rm directory/untracked_file
121 $ rm directory/untracked_file
122
122
123 skip ignored files if --all not specified
123 skip ignored files if --all not specified
124
124
125 $ touch ignored
125 $ touch ignored
126 $ hg purge -p
126 $ hg purge -p
127 $ hg purge -v
127 $ hg purge -v
128 $ ls
128 $ ls
129 directory
129 directory
130 ignored
130 ignored
131 r1
131 r1
132 $ hg purge -p --all
132 $ hg purge -p --all
133 ignored
133 ignored
134 $ hg purge -v --all
134 $ hg purge -v --all
135 removing file ignored
135 removing file ignored
136 $ ls
136 $ ls
137 directory
137 directory
138 r1
138 r1
139
139
140 abort with missing files until we support name mangling filesystems
140 abort with missing files until we support name mangling filesystems
141
141
142 $ touch untracked_file
142 $ touch untracked_file
143 $ rm r1
143 $ rm r1
144
144
145 hide error messages to avoid changing the output when the text changes
145 hide error messages to avoid changing the output when the text changes
146
146
147 $ hg purge -p 2> /dev/null
147 $ hg purge -p 2> /dev/null
148 untracked_file
148 untracked_file
149 $ hg st
149 $ hg st
150 ! r1
150 ! r1
151 ? untracked_file
151 ? untracked_file
152
152
153 $ hg purge -p
153 $ hg purge -p
154 untracked_file
154 untracked_file
155 $ hg purge -v 2> /dev/null
155 $ hg purge -v 2> /dev/null
156 removing file untracked_file
156 removing file untracked_file
157 $ hg st
157 $ hg st
158 ! r1
158 ! r1
159
159
160 $ hg purge -v
160 $ hg purge -v
161 $ hg revert --all --quiet
161 $ hg revert --all --quiet
162 $ hg st -a
162 $ hg st -a
163
163
164 tracked file in ignored directory (issue621)
164 tracked file in ignored directory (issue621)
165
165
166 $ echo directory >> .hgignore
166 $ echo directory >> .hgignore
167 $ hg ci -m 'ignore directory'
167 $ hg ci -m 'ignore directory'
168 $ touch untracked_file
168 $ touch untracked_file
169 $ hg purge -p
169 $ hg purge -p
170 untracked_file
170 untracked_file
171 $ hg purge -v
171 $ hg purge -v
172 removing file untracked_file
172 removing file untracked_file
173
173
174 skip excluded files
174 skip excluded files
175
175
176 $ touch excluded_file
176 $ touch excluded_file
177 $ hg purge -p -X excluded_file
177 $ hg purge -p -X excluded_file
178 $ hg purge -v -X excluded_file
178 $ hg purge -v -X excluded_file
179 $ ls
179 $ ls
180 directory
180 directory
181 excluded_file
181 excluded_file
182 r1
182 r1
183 $ rm excluded_file
183 $ rm excluded_file
184
184
185 skip files in excluded dirs
185 skip files in excluded dirs
186
186
187 $ mkdir excluded_dir
187 $ mkdir excluded_dir
188 $ touch excluded_dir/file
188 $ touch excluded_dir/file
189 $ hg purge -p -X excluded_dir
189 $ hg purge -p -X excluded_dir
190 $ hg purge -v -X excluded_dir
190 $ hg purge -v -X excluded_dir
191 $ ls
191 $ ls
192 directory
192 directory
193 excluded_dir
193 excluded_dir
194 r1
194 r1
195 $ ls excluded_dir
195 $ ls excluded_dir
196 file
196 file
197 $ rm -R excluded_dir
197 $ rm -R excluded_dir
198
198
199 skip excluded empty dirs
199 skip excluded empty dirs
200
200
201 $ mkdir excluded_dir
201 $ mkdir excluded_dir
202 $ hg purge -p -X excluded_dir
202 $ hg purge -p -X excluded_dir
203 $ hg purge -v -X excluded_dir
203 $ hg purge -v -X excluded_dir
204 $ ls
204 $ ls
205 directory
205 directory
206 excluded_dir
206 excluded_dir
207 r1
207 r1
208 $ rmdir excluded_dir
208 $ rmdir excluded_dir
209
209
210 skip patterns
210 skip patterns
211
211
212 $ mkdir .svn
212 $ mkdir .svn
213 $ touch .svn/foo
213 $ touch .svn/foo
214 $ mkdir directory/.svn
214 $ mkdir directory/.svn
215 $ touch directory/.svn/foo
215 $ touch directory/.svn/foo
216 $ hg purge -p -X .svn -X '*/.svn'
216 $ hg purge -p -X .svn -X '*/.svn'
217 $ hg purge -p -X re:.*.svn
217 $ hg purge -p -X re:.*.svn
218
218
219 $ rm -R .svn directory r1
219 $ rm -R .svn directory r1
220
220
221 only remove files
221 only remove files
222
222
223 $ mkdir -p empty_dir dir
223 $ mkdir -p empty_dir dir
224 $ touch untracked_file dir/untracked_file
224 $ touch untracked_file dir/untracked_file
225 $ hg purge -p --files
225 $ hg purge -p --files
226 dir/untracked_file
226 dir/untracked_file
227 untracked_file
227 untracked_file
228 $ hg purge -v --files
228 $ hg purge -v --files
229 removing file dir/untracked_file
229 removing file dir/untracked_file
230 removing file untracked_file
230 removing file untracked_file
231 $ ls
231 $ ls
232 dir
232 dir
233 empty_dir
233 empty_dir
234 $ ls dir
234 $ ls dir
235
235
236 only remove dirs
236 only remove dirs
237
237
238 $ mkdir -p empty_dir dir
238 $ mkdir -p empty_dir dir
239 $ touch untracked_file dir/untracked_file
239 $ touch untracked_file dir/untracked_file
240 $ hg purge -p --dirs
240 $ hg purge -p --dirs
241 empty_dir
241 empty_dir
242 $ hg purge -v --dirs
242 $ hg purge -v --dirs
243 removing directory empty_dir
243 removing directory empty_dir
244 $ ls
244 $ ls
245 dir
245 dir
246 untracked_file
246 untracked_file
247 $ ls dir
247 $ ls dir
248 untracked_file
248 untracked_file
249
249
250 remove both files and dirs
250 remove both files and dirs
251
251
252 $ mkdir -p empty_dir dir
252 $ mkdir -p empty_dir dir
253 $ touch untracked_file dir/untracked_file
253 $ touch untracked_file dir/untracked_file
254 $ hg purge -p --files --dirs
254 $ hg purge -p --files --dirs
255 dir/untracked_file
255 dir/untracked_file
256 untracked_file
256 untracked_file
257 empty_dir
257 empty_dir
258 $ hg purge -v --files --dirs
258 $ hg purge -v --files --dirs
259 removing file dir/untracked_file
259 removing file dir/untracked_file
260 removing file untracked_file
260 removing file untracked_file
261 removing directory empty_dir
261 removing directory empty_dir
262 removing directory dir
262 removing directory dir
263 $ ls
263 $ ls
264
264
265 $ cd ..
265 $ cd ..
@@ -1,3040 +1,3040 b''
1 $ HGENCODING=utf-8
1 $ HGENCODING=utf-8
2 $ export HGENCODING
2 $ export HGENCODING
3 $ cat > testrevset.py << EOF
3 $ cat > testrevset.py << EOF
4 > import mercurial.revset
4 > import mercurial.revset
5 >
5 >
6 > baseset = mercurial.revset.baseset
6 > baseset = mercurial.revset.baseset
7 >
7 >
8 > def r3232(repo, subset, x):
8 > def r3232(repo, subset, x):
9 > """"simple revset that return [3,2,3,2]
9 > """"simple revset that return [3,2,3,2]
10 >
10 >
11 > revisions duplicated on purpose.
11 > revisions duplicated on purpose.
12 > """
12 > """
13 > if 3 not in subset:
13 > if 3 not in subset:
14 > if 2 in subset:
14 > if 2 in subset:
15 > return baseset([2,2])
15 > return baseset([2, 2])
16 > return baseset()
16 > return baseset()
17 > return baseset([3,3,2,2])
17 > return baseset([3, 3, 2, 2])
18 >
18 >
19 > mercurial.revset.symbols[b'r3232'] = r3232
19 > mercurial.revset.symbols[b'r3232'] = r3232
20 > EOF
20 > EOF
21 $ cat >> $HGRCPATH << EOF
21 $ cat >> $HGRCPATH << EOF
22 > [extensions]
22 > [extensions]
23 > drawdag=$TESTDIR/drawdag.py
23 > drawdag=$TESTDIR/drawdag.py
24 > testrevset=$TESTTMP/testrevset.py
24 > testrevset=$TESTTMP/testrevset.py
25 > EOF
25 > EOF
26
26
27 $ try() {
27 $ try() {
28 > hg debugrevspec --debug "$@"
28 > hg debugrevspec --debug "$@"
29 > }
29 > }
30
30
31 $ log() {
31 $ log() {
32 > hg log --template '{rev}\n' -r "$1"
32 > hg log --template '{rev}\n' -r "$1"
33 > }
33 > }
34
34
35 extension to build '_intlist()' and '_hexlist()', which is necessary because
35 extension to build '_intlist()' and '_hexlist()', which is necessary because
36 these predicates use '\0' as a separator:
36 these predicates use '\0' as a separator:
37
37
38 $ cat <<EOF > debugrevlistspec.py
38 $ cat <<EOF > debugrevlistspec.py
39 > from __future__ import absolute_import
39 > from __future__ import absolute_import
40 > from mercurial import (
40 > from mercurial import (
41 > node as nodemod,
41 > node as nodemod,
42 > registrar,
42 > registrar,
43 > revset,
43 > revset,
44 > revsetlang,
44 > revsetlang,
45 > )
45 > )
46 > from mercurial.utils import stringutil
46 > from mercurial.utils import stringutil
47 > cmdtable = {}
47 > cmdtable = {}
48 > command = registrar.command(cmdtable)
48 > command = registrar.command(cmdtable)
49 > @command(b'debugrevlistspec',
49 > @command(b'debugrevlistspec',
50 > [(b'', b'optimize', None, b'print parsed tree after optimizing'),
50 > [(b'', b'optimize', None, b'print parsed tree after optimizing'),
51 > (b'', b'bin', None, b'unhexlify arguments')])
51 > (b'', b'bin', None, b'unhexlify arguments')])
52 > def debugrevlistspec(ui, repo, fmt, *args, **opts):
52 > def debugrevlistspec(ui, repo, fmt, *args, **opts):
53 > if opts['bin']:
53 > if opts['bin']:
54 > args = map(nodemod.bin, args)
54 > args = map(nodemod.bin, args)
55 > expr = revsetlang.formatspec(fmt, list(args))
55 > expr = revsetlang.formatspec(fmt, list(args))
56 > if ui.verbose:
56 > if ui.verbose:
57 > tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
57 > tree = revsetlang.parse(expr, lookup=revset.lookupfn(repo))
58 > ui.note(revsetlang.prettyformat(tree), b"\n")
58 > ui.note(revsetlang.prettyformat(tree), b"\n")
59 > if opts["optimize"]:
59 > if opts["optimize"]:
60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
60 > opttree = revsetlang.optimize(revsetlang.analyze(tree))
61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
61 > ui.note(b"* optimized:\n", revsetlang.prettyformat(opttree),
62 > b"\n")
62 > b"\n")
63 > func = revset.match(ui, expr, lookup=revset.lookupfn(repo))
63 > func = revset.match(ui, expr, lookup=revset.lookupfn(repo))
64 > revs = func(repo)
64 > revs = func(repo)
65 > if ui.verbose:
65 > if ui.verbose:
66 > ui.note(b"* set:\n", stringutil.prettyrepr(revs), b"\n")
66 > ui.note(b"* set:\n", stringutil.prettyrepr(revs), b"\n")
67 > for c in revs:
67 > for c in revs:
68 > ui.write(b"%d\n" % c)
68 > ui.write(b"%d\n" % c)
69 > EOF
69 > EOF
70 $ cat <<EOF >> $HGRCPATH
70 $ cat <<EOF >> $HGRCPATH
71 > [extensions]
71 > [extensions]
72 > debugrevlistspec = $TESTTMP/debugrevlistspec.py
72 > debugrevlistspec = $TESTTMP/debugrevlistspec.py
73 > EOF
73 > EOF
74 $ trylist() {
74 $ trylist() {
75 > hg debugrevlistspec --debug "$@"
75 > hg debugrevlistspec --debug "$@"
76 > }
76 > }
77
77
78 $ hg init repo
78 $ hg init repo
79 $ cd repo
79 $ cd repo
80
80
81 $ echo a > a
81 $ echo a > a
82 $ hg branch a
82 $ hg branch a
83 marked working directory as branch a
83 marked working directory as branch a
84 (branches are permanent and global, did you want a bookmark?)
84 (branches are permanent and global, did you want a bookmark?)
85 $ hg ci -Aqm0
85 $ hg ci -Aqm0
86
86
87 $ echo b > b
87 $ echo b > b
88 $ hg branch b
88 $ hg branch b
89 marked working directory as branch b
89 marked working directory as branch b
90 $ hg ci -Aqm1
90 $ hg ci -Aqm1
91
91
92 $ rm a
92 $ rm a
93 $ hg branch a-b-c-
93 $ hg branch a-b-c-
94 marked working directory as branch a-b-c-
94 marked working directory as branch a-b-c-
95 $ hg ci -Aqm2 -u Bob
95 $ hg ci -Aqm2 -u Bob
96
96
97 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
97 $ hg log -r "extra('branch', 'a-b-c-')" --template '{rev}\n'
98 2
98 2
99 $ hg log -r "extra('branch')" --template '{rev}\n'
99 $ hg log -r "extra('branch')" --template '{rev}\n'
100 0
100 0
101 1
101 1
102 2
102 2
103 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
103 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
104 0 a
104 0 a
105 2 a-b-c-
105 2 a-b-c-
106
106
107 $ hg co 1
107 $ hg co 1
108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 $ hg branch +a+b+c+
109 $ hg branch +a+b+c+
110 marked working directory as branch +a+b+c+
110 marked working directory as branch +a+b+c+
111 $ hg ci -Aqm3
111 $ hg ci -Aqm3
112
112
113 $ hg co 2 # interleave
113 $ hg co 2 # interleave
114 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
114 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
115 $ echo bb > b
115 $ echo bb > b
116 $ hg branch -- -a-b-c-
116 $ hg branch -- -a-b-c-
117 marked working directory as branch -a-b-c-
117 marked working directory as branch -a-b-c-
118 $ hg ci -Aqm4 -d "May 12 2005"
118 $ hg ci -Aqm4 -d "May 12 2005"
119
119
120 $ hg co 3
120 $ hg co 3
121 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
121 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
122 $ hg branch !a/b/c/
122 $ hg branch !a/b/c/
123 marked working directory as branch !a/b/c/
123 marked working directory as branch !a/b/c/
124 $ hg ci -Aqm"5 bug"
124 $ hg ci -Aqm"5 bug"
125
125
126 $ hg merge 4
126 $ hg merge 4
127 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
127 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
128 (branch merge, don't forget to commit)
128 (branch merge, don't forget to commit)
129 $ hg branch _a_b_c_
129 $ hg branch _a_b_c_
130 marked working directory as branch _a_b_c_
130 marked working directory as branch _a_b_c_
131 $ hg ci -Aqm"6 issue619"
131 $ hg ci -Aqm"6 issue619"
132
132
133 $ hg branch .a.b.c.
133 $ hg branch .a.b.c.
134 marked working directory as branch .a.b.c.
134 marked working directory as branch .a.b.c.
135 $ hg ci -Aqm7
135 $ hg ci -Aqm7
136
136
137 $ hg branch all
137 $ hg branch all
138 marked working directory as branch all
138 marked working directory as branch all
139
139
140 $ hg co 4
140 $ hg co 4
141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 $ hg branch Γ©
142 $ hg branch Γ©
143 marked working directory as branch \xc3\xa9 (esc)
143 marked working directory as branch \xc3\xa9 (esc)
144 $ hg ci -Aqm9
144 $ hg ci -Aqm9
145
145
146 $ hg tag -r6 1.0
146 $ hg tag -r6 1.0
147 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
147 $ hg bookmark -r6 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
148
148
149 $ hg clone --quiet -U -r 7 . ../remote1
149 $ hg clone --quiet -U -r 7 . ../remote1
150 $ hg clone --quiet -U -r 8 . ../remote2
150 $ hg clone --quiet -U -r 8 . ../remote2
151 $ echo "[paths]" >> .hg/hgrc
151 $ echo "[paths]" >> .hg/hgrc
152 $ echo "default = ../remote1" >> .hg/hgrc
152 $ echo "default = ../remote1" >> .hg/hgrc
153
153
154 trivial
154 trivial
155
155
156 $ try 0:1
156 $ try 0:1
157 (range
157 (range
158 (symbol '0')
158 (symbol '0')
159 (symbol '1'))
159 (symbol '1'))
160 * set:
160 * set:
161 <spanset+ 0:2>
161 <spanset+ 0:2>
162 0
162 0
163 1
163 1
164 $ try --optimize :
164 $ try --optimize :
165 (rangeall
165 (rangeall
166 None)
166 None)
167 * optimized:
167 * optimized:
168 (rangeall
168 (rangeall
169 None)
169 None)
170 * set:
170 * set:
171 <spanset+ 0:10>
171 <spanset+ 0:10>
172 0
172 0
173 1
173 1
174 2
174 2
175 3
175 3
176 4
176 4
177 5
177 5
178 6
178 6
179 7
179 7
180 8
180 8
181 9
181 9
182 $ try 3::6
182 $ try 3::6
183 (dagrange
183 (dagrange
184 (symbol '3')
184 (symbol '3')
185 (symbol '6'))
185 (symbol '6'))
186 * set:
186 * set:
187 <baseset+ [3, 5, 6]>
187 <baseset+ [3, 5, 6]>
188 3
188 3
189 5
189 5
190 6
190 6
191 $ try '0|1|2'
191 $ try '0|1|2'
192 (or
192 (or
193 (list
193 (list
194 (symbol '0')
194 (symbol '0')
195 (symbol '1')
195 (symbol '1')
196 (symbol '2')))
196 (symbol '2')))
197 * set:
197 * set:
198 <baseset [0, 1, 2]>
198 <baseset [0, 1, 2]>
199 0
199 0
200 1
200 1
201 2
201 2
202
202
203 names that should work without quoting
203 names that should work without quoting
204
204
205 $ try a
205 $ try a
206 (symbol 'a')
206 (symbol 'a')
207 * set:
207 * set:
208 <baseset [0]>
208 <baseset [0]>
209 0
209 0
210 $ try b-a
210 $ try b-a
211 (minus
211 (minus
212 (symbol 'b')
212 (symbol 'b')
213 (symbol 'a'))
213 (symbol 'a'))
214 * set:
214 * set:
215 <filteredset
215 <filteredset
216 <baseset [1]>,
216 <baseset [1]>,
217 <not
217 <not
218 <baseset [0]>>>
218 <baseset [0]>>>
219 1
219 1
220 $ try _a_b_c_
220 $ try _a_b_c_
221 (symbol '_a_b_c_')
221 (symbol '_a_b_c_')
222 * set:
222 * set:
223 <baseset [6]>
223 <baseset [6]>
224 6
224 6
225 $ try _a_b_c_-a
225 $ try _a_b_c_-a
226 (minus
226 (minus
227 (symbol '_a_b_c_')
227 (symbol '_a_b_c_')
228 (symbol 'a'))
228 (symbol 'a'))
229 * set:
229 * set:
230 <filteredset
230 <filteredset
231 <baseset [6]>,
231 <baseset [6]>,
232 <not
232 <not
233 <baseset [0]>>>
233 <baseset [0]>>>
234 6
234 6
235 $ try .a.b.c.
235 $ try .a.b.c.
236 (symbol '.a.b.c.')
236 (symbol '.a.b.c.')
237 * set:
237 * set:
238 <baseset [7]>
238 <baseset [7]>
239 7
239 7
240 $ try .a.b.c.-a
240 $ try .a.b.c.-a
241 (minus
241 (minus
242 (symbol '.a.b.c.')
242 (symbol '.a.b.c.')
243 (symbol 'a'))
243 (symbol 'a'))
244 * set:
244 * set:
245 <filteredset
245 <filteredset
246 <baseset [7]>,
246 <baseset [7]>,
247 <not
247 <not
248 <baseset [0]>>>
248 <baseset [0]>>>
249 7
249 7
250
250
251 names that should be caught by fallback mechanism
251 names that should be caught by fallback mechanism
252
252
253 $ try -- '-a-b-c-'
253 $ try -- '-a-b-c-'
254 (symbol '-a-b-c-')
254 (symbol '-a-b-c-')
255 * set:
255 * set:
256 <baseset [4]>
256 <baseset [4]>
257 4
257 4
258 $ log -a-b-c-
258 $ log -a-b-c-
259 4
259 4
260 $ try '+a+b+c+'
260 $ try '+a+b+c+'
261 (symbol '+a+b+c+')
261 (symbol '+a+b+c+')
262 * set:
262 * set:
263 <baseset [3]>
263 <baseset [3]>
264 3
264 3
265 $ try '+a+b+c+:'
265 $ try '+a+b+c+:'
266 (rangepost
266 (rangepost
267 (symbol '+a+b+c+'))
267 (symbol '+a+b+c+'))
268 * set:
268 * set:
269 <spanset+ 3:10>
269 <spanset+ 3:10>
270 3
270 3
271 4
271 4
272 5
272 5
273 6
273 6
274 7
274 7
275 8
275 8
276 9
276 9
277 $ try ':+a+b+c+'
277 $ try ':+a+b+c+'
278 (rangepre
278 (rangepre
279 (symbol '+a+b+c+'))
279 (symbol '+a+b+c+'))
280 * set:
280 * set:
281 <spanset+ 0:4>
281 <spanset+ 0:4>
282 0
282 0
283 1
283 1
284 2
284 2
285 3
285 3
286 $ try -- '-a-b-c-:+a+b+c+'
286 $ try -- '-a-b-c-:+a+b+c+'
287 (range
287 (range
288 (symbol '-a-b-c-')
288 (symbol '-a-b-c-')
289 (symbol '+a+b+c+'))
289 (symbol '+a+b+c+'))
290 * set:
290 * set:
291 <spanset- 3:5>
291 <spanset- 3:5>
292 4
292 4
293 3
293 3
294 $ log '-a-b-c-:+a+b+c+'
294 $ log '-a-b-c-:+a+b+c+'
295 4
295 4
296 3
296 3
297
297
298 $ try -- -a-b-c--a # complains
298 $ try -- -a-b-c--a # complains
299 (minus
299 (minus
300 (minus
300 (minus
301 (minus
301 (minus
302 (negate
302 (negate
303 (symbol 'a'))
303 (symbol 'a'))
304 (symbol 'b'))
304 (symbol 'b'))
305 (symbol 'c'))
305 (symbol 'c'))
306 (negate
306 (negate
307 (symbol 'a')))
307 (symbol 'a')))
308 abort: unknown revision '-a'!
308 abort: unknown revision '-a'!
309 [255]
309 [255]
310 $ try Γ©
310 $ try Γ©
311 (symbol '\xc3\xa9')
311 (symbol '\xc3\xa9')
312 * set:
312 * set:
313 <baseset [9]>
313 <baseset [9]>
314 9
314 9
315
315
316 no quoting needed
316 no quoting needed
317
317
318 $ log ::a-b-c-
318 $ log ::a-b-c-
319 0
319 0
320 1
320 1
321 2
321 2
322
322
323 quoting needed
323 quoting needed
324
324
325 $ try '"-a-b-c-"-a'
325 $ try '"-a-b-c-"-a'
326 (minus
326 (minus
327 (string '-a-b-c-')
327 (string '-a-b-c-')
328 (symbol 'a'))
328 (symbol 'a'))
329 * set:
329 * set:
330 <filteredset
330 <filteredset
331 <baseset [4]>,
331 <baseset [4]>,
332 <not
332 <not
333 <baseset [0]>>>
333 <baseset [0]>>>
334 4
334 4
335
335
336 $ log '1 or 2'
336 $ log '1 or 2'
337 1
337 1
338 2
338 2
339 $ log '1|2'
339 $ log '1|2'
340 1
340 1
341 2
341 2
342 $ log '1 and 2'
342 $ log '1 and 2'
343 $ log '1&2'
343 $ log '1&2'
344 $ try '1&2|3' # precedence - and is higher
344 $ try '1&2|3' # precedence - and is higher
345 (or
345 (or
346 (list
346 (list
347 (and
347 (and
348 (symbol '1')
348 (symbol '1')
349 (symbol '2'))
349 (symbol '2'))
350 (symbol '3')))
350 (symbol '3')))
351 * set:
351 * set:
352 <addset
352 <addset
353 <baseset []>,
353 <baseset []>,
354 <baseset [3]>>
354 <baseset [3]>>
355 3
355 3
356 $ try '1|2&3'
356 $ try '1|2&3'
357 (or
357 (or
358 (list
358 (list
359 (symbol '1')
359 (symbol '1')
360 (and
360 (and
361 (symbol '2')
361 (symbol '2')
362 (symbol '3'))))
362 (symbol '3'))))
363 * set:
363 * set:
364 <addset
364 <addset
365 <baseset [1]>,
365 <baseset [1]>,
366 <baseset []>>
366 <baseset []>>
367 1
367 1
368 $ try '1&2&3' # associativity
368 $ try '1&2&3' # associativity
369 (and
369 (and
370 (and
370 (and
371 (symbol '1')
371 (symbol '1')
372 (symbol '2'))
372 (symbol '2'))
373 (symbol '3'))
373 (symbol '3'))
374 * set:
374 * set:
375 <baseset []>
375 <baseset []>
376 $ try '1|(2|3)'
376 $ try '1|(2|3)'
377 (or
377 (or
378 (list
378 (list
379 (symbol '1')
379 (symbol '1')
380 (group
380 (group
381 (or
381 (or
382 (list
382 (list
383 (symbol '2')
383 (symbol '2')
384 (symbol '3'))))))
384 (symbol '3'))))))
385 * set:
385 * set:
386 <addset
386 <addset
387 <baseset [1]>,
387 <baseset [1]>,
388 <baseset [2, 3]>>
388 <baseset [2, 3]>>
389 1
389 1
390 2
390 2
391 3
391 3
392 $ log '1.0' # tag
392 $ log '1.0' # tag
393 6
393 6
394 $ log 'a' # branch
394 $ log 'a' # branch
395 0
395 0
396 $ log '2785f51ee'
396 $ log '2785f51ee'
397 0
397 0
398 $ log 'date(2005)'
398 $ log 'date(2005)'
399 4
399 4
400 $ log 'date(this is a test)'
400 $ log 'date(this is a test)'
401 hg: parse error at 10: unexpected token: symbol
401 hg: parse error at 10: unexpected token: symbol
402 (date(this is a test)
402 (date(this is a test)
403 ^ here)
403 ^ here)
404 [255]
404 [255]
405 $ log 'date()'
405 $ log 'date()'
406 hg: parse error: date requires a string
406 hg: parse error: date requires a string
407 [255]
407 [255]
408 $ log 'date'
408 $ log 'date'
409 abort: unknown revision 'date'!
409 abort: unknown revision 'date'!
410 [255]
410 [255]
411 $ log 'date('
411 $ log 'date('
412 hg: parse error at 5: not a prefix: end
412 hg: parse error at 5: not a prefix: end
413 (date(
413 (date(
414 ^ here)
414 ^ here)
415 [255]
415 [255]
416 $ log 'date("\xy")'
416 $ log 'date("\xy")'
417 hg: parse error: invalid \x escape* (glob)
417 hg: parse error: invalid \x escape* (glob)
418 [255]
418 [255]
419 $ log 'date(tip)'
419 $ log 'date(tip)'
420 hg: parse error: invalid date: 'tip'
420 hg: parse error: invalid date: 'tip'
421 [255]
421 [255]
422 $ log '0:date'
422 $ log '0:date'
423 abort: unknown revision 'date'!
423 abort: unknown revision 'date'!
424 [255]
424 [255]
425 $ log '::"date"'
425 $ log '::"date"'
426 abort: unknown revision 'date'!
426 abort: unknown revision 'date'!
427 [255]
427 [255]
428 $ hg book date -r 4
428 $ hg book date -r 4
429 $ log '0:date'
429 $ log '0:date'
430 0
430 0
431 1
431 1
432 2
432 2
433 3
433 3
434 4
434 4
435 $ log '::date'
435 $ log '::date'
436 0
436 0
437 1
437 1
438 2
438 2
439 4
439 4
440 $ log '::"date"'
440 $ log '::"date"'
441 0
441 0
442 1
442 1
443 2
443 2
444 4
444 4
445 $ log 'date(2005) and 1::'
445 $ log 'date(2005) and 1::'
446 4
446 4
447 $ hg book -d date
447 $ hg book -d date
448
448
449 function name should be a symbol
449 function name should be a symbol
450
450
451 $ log '"date"(2005)'
451 $ log '"date"(2005)'
452 hg: parse error: not a symbol
452 hg: parse error: not a symbol
453 [255]
453 [255]
454
454
455 keyword arguments
455 keyword arguments
456
456
457 $ log 'extra(branch, value=a)'
457 $ log 'extra(branch, value=a)'
458 0
458 0
459
459
460 $ log 'extra(branch, a, b)'
460 $ log 'extra(branch, a, b)'
461 hg: parse error: extra takes at most 2 positional arguments
461 hg: parse error: extra takes at most 2 positional arguments
462 [255]
462 [255]
463 $ log 'extra(a, label=b)'
463 $ log 'extra(a, label=b)'
464 hg: parse error: extra got multiple values for keyword argument 'label'
464 hg: parse error: extra got multiple values for keyword argument 'label'
465 [255]
465 [255]
466 $ log 'extra(label=branch, default)'
466 $ log 'extra(label=branch, default)'
467 hg: parse error: extra got an invalid argument
467 hg: parse error: extra got an invalid argument
468 [255]
468 [255]
469 $ log 'extra(branch, foo+bar=baz)'
469 $ log 'extra(branch, foo+bar=baz)'
470 hg: parse error: extra got an invalid argument
470 hg: parse error: extra got an invalid argument
471 [255]
471 [255]
472 $ log 'extra(unknown=branch)'
472 $ log 'extra(unknown=branch)'
473 hg: parse error: extra got an unexpected keyword argument 'unknown'
473 hg: parse error: extra got an unexpected keyword argument 'unknown'
474 [255]
474 [255]
475
475
476 $ try 'foo=bar|baz'
476 $ try 'foo=bar|baz'
477 (keyvalue
477 (keyvalue
478 (symbol 'foo')
478 (symbol 'foo')
479 (or
479 (or
480 (list
480 (list
481 (symbol 'bar')
481 (symbol 'bar')
482 (symbol 'baz'))))
482 (symbol 'baz'))))
483 hg: parse error: can't use a key-value pair in this context
483 hg: parse error: can't use a key-value pair in this context
484 [255]
484 [255]
485
485
486 right-hand side should be optimized recursively
486 right-hand side should be optimized recursively
487
487
488 $ try --optimize 'foo=(not public())'
488 $ try --optimize 'foo=(not public())'
489 (keyvalue
489 (keyvalue
490 (symbol 'foo')
490 (symbol 'foo')
491 (group
491 (group
492 (not
492 (not
493 (func
493 (func
494 (symbol 'public')
494 (symbol 'public')
495 None))))
495 None))))
496 * optimized:
496 * optimized:
497 (keyvalue
497 (keyvalue
498 (symbol 'foo')
498 (symbol 'foo')
499 (func
499 (func
500 (symbol '_notpublic')
500 (symbol '_notpublic')
501 None))
501 None))
502 hg: parse error: can't use a key-value pair in this context
502 hg: parse error: can't use a key-value pair in this context
503 [255]
503 [255]
504
504
505 relation-subscript operator has the highest binding strength (as function call):
505 relation-subscript operator has the highest binding strength (as function call):
506
506
507 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
507 $ hg debugrevspec -p parsed 'tip:tip^#generations[-1]'
508 * parsed:
508 * parsed:
509 (range
509 (range
510 (symbol 'tip')
510 (symbol 'tip')
511 (relsubscript
511 (relsubscript
512 (parentpost
512 (parentpost
513 (symbol 'tip'))
513 (symbol 'tip'))
514 (symbol 'generations')
514 (symbol 'generations')
515 (negate
515 (negate
516 (symbol '1'))))
516 (symbol '1'))))
517 9
517 9
518 8
518 8
519 7
519 7
520 6
520 6
521 5
521 5
522 4
522 4
523
523
524 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
524 $ hg debugrevspec -p parsed --no-show-revs 'not public()#generations[0]'
525 * parsed:
525 * parsed:
526 (not
526 (not
527 (relsubscript
527 (relsubscript
528 (func
528 (func
529 (symbol 'public')
529 (symbol 'public')
530 None)
530 None)
531 (symbol 'generations')
531 (symbol 'generations')
532 (symbol '0')))
532 (symbol '0')))
533
533
534 left-hand side of relation-subscript operator should be optimized recursively:
534 left-hand side of relation-subscript operator should be optimized recursively:
535
535
536 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
536 $ hg debugrevspec -p analyzed -p optimized --no-show-revs \
537 > '(not public())#generations[0]'
537 > '(not public())#generations[0]'
538 * analyzed:
538 * analyzed:
539 (relsubscript
539 (relsubscript
540 (not
540 (not
541 (func
541 (func
542 (symbol 'public')
542 (symbol 'public')
543 None))
543 None))
544 (symbol 'generations')
544 (symbol 'generations')
545 (symbol '0'))
545 (symbol '0'))
546 * optimized:
546 * optimized:
547 (relsubscript
547 (relsubscript
548 (func
548 (func
549 (symbol '_notpublic')
549 (symbol '_notpublic')
550 None)
550 None)
551 (symbol 'generations')
551 (symbol 'generations')
552 (symbol '0'))
552 (symbol '0'))
553
553
554 resolution of subscript and relation-subscript ternary operators:
554 resolution of subscript and relation-subscript ternary operators:
555
555
556 $ hg debugrevspec -p analyzed 'tip[0]'
556 $ hg debugrevspec -p analyzed 'tip[0]'
557 * analyzed:
557 * analyzed:
558 (subscript
558 (subscript
559 (symbol 'tip')
559 (symbol 'tip')
560 (symbol '0'))
560 (symbol '0'))
561 hg: parse error: can't use a subscript in this context
561 hg: parse error: can't use a subscript in this context
562 [255]
562 [255]
563
563
564 $ hg debugrevspec -p analyzed 'tip#rel[0]'
564 $ hg debugrevspec -p analyzed 'tip#rel[0]'
565 * analyzed:
565 * analyzed:
566 (relsubscript
566 (relsubscript
567 (symbol 'tip')
567 (symbol 'tip')
568 (symbol 'rel')
568 (symbol 'rel')
569 (symbol '0'))
569 (symbol '0'))
570 hg: parse error: unknown identifier: rel
570 hg: parse error: unknown identifier: rel
571 [255]
571 [255]
572
572
573 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
573 $ hg debugrevspec -p analyzed '(tip#rel)[0]'
574 * analyzed:
574 * analyzed:
575 (subscript
575 (subscript
576 (relation
576 (relation
577 (symbol 'tip')
577 (symbol 'tip')
578 (symbol 'rel'))
578 (symbol 'rel'))
579 (symbol '0'))
579 (symbol '0'))
580 hg: parse error: can't use a subscript in this context
580 hg: parse error: can't use a subscript in this context
581 [255]
581 [255]
582
582
583 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
583 $ hg debugrevspec -p analyzed 'tip#rel[0][1]'
584 * analyzed:
584 * analyzed:
585 (subscript
585 (subscript
586 (relsubscript
586 (relsubscript
587 (symbol 'tip')
587 (symbol 'tip')
588 (symbol 'rel')
588 (symbol 'rel')
589 (symbol '0'))
589 (symbol '0'))
590 (symbol '1'))
590 (symbol '1'))
591 hg: parse error: can't use a subscript in this context
591 hg: parse error: can't use a subscript in this context
592 [255]
592 [255]
593
593
594 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
594 $ hg debugrevspec -p analyzed 'tip#rel0#rel1[1]'
595 * analyzed:
595 * analyzed:
596 (relsubscript
596 (relsubscript
597 (relation
597 (relation
598 (symbol 'tip')
598 (symbol 'tip')
599 (symbol 'rel0'))
599 (symbol 'rel0'))
600 (symbol 'rel1')
600 (symbol 'rel1')
601 (symbol '1'))
601 (symbol '1'))
602 hg: parse error: unknown identifier: rel1
602 hg: parse error: unknown identifier: rel1
603 [255]
603 [255]
604
604
605 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
605 $ hg debugrevspec -p analyzed 'tip#rel0[0]#rel1[1]'
606 * analyzed:
606 * analyzed:
607 (relsubscript
607 (relsubscript
608 (relsubscript
608 (relsubscript
609 (symbol 'tip')
609 (symbol 'tip')
610 (symbol 'rel0')
610 (symbol 'rel0')
611 (symbol '0'))
611 (symbol '0'))
612 (symbol 'rel1')
612 (symbol 'rel1')
613 (symbol '1'))
613 (symbol '1'))
614 hg: parse error: unknown identifier: rel1
614 hg: parse error: unknown identifier: rel1
615 [255]
615 [255]
616
616
617 parse errors of relation, subscript and relation-subscript operators:
617 parse errors of relation, subscript and relation-subscript operators:
618
618
619 $ hg debugrevspec '[0]'
619 $ hg debugrevspec '[0]'
620 hg: parse error at 0: not a prefix: [
620 hg: parse error at 0: not a prefix: [
621 ([0]
621 ([0]
622 ^ here)
622 ^ here)
623 [255]
623 [255]
624 $ hg debugrevspec '.#'
624 $ hg debugrevspec '.#'
625 hg: parse error at 2: not a prefix: end
625 hg: parse error at 2: not a prefix: end
626 (.#
626 (.#
627 ^ here)
627 ^ here)
628 [255]
628 [255]
629 $ hg debugrevspec '#rel'
629 $ hg debugrevspec '#rel'
630 hg: parse error at 0: not a prefix: #
630 hg: parse error at 0: not a prefix: #
631 (#rel
631 (#rel
632 ^ here)
632 ^ here)
633 [255]
633 [255]
634 $ hg debugrevspec '.#rel[0'
634 $ hg debugrevspec '.#rel[0'
635 hg: parse error at 7: unexpected token: end
635 hg: parse error at 7: unexpected token: end
636 (.#rel[0
636 (.#rel[0
637 ^ here)
637 ^ here)
638 [255]
638 [255]
639 $ hg debugrevspec '.]'
639 $ hg debugrevspec '.]'
640 hg: parse error at 1: invalid token
640 hg: parse error at 1: invalid token
641 (.]
641 (.]
642 ^ here)
642 ^ here)
643 [255]
643 [255]
644
644
645 $ hg debugrevspec '.#generations[a]'
645 $ hg debugrevspec '.#generations[a]'
646 hg: parse error: relation subscript must be an integer or a range
646 hg: parse error: relation subscript must be an integer or a range
647 [255]
647 [255]
648 $ hg debugrevspec '.#generations[1-2]'
648 $ hg debugrevspec '.#generations[1-2]'
649 hg: parse error: relation subscript must be an integer or a range
649 hg: parse error: relation subscript must be an integer or a range
650 [255]
650 [255]
651 $ hg debugrevspec '.#generations[foo:bar]'
651 $ hg debugrevspec '.#generations[foo:bar]'
652 hg: parse error: relation subscript bounds must be integers
652 hg: parse error: relation subscript bounds must be integers
653 [255]
653 [255]
654
654
655 suggested relations
655 suggested relations
656
656
657 $ hg debugrevspec '.#generafions[0]'
657 $ hg debugrevspec '.#generafions[0]'
658 hg: parse error: unknown identifier: generafions
658 hg: parse error: unknown identifier: generafions
659 (did you mean generations?)
659 (did you mean generations?)
660 [255]
660 [255]
661
661
662 $ hg debugrevspec '.#f[0]'
662 $ hg debugrevspec '.#f[0]'
663 hg: parse error: unknown identifier: f
663 hg: parse error: unknown identifier: f
664 [255]
664 [255]
665
665
666 parsed tree at stages:
666 parsed tree at stages:
667
667
668 $ hg debugrevspec -p all '()'
668 $ hg debugrevspec -p all '()'
669 * parsed:
669 * parsed:
670 (group
670 (group
671 None)
671 None)
672 * expanded:
672 * expanded:
673 (group
673 (group
674 None)
674 None)
675 * concatenated:
675 * concatenated:
676 (group
676 (group
677 None)
677 None)
678 * analyzed:
678 * analyzed:
679 None
679 None
680 * optimized:
680 * optimized:
681 None
681 None
682 hg: parse error: missing argument
682 hg: parse error: missing argument
683 [255]
683 [255]
684
684
685 $ hg debugrevspec --no-optimized -p all '()'
685 $ hg debugrevspec --no-optimized -p all '()'
686 * parsed:
686 * parsed:
687 (group
687 (group
688 None)
688 None)
689 * expanded:
689 * expanded:
690 (group
690 (group
691 None)
691 None)
692 * concatenated:
692 * concatenated:
693 (group
693 (group
694 None)
694 None)
695 * analyzed:
695 * analyzed:
696 None
696 None
697 hg: parse error: missing argument
697 hg: parse error: missing argument
698 [255]
698 [255]
699
699
700 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
700 $ hg debugrevspec -p parsed -p analyzed -p optimized '(0|1)-1'
701 * parsed:
701 * parsed:
702 (minus
702 (minus
703 (group
703 (group
704 (or
704 (or
705 (list
705 (list
706 (symbol '0')
706 (symbol '0')
707 (symbol '1'))))
707 (symbol '1'))))
708 (symbol '1'))
708 (symbol '1'))
709 * analyzed:
709 * analyzed:
710 (and
710 (and
711 (or
711 (or
712 (list
712 (list
713 (symbol '0')
713 (symbol '0')
714 (symbol '1')))
714 (symbol '1')))
715 (not
715 (not
716 (symbol '1')))
716 (symbol '1')))
717 * optimized:
717 * optimized:
718 (difference
718 (difference
719 (func
719 (func
720 (symbol '_list')
720 (symbol '_list')
721 (string '0\x001'))
721 (string '0\x001'))
722 (symbol '1'))
722 (symbol '1'))
723 0
723 0
724
724
725 $ hg debugrevspec -p unknown '0'
725 $ hg debugrevspec -p unknown '0'
726 abort: invalid stage name: unknown
726 abort: invalid stage name: unknown
727 [255]
727 [255]
728
728
729 $ hg debugrevspec -p all --optimize '0'
729 $ hg debugrevspec -p all --optimize '0'
730 abort: cannot use --optimize with --show-stage
730 abort: cannot use --optimize with --show-stage
731 [255]
731 [255]
732
732
733 verify optimized tree:
733 verify optimized tree:
734
734
735 $ hg debugrevspec --verify '0|1'
735 $ hg debugrevspec --verify '0|1'
736
736
737 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
737 $ hg debugrevspec --verify -v -p analyzed -p optimized 'r3232() & 2'
738 * analyzed:
738 * analyzed:
739 (and
739 (and
740 (func
740 (func
741 (symbol 'r3232')
741 (symbol 'r3232')
742 None)
742 None)
743 (symbol '2'))
743 (symbol '2'))
744 * optimized:
744 * optimized:
745 (andsmally
745 (andsmally
746 (func
746 (func
747 (symbol 'r3232')
747 (symbol 'r3232')
748 None)
748 None)
749 (symbol '2'))
749 (symbol '2'))
750 * analyzed set:
750 * analyzed set:
751 <baseset [2]>
751 <baseset [2]>
752 * optimized set:
752 * optimized set:
753 <baseset [2, 2]>
753 <baseset [2, 2]>
754 --- analyzed
754 --- analyzed
755 +++ optimized
755 +++ optimized
756 2
756 2
757 +2
757 +2
758 [1]
758 [1]
759
759
760 $ hg debugrevspec --no-optimized --verify-optimized '0'
760 $ hg debugrevspec --no-optimized --verify-optimized '0'
761 abort: cannot use --verify-optimized with --no-optimized
761 abort: cannot use --verify-optimized with --no-optimized
762 [255]
762 [255]
763
763
764 Test that symbols only get parsed as functions if there's an opening
764 Test that symbols only get parsed as functions if there's an opening
765 parenthesis.
765 parenthesis.
766
766
767 $ hg book only -r 9
767 $ hg book only -r 9
768 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
768 $ log 'only(only)' # Outer "only" is a function, inner "only" is the bookmark
769 8
769 8
770 9
770 9
771
771
772 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
772 ':y' behaves like '0:y', but can't be rewritten as such since the revision '0'
773 may be hidden (issue5385)
773 may be hidden (issue5385)
774
774
775 $ try -p parsed -p analyzed ':'
775 $ try -p parsed -p analyzed ':'
776 * parsed:
776 * parsed:
777 (rangeall
777 (rangeall
778 None)
778 None)
779 * analyzed:
779 * analyzed:
780 (rangeall
780 (rangeall
781 None)
781 None)
782 * set:
782 * set:
783 <spanset+ 0:10>
783 <spanset+ 0:10>
784 0
784 0
785 1
785 1
786 2
786 2
787 3
787 3
788 4
788 4
789 5
789 5
790 6
790 6
791 7
791 7
792 8
792 8
793 9
793 9
794 $ try -p analyzed ':1'
794 $ try -p analyzed ':1'
795 * analyzed:
795 * analyzed:
796 (rangepre
796 (rangepre
797 (symbol '1'))
797 (symbol '1'))
798 * set:
798 * set:
799 <spanset+ 0:2>
799 <spanset+ 0:2>
800 0
800 0
801 1
801 1
802 $ try -p analyzed ':(1|2)'
802 $ try -p analyzed ':(1|2)'
803 * analyzed:
803 * analyzed:
804 (rangepre
804 (rangepre
805 (or
805 (or
806 (list
806 (list
807 (symbol '1')
807 (symbol '1')
808 (symbol '2'))))
808 (symbol '2'))))
809 * set:
809 * set:
810 <spanset+ 0:3>
810 <spanset+ 0:3>
811 0
811 0
812 1
812 1
813 2
813 2
814 $ try -p analyzed ':(1&2)'
814 $ try -p analyzed ':(1&2)'
815 * analyzed:
815 * analyzed:
816 (rangepre
816 (rangepre
817 (and
817 (and
818 (symbol '1')
818 (symbol '1')
819 (symbol '2')))
819 (symbol '2')))
820 * set:
820 * set:
821 <baseset []>
821 <baseset []>
822
822
823 infix/suffix resolution of ^ operator (issue2884, issue5764):
823 infix/suffix resolution of ^ operator (issue2884, issue5764):
824
824
825 x^:y means (x^):y
825 x^:y means (x^):y
826
826
827 $ try '1^:2'
827 $ try '1^:2'
828 (range
828 (range
829 (parentpost
829 (parentpost
830 (symbol '1'))
830 (symbol '1'))
831 (symbol '2'))
831 (symbol '2'))
832 * set:
832 * set:
833 <spanset+ 0:3>
833 <spanset+ 0:3>
834 0
834 0
835 1
835 1
836 2
836 2
837
837
838 $ try '1^::2'
838 $ try '1^::2'
839 (dagrange
839 (dagrange
840 (parentpost
840 (parentpost
841 (symbol '1'))
841 (symbol '1'))
842 (symbol '2'))
842 (symbol '2'))
843 * set:
843 * set:
844 <baseset+ [0, 1, 2]>
844 <baseset+ [0, 1, 2]>
845 0
845 0
846 1
846 1
847 2
847 2
848
848
849 $ try '1^..2'
849 $ try '1^..2'
850 (dagrange
850 (dagrange
851 (parentpost
851 (parentpost
852 (symbol '1'))
852 (symbol '1'))
853 (symbol '2'))
853 (symbol '2'))
854 * set:
854 * set:
855 <baseset+ [0, 1, 2]>
855 <baseset+ [0, 1, 2]>
856 0
856 0
857 1
857 1
858 2
858 2
859
859
860 $ try '9^:'
860 $ try '9^:'
861 (rangepost
861 (rangepost
862 (parentpost
862 (parentpost
863 (symbol '9')))
863 (symbol '9')))
864 * set:
864 * set:
865 <spanset+ 8:10>
865 <spanset+ 8:10>
866 8
866 8
867 9
867 9
868
868
869 $ try '9^::'
869 $ try '9^::'
870 (dagrangepost
870 (dagrangepost
871 (parentpost
871 (parentpost
872 (symbol '9')))
872 (symbol '9')))
873 * set:
873 * set:
874 <generatorsetasc+>
874 <generatorsetasc+>
875 8
875 8
876 9
876 9
877
877
878 $ try '9^..'
878 $ try '9^..'
879 (dagrangepost
879 (dagrangepost
880 (parentpost
880 (parentpost
881 (symbol '9')))
881 (symbol '9')))
882 * set:
882 * set:
883 <generatorsetasc+>
883 <generatorsetasc+>
884 8
884 8
885 9
885 9
886
886
887 x^:y should be resolved before omitting group operators
887 x^:y should be resolved before omitting group operators
888
888
889 $ try '1^(:2)'
889 $ try '1^(:2)'
890 (parent
890 (parent
891 (symbol '1')
891 (symbol '1')
892 (group
892 (group
893 (rangepre
893 (rangepre
894 (symbol '2'))))
894 (symbol '2'))))
895 hg: parse error: ^ expects a number 0, 1, or 2
895 hg: parse error: ^ expects a number 0, 1, or 2
896 [255]
896 [255]
897
897
898 x^:y should be resolved recursively
898 x^:y should be resolved recursively
899
899
900 $ try 'sort(1^:2)'
900 $ try 'sort(1^:2)'
901 (func
901 (func
902 (symbol 'sort')
902 (symbol 'sort')
903 (range
903 (range
904 (parentpost
904 (parentpost
905 (symbol '1'))
905 (symbol '1'))
906 (symbol '2')))
906 (symbol '2')))
907 * set:
907 * set:
908 <spanset+ 0:3>
908 <spanset+ 0:3>
909 0
909 0
910 1
910 1
911 2
911 2
912
912
913 $ try '(3^:4)^:2'
913 $ try '(3^:4)^:2'
914 (range
914 (range
915 (parentpost
915 (parentpost
916 (group
916 (group
917 (range
917 (range
918 (parentpost
918 (parentpost
919 (symbol '3'))
919 (symbol '3'))
920 (symbol '4'))))
920 (symbol '4'))))
921 (symbol '2'))
921 (symbol '2'))
922 * set:
922 * set:
923 <spanset+ 0:3>
923 <spanset+ 0:3>
924 0
924 0
925 1
925 1
926 2
926 2
927
927
928 $ try '(3^::4)^::2'
928 $ try '(3^::4)^::2'
929 (dagrange
929 (dagrange
930 (parentpost
930 (parentpost
931 (group
931 (group
932 (dagrange
932 (dagrange
933 (parentpost
933 (parentpost
934 (symbol '3'))
934 (symbol '3'))
935 (symbol '4'))))
935 (symbol '4'))))
936 (symbol '2'))
936 (symbol '2'))
937 * set:
937 * set:
938 <baseset+ [0, 1, 2]>
938 <baseset+ [0, 1, 2]>
939 0
939 0
940 1
940 1
941 2
941 2
942
942
943 $ try '(9^:)^:'
943 $ try '(9^:)^:'
944 (rangepost
944 (rangepost
945 (parentpost
945 (parentpost
946 (group
946 (group
947 (rangepost
947 (rangepost
948 (parentpost
948 (parentpost
949 (symbol '9'))))))
949 (symbol '9'))))))
950 * set:
950 * set:
951 <spanset+ 4:10>
951 <spanset+ 4:10>
952 4
952 4
953 5
953 5
954 6
954 6
955 7
955 7
956 8
956 8
957 9
957 9
958
958
959 x^ in alias should also be resolved
959 x^ in alias should also be resolved
960
960
961 $ try 'A' --config 'revsetalias.A=1^:2'
961 $ try 'A' --config 'revsetalias.A=1^:2'
962 (symbol 'A')
962 (symbol 'A')
963 * expanded:
963 * expanded:
964 (range
964 (range
965 (parentpost
965 (parentpost
966 (symbol '1'))
966 (symbol '1'))
967 (symbol '2'))
967 (symbol '2'))
968 * set:
968 * set:
969 <spanset+ 0:3>
969 <spanset+ 0:3>
970 0
970 0
971 1
971 1
972 2
972 2
973
973
974 $ try 'A:2' --config 'revsetalias.A=1^'
974 $ try 'A:2' --config 'revsetalias.A=1^'
975 (range
975 (range
976 (symbol 'A')
976 (symbol 'A')
977 (symbol '2'))
977 (symbol '2'))
978 * expanded:
978 * expanded:
979 (range
979 (range
980 (parentpost
980 (parentpost
981 (symbol '1'))
981 (symbol '1'))
982 (symbol '2'))
982 (symbol '2'))
983 * set:
983 * set:
984 <spanset+ 0:3>
984 <spanset+ 0:3>
985 0
985 0
986 1
986 1
987 2
987 2
988
988
989 but not beyond the boundary of alias expansion, because the resolution should
989 but not beyond the boundary of alias expansion, because the resolution should
990 be made at the parsing stage
990 be made at the parsing stage
991
991
992 $ try '1^A' --config 'revsetalias.A=:2'
992 $ try '1^A' --config 'revsetalias.A=:2'
993 (parent
993 (parent
994 (symbol '1')
994 (symbol '1')
995 (symbol 'A'))
995 (symbol 'A'))
996 * expanded:
996 * expanded:
997 (parent
997 (parent
998 (symbol '1')
998 (symbol '1')
999 (rangepre
999 (rangepre
1000 (symbol '2')))
1000 (symbol '2')))
1001 hg: parse error: ^ expects a number 0, 1, or 2
1001 hg: parse error: ^ expects a number 0, 1, or 2
1002 [255]
1002 [255]
1003
1003
1004 '::' itself isn't a valid expression
1004 '::' itself isn't a valid expression
1005
1005
1006 $ try '::'
1006 $ try '::'
1007 (dagrangeall
1007 (dagrangeall
1008 None)
1008 None)
1009 hg: parse error: can't use '::' in this context
1009 hg: parse error: can't use '::' in this context
1010 [255]
1010 [255]
1011
1011
1012 ancestor can accept 0 or more arguments
1012 ancestor can accept 0 or more arguments
1013
1013
1014 $ log 'ancestor()'
1014 $ log 'ancestor()'
1015 $ log 'ancestor(1)'
1015 $ log 'ancestor(1)'
1016 1
1016 1
1017 $ log 'ancestor(4,5)'
1017 $ log 'ancestor(4,5)'
1018 1
1018 1
1019 $ log 'ancestor(4,5) and 4'
1019 $ log 'ancestor(4,5) and 4'
1020 $ log 'ancestor(0,0,1,3)'
1020 $ log 'ancestor(0,0,1,3)'
1021 0
1021 0
1022 $ log 'ancestor(3,1,5,3,5,1)'
1022 $ log 'ancestor(3,1,5,3,5,1)'
1023 1
1023 1
1024 $ log 'ancestor(0,1,3,5)'
1024 $ log 'ancestor(0,1,3,5)'
1025 0
1025 0
1026 $ log 'ancestor(1,2,3,4,5)'
1026 $ log 'ancestor(1,2,3,4,5)'
1027 1
1027 1
1028
1028
1029 test ancestors
1029 test ancestors
1030
1030
1031 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1031 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1032 @ 9
1032 @ 9
1033 o 8
1033 o 8
1034 | o 7
1034 | o 7
1035 | o 6
1035 | o 6
1036 |/|
1036 |/|
1037 | o 5
1037 | o 5
1038 o | 4
1038 o | 4
1039 | o 3
1039 | o 3
1040 o | 2
1040 o | 2
1041 |/
1041 |/
1042 o 1
1042 o 1
1043 o 0
1043 o 0
1044
1044
1045 $ log 'ancestors(5)'
1045 $ log 'ancestors(5)'
1046 0
1046 0
1047 1
1047 1
1048 3
1048 3
1049 5
1049 5
1050 $ log 'ancestor(ancestors(5))'
1050 $ log 'ancestor(ancestors(5))'
1051 0
1051 0
1052 $ log '::r3232()'
1052 $ log '::r3232()'
1053 0
1053 0
1054 1
1054 1
1055 2
1055 2
1056 3
1056 3
1057
1057
1058 test common ancestors
1058 test common ancestors
1059
1059
1060 $ hg log -T '{rev}\n' -r 'commonancestors(7 + 9)'
1060 $ hg log -T '{rev}\n' -r 'commonancestors(7 + 9)'
1061 0
1061 0
1062 1
1062 1
1063 2
1063 2
1064 4
1064 4
1065
1065
1066 $ hg log -T '{rev}\n' -r 'commonancestors(heads(all()))'
1066 $ hg log -T '{rev}\n' -r 'commonancestors(heads(all()))'
1067 0
1067 0
1068 1
1068 1
1069 2
1069 2
1070 4
1070 4
1071
1071
1072 $ hg log -T '{rev}\n' -r 'commonancestors(9)'
1072 $ hg log -T '{rev}\n' -r 'commonancestors(9)'
1073 0
1073 0
1074 1
1074 1
1075 2
1075 2
1076 4
1076 4
1077 8
1077 8
1078 9
1078 9
1079
1079
1080 $ hg log -T '{rev}\n' -r 'commonancestors(8 + 9)'
1080 $ hg log -T '{rev}\n' -r 'commonancestors(8 + 9)'
1081 0
1081 0
1082 1
1082 1
1083 2
1083 2
1084 4
1084 4
1085 8
1085 8
1086
1086
1087 test the specialized implementation of heads(commonancestors(..))
1087 test the specialized implementation of heads(commonancestors(..))
1088 (2 gcas is tested in test-merge-criss-cross.t)
1088 (2 gcas is tested in test-merge-criss-cross.t)
1089
1089
1090 $ hg log -T '{rev}\n' -r 'heads(commonancestors(7 + 9))'
1090 $ hg log -T '{rev}\n' -r 'heads(commonancestors(7 + 9))'
1091 4
1091 4
1092 $ hg log -T '{rev}\n' -r 'heads(commonancestors(heads(all())))'
1092 $ hg log -T '{rev}\n' -r 'heads(commonancestors(heads(all())))'
1093 4
1093 4
1094 $ hg log -T '{rev}\n' -r 'heads(commonancestors(9))'
1094 $ hg log -T '{rev}\n' -r 'heads(commonancestors(9))'
1095 9
1095 9
1096 $ hg log -T '{rev}\n' -r 'heads(commonancestors(8 + 9))'
1096 $ hg log -T '{rev}\n' -r 'heads(commonancestors(8 + 9))'
1097 8
1097 8
1098
1098
1099 test ancestor variants of empty revision
1099 test ancestor variants of empty revision
1100
1100
1101 $ log 'ancestor(none())'
1101 $ log 'ancestor(none())'
1102 $ log 'ancestors(none())'
1102 $ log 'ancestors(none())'
1103 $ log 'commonancestors(none())'
1103 $ log 'commonancestors(none())'
1104 $ log 'heads(commonancestors(none()))'
1104 $ log 'heads(commonancestors(none()))'
1105
1105
1106 test ancestors with depth limit
1106 test ancestors with depth limit
1107
1107
1108 (depth=0 selects the node itself)
1108 (depth=0 selects the node itself)
1109
1109
1110 $ log 'reverse(ancestors(9, depth=0))'
1110 $ log 'reverse(ancestors(9, depth=0))'
1111 9
1111 9
1112
1112
1113 (interleaved: '4' would be missing if heap queue were higher depth first)
1113 (interleaved: '4' would be missing if heap queue were higher depth first)
1114
1114
1115 $ log 'reverse(ancestors(8:9, depth=1))'
1115 $ log 'reverse(ancestors(8:9, depth=1))'
1116 9
1116 9
1117 8
1117 8
1118 4
1118 4
1119
1119
1120 (interleaved: '2' would be missing if heap queue were higher depth first)
1120 (interleaved: '2' would be missing if heap queue were higher depth first)
1121
1121
1122 $ log 'reverse(ancestors(7+8, depth=2))'
1122 $ log 'reverse(ancestors(7+8, depth=2))'
1123 8
1123 8
1124 7
1124 7
1125 6
1125 6
1126 5
1126 5
1127 4
1127 4
1128 2
1128 2
1129
1129
1130 (walk example above by separate queries)
1130 (walk example above by separate queries)
1131
1131
1132 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1132 $ log 'reverse(ancestors(8, depth=2)) + reverse(ancestors(7, depth=2))'
1133 8
1133 8
1134 4
1134 4
1135 2
1135 2
1136 7
1136 7
1137 6
1137 6
1138 5
1138 5
1139
1139
1140 (walk 2nd and 3rd ancestors)
1140 (walk 2nd and 3rd ancestors)
1141
1141
1142 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1142 $ log 'reverse(ancestors(7, depth=3, startdepth=2))'
1143 5
1143 5
1144 4
1144 4
1145 3
1145 3
1146 2
1146 2
1147
1147
1148 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1148 (interleaved: '4' would be missing if higher-depth ancestors weren't scanned)
1149
1149
1150 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1150 $ log 'reverse(ancestors(7+8, depth=2, startdepth=2))'
1151 5
1151 5
1152 4
1152 4
1153 2
1153 2
1154
1154
1155 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1155 (note that 'ancestors(x, depth=y, startdepth=z)' does not identical to
1156 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1156 'ancestors(x, depth=y) - ancestors(x, depth=z-1)' because a node may have
1157 multiple depths)
1157 multiple depths)
1158
1158
1159 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1159 $ log 'reverse(ancestors(7+8, depth=2) - ancestors(7+8, depth=1))'
1160 5
1160 5
1161 2
1161 2
1162
1162
1163 test bad arguments passed to ancestors()
1163 test bad arguments passed to ancestors()
1164
1164
1165 $ log 'ancestors(., depth=-1)'
1165 $ log 'ancestors(., depth=-1)'
1166 hg: parse error: negative depth
1166 hg: parse error: negative depth
1167 [255]
1167 [255]
1168 $ log 'ancestors(., depth=foo)'
1168 $ log 'ancestors(., depth=foo)'
1169 hg: parse error: ancestors expects an integer depth
1169 hg: parse error: ancestors expects an integer depth
1170 [255]
1170 [255]
1171
1171
1172 test descendants
1172 test descendants
1173
1173
1174 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1174 $ hg log -G -T '{rev}\n' --config experimental.graphshorten=True
1175 @ 9
1175 @ 9
1176 o 8
1176 o 8
1177 | o 7
1177 | o 7
1178 | o 6
1178 | o 6
1179 |/|
1179 |/|
1180 | o 5
1180 | o 5
1181 o | 4
1181 o | 4
1182 | o 3
1182 | o 3
1183 o | 2
1183 o | 2
1184 |/
1184 |/
1185 o 1
1185 o 1
1186 o 0
1186 o 0
1187
1187
1188 (null is ultimate root and has optimized path)
1188 (null is ultimate root and has optimized path)
1189
1189
1190 $ log 'null:4 & descendants(null)'
1190 $ log 'null:4 & descendants(null)'
1191 -1
1191 -1
1192 0
1192 0
1193 1
1193 1
1194 2
1194 2
1195 3
1195 3
1196 4
1196 4
1197
1197
1198 (including merge)
1198 (including merge)
1199
1199
1200 $ log ':8 & descendants(2)'
1200 $ log ':8 & descendants(2)'
1201 2
1201 2
1202 4
1202 4
1203 6
1203 6
1204 7
1204 7
1205 8
1205 8
1206
1206
1207 (multiple roots)
1207 (multiple roots)
1208
1208
1209 $ log ':8 & descendants(2+5)'
1209 $ log ':8 & descendants(2+5)'
1210 2
1210 2
1211 4
1211 4
1212 5
1212 5
1213 6
1213 6
1214 7
1214 7
1215 8
1215 8
1216
1216
1217 test descendants with depth limit
1217 test descendants with depth limit
1218
1218
1219 (depth=0 selects the node itself)
1219 (depth=0 selects the node itself)
1220
1220
1221 $ log 'descendants(0, depth=0)'
1221 $ log 'descendants(0, depth=0)'
1222 0
1222 0
1223 $ log 'null: & descendants(null, depth=0)'
1223 $ log 'null: & descendants(null, depth=0)'
1224 -1
1224 -1
1225
1225
1226 (p2 = null should be ignored)
1226 (p2 = null should be ignored)
1227
1227
1228 $ log 'null: & descendants(null, depth=2)'
1228 $ log 'null: & descendants(null, depth=2)'
1229 -1
1229 -1
1230 0
1230 0
1231 1
1231 1
1232
1232
1233 (multiple paths: depth(6) = (2, 3))
1233 (multiple paths: depth(6) = (2, 3))
1234
1234
1235 $ log 'descendants(1+3, depth=2)'
1235 $ log 'descendants(1+3, depth=2)'
1236 1
1236 1
1237 2
1237 2
1238 3
1238 3
1239 4
1239 4
1240 5
1240 5
1241 6
1241 6
1242
1242
1243 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1243 (multiple paths: depth(5) = (1, 2), depth(6) = (2, 3))
1244
1244
1245 $ log 'descendants(3+1, depth=2, startdepth=2)'
1245 $ log 'descendants(3+1, depth=2, startdepth=2)'
1246 4
1246 4
1247 5
1247 5
1248 6
1248 6
1249
1249
1250 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1250 (multiple depths: depth(6) = (0, 2, 4), search for depth=2)
1251
1251
1252 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1252 $ log 'descendants(0+3+6, depth=3, startdepth=1)'
1253 1
1253 1
1254 2
1254 2
1255 3
1255 3
1256 4
1256 4
1257 5
1257 5
1258 6
1258 6
1259 7
1259 7
1260
1260
1261 (multiple depths: depth(6) = (0, 4), no match)
1261 (multiple depths: depth(6) = (0, 4), no match)
1262
1262
1263 $ log 'descendants(0+6, depth=3, startdepth=1)'
1263 $ log 'descendants(0+6, depth=3, startdepth=1)'
1264 1
1264 1
1265 2
1265 2
1266 3
1266 3
1267 4
1267 4
1268 5
1268 5
1269 7
1269 7
1270
1270
1271 test ancestors/descendants relation subscript:
1271 test ancestors/descendants relation subscript:
1272
1272
1273 $ log 'tip#generations[0]'
1273 $ log 'tip#generations[0]'
1274 9
1274 9
1275 $ log '.#generations[-1]'
1275 $ log '.#generations[-1]'
1276 8
1276 8
1277 $ log '.#g[(-1)]'
1277 $ log '.#g[(-1)]'
1278 8
1278 8
1279
1279
1280 $ log '6#generations[0:1]'
1280 $ log '6#generations[0:1]'
1281 6
1281 6
1282 7
1282 7
1283 $ log '6#generations[-1:1]'
1283 $ log '6#generations[-1:1]'
1284 4
1284 4
1285 5
1285 5
1286 6
1286 6
1287 7
1287 7
1288 $ log '6#generations[0:]'
1288 $ log '6#generations[0:]'
1289 6
1289 6
1290 7
1290 7
1291 $ log '5#generations[:0]'
1291 $ log '5#generations[:0]'
1292 0
1292 0
1293 1
1293 1
1294 3
1294 3
1295 5
1295 5
1296 $ log '3#generations[:]'
1296 $ log '3#generations[:]'
1297 0
1297 0
1298 1
1298 1
1299 3
1299 3
1300 5
1300 5
1301 6
1301 6
1302 7
1302 7
1303 $ log 'tip#generations[1:-1]'
1303 $ log 'tip#generations[1:-1]'
1304
1304
1305 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1305 $ hg debugrevspec -p parsed 'roots(:)#g[2]'
1306 * parsed:
1306 * parsed:
1307 (relsubscript
1307 (relsubscript
1308 (func
1308 (func
1309 (symbol 'roots')
1309 (symbol 'roots')
1310 (rangeall
1310 (rangeall
1311 None))
1311 None))
1312 (symbol 'g')
1312 (symbol 'g')
1313 (symbol '2'))
1313 (symbol '2'))
1314 2
1314 2
1315 3
1315 3
1316
1316
1317 test author
1317 test author
1318
1318
1319 $ log 'author(bob)'
1319 $ log 'author(bob)'
1320 2
1320 2
1321 $ log 'author("re:bob|test")'
1321 $ log 'author("re:bob|test")'
1322 0
1322 0
1323 1
1323 1
1324 2
1324 2
1325 3
1325 3
1326 4
1326 4
1327 5
1327 5
1328 6
1328 6
1329 7
1329 7
1330 8
1330 8
1331 9
1331 9
1332 $ log 'author(r"re:\S")'
1332 $ log 'author(r"re:\S")'
1333 0
1333 0
1334 1
1334 1
1335 2
1335 2
1336 3
1336 3
1337 4
1337 4
1338 5
1338 5
1339 6
1339 6
1340 7
1340 7
1341 8
1341 8
1342 9
1342 9
1343 $ log 'branch(Γ©)'
1343 $ log 'branch(Γ©)'
1344 8
1344 8
1345 9
1345 9
1346 $ log 'branch(a)'
1346 $ log 'branch(a)'
1347 0
1347 0
1348 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1348 $ hg log -r 'branch("re:a")' --template '{rev} {branch}\n'
1349 0 a
1349 0 a
1350 2 a-b-c-
1350 2 a-b-c-
1351 3 +a+b+c+
1351 3 +a+b+c+
1352 4 -a-b-c-
1352 4 -a-b-c-
1353 5 !a/b/c/
1353 5 !a/b/c/
1354 6 _a_b_c_
1354 6 _a_b_c_
1355 7 .a.b.c.
1355 7 .a.b.c.
1356 $ log 'children(ancestor(4,5))'
1356 $ log 'children(ancestor(4,5))'
1357 2
1357 2
1358 3
1358 3
1359
1359
1360 $ log 'children(4)'
1360 $ log 'children(4)'
1361 6
1361 6
1362 8
1362 8
1363 $ log 'children(null)'
1363 $ log 'children(null)'
1364 0
1364 0
1365
1365
1366 $ log 'closed()'
1366 $ log 'closed()'
1367 $ log 'contains(a)'
1367 $ log 'contains(a)'
1368 0
1368 0
1369 1
1369 1
1370 3
1370 3
1371 5
1371 5
1372 $ log 'contains("../repo/a")'
1372 $ log 'contains("../repo/a")'
1373 0
1373 0
1374 1
1374 1
1375 3
1375 3
1376 5
1376 5
1377 $ log 'desc(B)'
1377 $ log 'desc(B)'
1378 5
1378 5
1379 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1379 $ hg log -r 'desc(r"re:S?u")' --template "{rev} {desc|firstline}\n"
1380 5 5 bug
1380 5 5 bug
1381 6 6 issue619
1381 6 6 issue619
1382 $ log 'descendants(2 or 3)'
1382 $ log 'descendants(2 or 3)'
1383 2
1383 2
1384 3
1384 3
1385 4
1385 4
1386 5
1386 5
1387 6
1387 6
1388 7
1388 7
1389 8
1389 8
1390 9
1390 9
1391 $ log 'file("b*")'
1391 $ log 'file("b*")'
1392 1
1392 1
1393 4
1393 4
1394 $ log 'filelog("b")'
1394 $ log 'filelog("b")'
1395 1
1395 1
1396 4
1396 4
1397 $ log 'filelog("../repo/b")'
1397 $ log 'filelog("../repo/b")'
1398 1
1398 1
1399 4
1399 4
1400 $ log 'follow()'
1400 $ log 'follow()'
1401 0
1401 0
1402 1
1402 1
1403 2
1403 2
1404 4
1404 4
1405 8
1405 8
1406 9
1406 9
1407 $ log 'grep("issue\d+")'
1407 $ log 'grep("issue\d+")'
1408 6
1408 6
1409 $ try 'grep("(")' # invalid regular expression
1409 $ try 'grep("(")' # invalid regular expression
1410 (func
1410 (func
1411 (symbol 'grep')
1411 (symbol 'grep')
1412 (string '('))
1412 (string '('))
1413 hg: parse error: invalid match pattern: (unbalanced parenthesis|missing \),.*) (re)
1413 hg: parse error: invalid match pattern: (unbalanced parenthesis|missing \),.*) (re)
1414 [255]
1414 [255]
1415 $ try 'grep("\bissue\d+")'
1415 $ try 'grep("\bissue\d+")'
1416 (func
1416 (func
1417 (symbol 'grep')
1417 (symbol 'grep')
1418 (string '\x08issue\\d+'))
1418 (string '\x08issue\\d+'))
1419 * set:
1419 * set:
1420 <filteredset
1420 <filteredset
1421 <fullreposet+ 0:10>,
1421 <fullreposet+ 0:10>,
1422 <grep '\x08issue\\d+'>>
1422 <grep '\x08issue\\d+'>>
1423 $ try 'grep(r"\bissue\d+")'
1423 $ try 'grep(r"\bissue\d+")'
1424 (func
1424 (func
1425 (symbol 'grep')
1425 (symbol 'grep')
1426 (string '\\bissue\\d+'))
1426 (string '\\bissue\\d+'))
1427 * set:
1427 * set:
1428 <filteredset
1428 <filteredset
1429 <fullreposet+ 0:10>,
1429 <fullreposet+ 0:10>,
1430 <grep '\\bissue\\d+'>>
1430 <grep '\\bissue\\d+'>>
1431 6
1431 6
1432 $ try 'grep(r"\")'
1432 $ try 'grep(r"\")'
1433 hg: parse error at 7: unterminated string
1433 hg: parse error at 7: unterminated string
1434 (grep(r"\")
1434 (grep(r"\")
1435 ^ here)
1435 ^ here)
1436 [255]
1436 [255]
1437 $ log 'head()'
1437 $ log 'head()'
1438 0
1438 0
1439 1
1439 1
1440 2
1440 2
1441 3
1441 3
1442 4
1442 4
1443 5
1443 5
1444 6
1444 6
1445 7
1445 7
1446 9
1446 9
1447
1447
1448 Test heads
1448 Test heads
1449
1449
1450 $ log 'heads(6::)'
1450 $ log 'heads(6::)'
1451 7
1451 7
1452
1452
1453 heads() can be computed in subset '9:'
1453 heads() can be computed in subset '9:'
1454
1454
1455 $ hg debugrevspec -s '9: & heads(all())'
1455 $ hg debugrevspec -s '9: & heads(all())'
1456 * set:
1456 * set:
1457 <filteredset
1457 <filteredset
1458 <baseset [9]>,
1458 <baseset [9]>,
1459 <baseset+ [7, 9]>>
1459 <baseset+ [7, 9]>>
1460 9
1460 9
1461
1461
1462 but should follow the order of the subset
1462 but should follow the order of the subset
1463
1463
1464 $ log 'heads(all())'
1464 $ log 'heads(all())'
1465 7
1465 7
1466 9
1466 9
1467 $ log 'heads(tip:0)'
1467 $ log 'heads(tip:0)'
1468 7
1468 7
1469 9
1469 9
1470 $ log 'tip:0 & heads(all())'
1470 $ log 'tip:0 & heads(all())'
1471 9
1471 9
1472 7
1472 7
1473 $ log 'tip:0 & heads(0:tip)'
1473 $ log 'tip:0 & heads(0:tip)'
1474 9
1474 9
1475 7
1475 7
1476
1476
1477 $ log 'keyword(issue)'
1477 $ log 'keyword(issue)'
1478 6
1478 6
1479 $ log 'keyword("test a")'
1479 $ log 'keyword("test a")'
1480
1480
1481 Test first (=limit) and last
1481 Test first (=limit) and last
1482
1482
1483 $ log 'limit(head(), 1)'
1483 $ log 'limit(head(), 1)'
1484 0
1484 0
1485 $ log 'limit(author("re:bob|test"), 3, 5)'
1485 $ log 'limit(author("re:bob|test"), 3, 5)'
1486 5
1486 5
1487 6
1487 6
1488 7
1488 7
1489 $ log 'limit(author("re:bob|test"), offset=6)'
1489 $ log 'limit(author("re:bob|test"), offset=6)'
1490 6
1490 6
1491 $ log 'limit(author("re:bob|test"), offset=10)'
1491 $ log 'limit(author("re:bob|test"), offset=10)'
1492 $ log 'limit(all(), 1, -1)'
1492 $ log 'limit(all(), 1, -1)'
1493 hg: parse error: negative offset
1493 hg: parse error: negative offset
1494 [255]
1494 [255]
1495 $ log 'limit(all(), -1)'
1495 $ log 'limit(all(), -1)'
1496 hg: parse error: negative number to select
1496 hg: parse error: negative number to select
1497 [255]
1497 [255]
1498 $ log 'limit(all(), 0)'
1498 $ log 'limit(all(), 0)'
1499
1499
1500 $ log 'last(all(), -1)'
1500 $ log 'last(all(), -1)'
1501 hg: parse error: negative number to select
1501 hg: parse error: negative number to select
1502 [255]
1502 [255]
1503 $ log 'last(all(), 0)'
1503 $ log 'last(all(), 0)'
1504 $ log 'last(all(), 1)'
1504 $ log 'last(all(), 1)'
1505 9
1505 9
1506 $ log 'last(all(), 2)'
1506 $ log 'last(all(), 2)'
1507 8
1507 8
1508 9
1508 9
1509
1509
1510 Test smartset.slice() by first/last()
1510 Test smartset.slice() by first/last()
1511
1511
1512 (using unoptimized set, filteredset as example)
1512 (using unoptimized set, filteredset as example)
1513
1513
1514 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1514 $ hg debugrevspec --no-show-revs -s '0:7 & branch("re:")'
1515 * set:
1515 * set:
1516 <filteredset
1516 <filteredset
1517 <spanset+ 0:8>,
1517 <spanset+ 0:8>,
1518 <branch 're:'>>
1518 <branch 're:'>>
1519 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1519 $ log 'limit(0:7 & branch("re:"), 3, 4)'
1520 4
1520 4
1521 5
1521 5
1522 6
1522 6
1523 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1523 $ log 'limit(7:0 & branch("re:"), 3, 4)'
1524 3
1524 3
1525 2
1525 2
1526 1
1526 1
1527 $ log 'last(0:7 & branch("re:"), 2)'
1527 $ log 'last(0:7 & branch("re:"), 2)'
1528 6
1528 6
1529 7
1529 7
1530
1530
1531 (using baseset)
1531 (using baseset)
1532
1532
1533 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1533 $ hg debugrevspec --no-show-revs -s 0+1+2+3+4+5+6+7
1534 * set:
1534 * set:
1535 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1535 <baseset [0, 1, 2, 3, 4, 5, 6, 7]>
1536 $ hg debugrevspec --no-show-revs -s 0::7
1536 $ hg debugrevspec --no-show-revs -s 0::7
1537 * set:
1537 * set:
1538 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1538 <baseset+ [0, 1, 2, 3, 4, 5, 6, 7]>
1539 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1539 $ log 'limit(0+1+2+3+4+5+6+7, 3, 4)'
1540 4
1540 4
1541 5
1541 5
1542 6
1542 6
1543 $ log 'limit(sort(0::7, rev), 3, 4)'
1543 $ log 'limit(sort(0::7, rev), 3, 4)'
1544 4
1544 4
1545 5
1545 5
1546 6
1546 6
1547 $ log 'limit(sort(0::7, -rev), 3, 4)'
1547 $ log 'limit(sort(0::7, -rev), 3, 4)'
1548 3
1548 3
1549 2
1549 2
1550 1
1550 1
1551 $ log 'last(sort(0::7, rev), 2)'
1551 $ log 'last(sort(0::7, rev), 2)'
1552 6
1552 6
1553 7
1553 7
1554 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1554 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 6)'
1555 * set:
1555 * set:
1556 <baseset+ [6, 7]>
1556 <baseset+ [6, 7]>
1557 6
1557 6
1558 7
1558 7
1559 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1559 $ hg debugrevspec -s 'limit(sort(0::7, rev), 3, 9)'
1560 * set:
1560 * set:
1561 <baseset+ []>
1561 <baseset+ []>
1562 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1562 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 6)'
1563 * set:
1563 * set:
1564 <baseset- [0, 1]>
1564 <baseset- [0, 1]>
1565 1
1565 1
1566 0
1566 0
1567 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1567 $ hg debugrevspec -s 'limit(sort(0::7, -rev), 3, 9)'
1568 * set:
1568 * set:
1569 <baseset- []>
1569 <baseset- []>
1570 $ hg debugrevspec -s 'limit(0::7, 0)'
1570 $ hg debugrevspec -s 'limit(0::7, 0)'
1571 * set:
1571 * set:
1572 <baseset+ []>
1572 <baseset+ []>
1573
1573
1574 (using spanset)
1574 (using spanset)
1575
1575
1576 $ hg debugrevspec --no-show-revs -s 0:7
1576 $ hg debugrevspec --no-show-revs -s 0:7
1577 * set:
1577 * set:
1578 <spanset+ 0:8>
1578 <spanset+ 0:8>
1579 $ log 'limit(0:7, 3, 4)'
1579 $ log 'limit(0:7, 3, 4)'
1580 4
1580 4
1581 5
1581 5
1582 6
1582 6
1583 $ log 'limit(7:0, 3, 4)'
1583 $ log 'limit(7:0, 3, 4)'
1584 3
1584 3
1585 2
1585 2
1586 1
1586 1
1587 $ log 'limit(0:7, 3, 6)'
1587 $ log 'limit(0:7, 3, 6)'
1588 6
1588 6
1589 7
1589 7
1590 $ log 'limit(7:0, 3, 6)'
1590 $ log 'limit(7:0, 3, 6)'
1591 1
1591 1
1592 0
1592 0
1593 $ log 'last(0:7, 2)'
1593 $ log 'last(0:7, 2)'
1594 6
1594 6
1595 7
1595 7
1596 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1596 $ hg debugrevspec -s 'limit(0:7, 3, 6)'
1597 * set:
1597 * set:
1598 <spanset+ 6:8>
1598 <spanset+ 6:8>
1599 6
1599 6
1600 7
1600 7
1601 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1601 $ hg debugrevspec -s 'limit(0:7, 3, 9)'
1602 * set:
1602 * set:
1603 <spanset+ 8:8>
1603 <spanset+ 8:8>
1604 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1604 $ hg debugrevspec -s 'limit(7:0, 3, 6)'
1605 * set:
1605 * set:
1606 <spanset- 0:2>
1606 <spanset- 0:2>
1607 1
1607 1
1608 0
1608 0
1609 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1609 $ hg debugrevspec -s 'limit(7:0, 3, 9)'
1610 * set:
1610 * set:
1611 <spanset- 0:0>
1611 <spanset- 0:0>
1612 $ hg debugrevspec -s 'limit(0:7, 0)'
1612 $ hg debugrevspec -s 'limit(0:7, 0)'
1613 * set:
1613 * set:
1614 <spanset+ 0:0>
1614 <spanset+ 0:0>
1615
1615
1616 Test order of first/last revisions
1616 Test order of first/last revisions
1617
1617
1618 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1618 $ hg debugrevspec -s 'first(4:0, 3) & 3:'
1619 * set:
1619 * set:
1620 <filteredset
1620 <filteredset
1621 <spanset- 2:5>,
1621 <spanset- 2:5>,
1622 <spanset+ 3:10>>
1622 <spanset+ 3:10>>
1623 4
1623 4
1624 3
1624 3
1625
1625
1626 $ hg debugrevspec -s '3: & first(4:0, 3)'
1626 $ hg debugrevspec -s '3: & first(4:0, 3)'
1627 * set:
1627 * set:
1628 <filteredset
1628 <filteredset
1629 <spanset+ 3:10>,
1629 <spanset+ 3:10>,
1630 <spanset- 2:5>>
1630 <spanset- 2:5>>
1631 3
1631 3
1632 4
1632 4
1633
1633
1634 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1634 $ hg debugrevspec -s 'last(4:0, 3) & :1'
1635 * set:
1635 * set:
1636 <filteredset
1636 <filteredset
1637 <spanset- 0:3>,
1637 <spanset- 0:3>,
1638 <spanset+ 0:2>>
1638 <spanset+ 0:2>>
1639 1
1639 1
1640 0
1640 0
1641
1641
1642 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1642 $ hg debugrevspec -s ':1 & last(4:0, 3)'
1643 * set:
1643 * set:
1644 <filteredset
1644 <filteredset
1645 <spanset+ 0:2>,
1645 <spanset+ 0:2>,
1646 <spanset+ 0:3>>
1646 <spanset+ 0:3>>
1647 0
1647 0
1648 1
1648 1
1649
1649
1650 Test scmutil.revsingle() should return the last revision
1650 Test scmutil.revsingle() should return the last revision
1651
1651
1652 $ hg debugrevspec -s 'last(0::)'
1652 $ hg debugrevspec -s 'last(0::)'
1653 * set:
1653 * set:
1654 <baseset slice=0:1
1654 <baseset slice=0:1
1655 <generatorsetasc->>
1655 <generatorsetasc->>
1656 9
1656 9
1657 $ hg identify -r '0::' --num
1657 $ hg identify -r '0::' --num
1658 9
1658 9
1659
1659
1660 Test matching
1660 Test matching
1661
1661
1662 $ log 'matching(6)'
1662 $ log 'matching(6)'
1663 6
1663 6
1664 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1664 $ log 'matching(6:7, "phase parents user date branch summary files description substate")'
1665 6
1665 6
1666 7
1666 7
1667
1667
1668 Testing min and max
1668 Testing min and max
1669
1669
1670 max: simple
1670 max: simple
1671
1671
1672 $ log 'max(contains(a))'
1672 $ log 'max(contains(a))'
1673 5
1673 5
1674
1674
1675 max: simple on unordered set)
1675 max: simple on unordered set)
1676
1676
1677 $ log 'max((4+0+2+5+7) and contains(a))'
1677 $ log 'max((4+0+2+5+7) and contains(a))'
1678 5
1678 5
1679
1679
1680 max: no result
1680 max: no result
1681
1681
1682 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1682 $ log 'max(contains(stringthatdoesnotappearanywhere))'
1683
1683
1684 max: no result on unordered set
1684 max: no result on unordered set
1685
1685
1686 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1686 $ log 'max((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1687
1687
1688 min: simple
1688 min: simple
1689
1689
1690 $ log 'min(contains(a))'
1690 $ log 'min(contains(a))'
1691 0
1691 0
1692
1692
1693 min: simple on unordered set
1693 min: simple on unordered set
1694
1694
1695 $ log 'min((4+0+2+5+7) and contains(a))'
1695 $ log 'min((4+0+2+5+7) and contains(a))'
1696 0
1696 0
1697
1697
1698 min: empty
1698 min: empty
1699
1699
1700 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1700 $ log 'min(contains(stringthatdoesnotappearanywhere))'
1701
1701
1702 min: empty on unordered set
1702 min: empty on unordered set
1703
1703
1704 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1704 $ log 'min((4+0+2+5+7) and contains(stringthatdoesnotappearanywhere))'
1705
1705
1706
1706
1707 $ log 'merge()'
1707 $ log 'merge()'
1708 6
1708 6
1709 $ log 'branchpoint()'
1709 $ log 'branchpoint()'
1710 1
1710 1
1711 4
1711 4
1712 $ log 'modifies(b)'
1712 $ log 'modifies(b)'
1713 4
1713 4
1714 $ log 'modifies("path:b")'
1714 $ log 'modifies("path:b")'
1715 4
1715 4
1716 $ log 'modifies("*")'
1716 $ log 'modifies("*")'
1717 4
1717 4
1718 6
1718 6
1719 $ log 'modifies("set:modified()")'
1719 $ log 'modifies("set:modified()")'
1720 4
1720 4
1721 $ log 'id(5)'
1721 $ log 'id(5)'
1722 2
1722 2
1723 $ log 'only(9)'
1723 $ log 'only(9)'
1724 8
1724 8
1725 9
1725 9
1726 $ log 'only(8)'
1726 $ log 'only(8)'
1727 8
1727 8
1728 $ log 'only(9, 5)'
1728 $ log 'only(9, 5)'
1729 2
1729 2
1730 4
1730 4
1731 8
1731 8
1732 9
1732 9
1733 $ log 'only(7 + 9, 5 + 2)'
1733 $ log 'only(7 + 9, 5 + 2)'
1734 4
1734 4
1735 6
1735 6
1736 7
1736 7
1737 8
1737 8
1738 9
1738 9
1739
1739
1740 Test empty set input
1740 Test empty set input
1741 $ log 'only(p2())'
1741 $ log 'only(p2())'
1742 $ log 'only(p1(), p2())'
1742 $ log 'only(p1(), p2())'
1743 0
1743 0
1744 1
1744 1
1745 2
1745 2
1746 4
1746 4
1747 8
1747 8
1748 9
1748 9
1749
1749
1750 Test '%' operator
1750 Test '%' operator
1751
1751
1752 $ log '9%'
1752 $ log '9%'
1753 8
1753 8
1754 9
1754 9
1755 $ log '9%5'
1755 $ log '9%5'
1756 2
1756 2
1757 4
1757 4
1758 8
1758 8
1759 9
1759 9
1760 $ log '(7 + 9)%(5 + 2)'
1760 $ log '(7 + 9)%(5 + 2)'
1761 4
1761 4
1762 6
1762 6
1763 7
1763 7
1764 8
1764 8
1765 9
1765 9
1766
1766
1767 Test operand of '%' is optimized recursively (issue4670)
1767 Test operand of '%' is optimized recursively (issue4670)
1768
1768
1769 $ try --optimize '8:9-8%'
1769 $ try --optimize '8:9-8%'
1770 (onlypost
1770 (onlypost
1771 (minus
1771 (minus
1772 (range
1772 (range
1773 (symbol '8')
1773 (symbol '8')
1774 (symbol '9'))
1774 (symbol '9'))
1775 (symbol '8')))
1775 (symbol '8')))
1776 * optimized:
1776 * optimized:
1777 (func
1777 (func
1778 (symbol 'only')
1778 (symbol 'only')
1779 (difference
1779 (difference
1780 (range
1780 (range
1781 (symbol '8')
1781 (symbol '8')
1782 (symbol '9'))
1782 (symbol '9'))
1783 (symbol '8')))
1783 (symbol '8')))
1784 * set:
1784 * set:
1785 <baseset+ [8, 9]>
1785 <baseset+ [8, 9]>
1786 8
1786 8
1787 9
1787 9
1788 $ try --optimize '(9)%(5)'
1788 $ try --optimize '(9)%(5)'
1789 (only
1789 (only
1790 (group
1790 (group
1791 (symbol '9'))
1791 (symbol '9'))
1792 (group
1792 (group
1793 (symbol '5')))
1793 (symbol '5')))
1794 * optimized:
1794 * optimized:
1795 (func
1795 (func
1796 (symbol 'only')
1796 (symbol 'only')
1797 (list
1797 (list
1798 (symbol '9')
1798 (symbol '9')
1799 (symbol '5')))
1799 (symbol '5')))
1800 * set:
1800 * set:
1801 <baseset+ [2, 4, 8, 9]>
1801 <baseset+ [2, 4, 8, 9]>
1802 2
1802 2
1803 4
1803 4
1804 8
1804 8
1805 9
1805 9
1806
1806
1807 Test the order of operations
1807 Test the order of operations
1808
1808
1809 $ log '7 + 9%5 + 2'
1809 $ log '7 + 9%5 + 2'
1810 7
1810 7
1811 2
1811 2
1812 4
1812 4
1813 8
1813 8
1814 9
1814 9
1815
1815
1816 Test explicit numeric revision
1816 Test explicit numeric revision
1817 $ log 'rev(-2)'
1817 $ log 'rev(-2)'
1818 $ log 'rev(-1)'
1818 $ log 'rev(-1)'
1819 -1
1819 -1
1820 $ log 'rev(0)'
1820 $ log 'rev(0)'
1821 0
1821 0
1822 $ log 'rev(9)'
1822 $ log 'rev(9)'
1823 9
1823 9
1824 $ log 'rev(10)'
1824 $ log 'rev(10)'
1825 $ log 'rev(tip)'
1825 $ log 'rev(tip)'
1826 hg: parse error: rev expects a number
1826 hg: parse error: rev expects a number
1827 [255]
1827 [255]
1828
1828
1829 Test hexadecimal revision
1829 Test hexadecimal revision
1830 $ log 'id(2)'
1830 $ log 'id(2)'
1831 $ log 'id(5)'
1831 $ log 'id(5)'
1832 2
1832 2
1833 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x5)'
1833 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x5)'
1834 2
1834 2
1835 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x5'
1835 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x5'
1836 2
1836 2
1837 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x)'
1837 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'id(x)'
1838 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x'
1838 $ hg --config experimental.revisions.prefixhexnode=yes log --template '{rev}\n' -r 'x'
1839 abort: 00changelog.i@: ambiguous identifier!
1839 abort: 00changelog.i@: ambiguous identifier!
1840 [255]
1840 [255]
1841 $ log 'id(23268)'
1841 $ log 'id(23268)'
1842 4
1842 4
1843 $ log 'id(2785f51eece)'
1843 $ log 'id(2785f51eece)'
1844 0
1844 0
1845 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1845 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532c)'
1846 8
1846 8
1847 $ log 'id(d5d0dcbdc4a)'
1847 $ log 'id(d5d0dcbdc4a)'
1848 $ log 'id(d5d0dcbdc4w)'
1848 $ log 'id(d5d0dcbdc4w)'
1849 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1849 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532d)'
1850 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1850 $ log 'id(d5d0dcbdc4d9ff5dbb2d336f32f0bb561c1a532q)'
1851 $ log 'id(1.0)'
1851 $ log 'id(1.0)'
1852 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1852 $ log 'id(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)'
1853
1853
1854 Test null revision
1854 Test null revision
1855 $ log '(null)'
1855 $ log '(null)'
1856 -1
1856 -1
1857 $ log '(null:0)'
1857 $ log '(null:0)'
1858 -1
1858 -1
1859 0
1859 0
1860 $ log '(0:null)'
1860 $ log '(0:null)'
1861 0
1861 0
1862 -1
1862 -1
1863 $ log 'null::0'
1863 $ log 'null::0'
1864 -1
1864 -1
1865 0
1865 0
1866 $ log 'null:tip - 0:'
1866 $ log 'null:tip - 0:'
1867 -1
1867 -1
1868 $ log 'null: and null::' | head -1
1868 $ log 'null: and null::' | head -1
1869 -1
1869 -1
1870 $ log 'null: or 0:' | head -2
1870 $ log 'null: or 0:' | head -2
1871 -1
1871 -1
1872 0
1872 0
1873 $ log 'ancestors(null)'
1873 $ log 'ancestors(null)'
1874 -1
1874 -1
1875 $ log 'reverse(null:)' | tail -2
1875 $ log 'reverse(null:)' | tail -2
1876 0
1876 0
1877 -1
1877 -1
1878 $ log 'first(null:)'
1878 $ log 'first(null:)'
1879 -1
1879 -1
1880 $ log 'min(null:)'
1880 $ log 'min(null:)'
1881 BROKEN: should be '-1'
1881 BROKEN: should be '-1'
1882 $ log 'tip:null and all()' | tail -2
1882 $ log 'tip:null and all()' | tail -2
1883 1
1883 1
1884 0
1884 0
1885
1885
1886 Test working-directory revision
1886 Test working-directory revision
1887 $ hg debugrevspec 'wdir()'
1887 $ hg debugrevspec 'wdir()'
1888 2147483647
1888 2147483647
1889 $ hg debugrevspec 'wdir()^'
1889 $ hg debugrevspec 'wdir()^'
1890 9
1890 9
1891 $ hg up 7
1891 $ hg up 7
1892 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1892 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1893 $ hg debugrevspec 'wdir()^'
1893 $ hg debugrevspec 'wdir()^'
1894 7
1894 7
1895 $ hg debugrevspec 'wdir()^0'
1895 $ hg debugrevspec 'wdir()^0'
1896 2147483647
1896 2147483647
1897 $ hg debugrevspec 'wdir()~3'
1897 $ hg debugrevspec 'wdir()~3'
1898 5
1898 5
1899 $ hg debugrevspec 'ancestors(wdir())'
1899 $ hg debugrevspec 'ancestors(wdir())'
1900 0
1900 0
1901 1
1901 1
1902 2
1902 2
1903 3
1903 3
1904 4
1904 4
1905 5
1905 5
1906 6
1906 6
1907 7
1907 7
1908 2147483647
1908 2147483647
1909 $ hg debugrevspec '0:wdir() & ancestor(wdir())'
1909 $ hg debugrevspec '0:wdir() & ancestor(wdir())'
1910 2147483647
1910 2147483647
1911 $ hg debugrevspec '0:wdir() & ancestor(.:wdir())'
1911 $ hg debugrevspec '0:wdir() & ancestor(.:wdir())'
1912 4
1912 4
1913 $ hg debugrevspec '0:wdir() & ancestor(wdir(), wdir())'
1913 $ hg debugrevspec '0:wdir() & ancestor(wdir(), wdir())'
1914 2147483647
1914 2147483647
1915 $ hg debugrevspec '0:wdir() & ancestor(wdir(), tip)'
1915 $ hg debugrevspec '0:wdir() & ancestor(wdir(), tip)'
1916 4
1916 4
1917 $ hg debugrevspec 'null:wdir() & ancestor(wdir(), null)'
1917 $ hg debugrevspec 'null:wdir() & ancestor(wdir(), null)'
1918 -1
1918 -1
1919 $ hg debugrevspec 'wdir()~0'
1919 $ hg debugrevspec 'wdir()~0'
1920 2147483647
1920 2147483647
1921 $ hg debugrevspec 'p1(wdir())'
1921 $ hg debugrevspec 'p1(wdir())'
1922 7
1922 7
1923 $ hg debugrevspec 'p2(wdir())'
1923 $ hg debugrevspec 'p2(wdir())'
1924 $ hg debugrevspec 'parents(wdir())'
1924 $ hg debugrevspec 'parents(wdir())'
1925 7
1925 7
1926 $ hg debugrevspec 'wdir()^1'
1926 $ hg debugrevspec 'wdir()^1'
1927 7
1927 7
1928 $ hg debugrevspec 'wdir()^2'
1928 $ hg debugrevspec 'wdir()^2'
1929 $ hg debugrevspec 'wdir()^3'
1929 $ hg debugrevspec 'wdir()^3'
1930 hg: parse error: ^ expects a number 0, 1, or 2
1930 hg: parse error: ^ expects a number 0, 1, or 2
1931 [255]
1931 [255]
1932 For tests consistency
1932 For tests consistency
1933 $ hg up 9
1933 $ hg up 9
1934 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1934 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1935 $ hg debugrevspec 'tip or wdir()'
1935 $ hg debugrevspec 'tip or wdir()'
1936 9
1936 9
1937 2147483647
1937 2147483647
1938 $ hg debugrevspec '0:tip and wdir()'
1938 $ hg debugrevspec '0:tip and wdir()'
1939 $ log '0:wdir()' | tail -3
1939 $ log '0:wdir()' | tail -3
1940 8
1940 8
1941 9
1941 9
1942 2147483647
1942 2147483647
1943 $ log 'wdir():0' | head -3
1943 $ log 'wdir():0' | head -3
1944 2147483647
1944 2147483647
1945 9
1945 9
1946 8
1946 8
1947 $ log 'wdir():wdir()'
1947 $ log 'wdir():wdir()'
1948 2147483647
1948 2147483647
1949 $ log '(all() + wdir()) & min(. + wdir())'
1949 $ log '(all() + wdir()) & min(. + wdir())'
1950 9
1950 9
1951 $ log '(all() + wdir()) & max(. + wdir())'
1951 $ log '(all() + wdir()) & max(. + wdir())'
1952 2147483647
1952 2147483647
1953 $ log 'first(wdir() + .)'
1953 $ log 'first(wdir() + .)'
1954 2147483647
1954 2147483647
1955 $ log 'last(. + wdir())'
1955 $ log 'last(. + wdir())'
1956 2147483647
1956 2147483647
1957
1957
1958 Test working-directory integer revision and node id
1958 Test working-directory integer revision and node id
1959 (BUG: '0:wdir()' is still needed to populate wdir revision)
1959 (BUG: '0:wdir()' is still needed to populate wdir revision)
1960
1960
1961 $ hg debugrevspec '0:wdir() & 2147483647'
1961 $ hg debugrevspec '0:wdir() & 2147483647'
1962 2147483647
1962 2147483647
1963 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1963 $ hg debugrevspec '0:wdir() & rev(2147483647)'
1964 2147483647
1964 2147483647
1965 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1965 $ hg debugrevspec '0:wdir() & ffffffffffffffffffffffffffffffffffffffff'
1966 2147483647
1966 2147483647
1967 $ hg debugrevspec '0:wdir() & ffffffffffff'
1967 $ hg debugrevspec '0:wdir() & ffffffffffff'
1968 2147483647
1968 2147483647
1969 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1969 $ hg debugrevspec '0:wdir() & id(ffffffffffffffffffffffffffffffffffffffff)'
1970 2147483647
1970 2147483647
1971 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1971 $ hg debugrevspec '0:wdir() & id(ffffffffffff)'
1972 2147483647
1972 2147483647
1973
1973
1974 $ cd ..
1974 $ cd ..
1975
1975
1976 Test short 'ff...' hash collision
1976 Test short 'ff...' hash collision
1977 (BUG: '0:wdir()' is still needed to populate wdir revision)
1977 (BUG: '0:wdir()' is still needed to populate wdir revision)
1978
1978
1979 $ hg init wdir-hashcollision
1979 $ hg init wdir-hashcollision
1980 $ cd wdir-hashcollision
1980 $ cd wdir-hashcollision
1981 $ cat <<EOF >> .hg/hgrc
1981 $ cat <<EOF >> .hg/hgrc
1982 > [experimental]
1982 > [experimental]
1983 > evolution.createmarkers=True
1983 > evolution.createmarkers=True
1984 > EOF
1984 > EOF
1985 $ echo 0 > a
1985 $ echo 0 > a
1986 $ hg ci -qAm 0
1986 $ hg ci -qAm 0
1987 $ for i in 2463 2961 6726 78127; do
1987 $ for i in 2463 2961 6726 78127; do
1988 > hg up -q 0
1988 > hg up -q 0
1989 > echo $i > a
1989 > echo $i > a
1990 > hg ci -qm $i
1990 > hg ci -qm $i
1991 > done
1991 > done
1992 $ hg up -q null
1992 $ hg up -q null
1993 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1993 $ hg log -r '0:wdir()' -T '{rev}:{node} {shortest(node, 3)}\n'
1994 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1994 0:b4e73ffab476aa0ee32ed81ca51e07169844bc6a b4e
1995 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1995 1:fffbae3886c8fbb2114296380d276fd37715d571 fffba
1996 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1996 2:fffb6093b00943f91034b9bdad069402c834e572 fffb6
1997 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1997 3:fff48a9b9de34a4d64120c29548214c67980ade3 fff4
1998 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1998 4:ffff85cff0ff78504fcdc3c0bc10de0c65379249 ffff8
1999 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
1999 2147483647:ffffffffffffffffffffffffffffffffffffffff fffff
2000 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
2000 $ hg debugobsolete fffbae3886c8fbb2114296380d276fd37715d571
2001 obsoleted 1 changesets
2001 obsoleted 1 changesets
2002
2002
2003 $ hg debugrevspec '0:wdir() & fff'
2003 $ hg debugrevspec '0:wdir() & fff'
2004 abort: 00changelog.i@fff: ambiguous identifier!
2004 abort: 00changelog.i@fff: ambiguous identifier!
2005 [255]
2005 [255]
2006 $ hg debugrevspec '0:wdir() & ffff'
2006 $ hg debugrevspec '0:wdir() & ffff'
2007 abort: 00changelog.i@ffff: ambiguous identifier!
2007 abort: 00changelog.i@ffff: ambiguous identifier!
2008 [255]
2008 [255]
2009 $ hg debugrevspec '0:wdir() & fffb'
2009 $ hg debugrevspec '0:wdir() & fffb'
2010 abort: 00changelog.i@fffb: ambiguous identifier!
2010 abort: 00changelog.i@fffb: ambiguous identifier!
2011 [255]
2011 [255]
2012 BROKEN should be '2' (node lookup uses unfiltered repo)
2012 BROKEN should be '2' (node lookup uses unfiltered repo)
2013 $ hg debugrevspec '0:wdir() & id(fffb)'
2013 $ hg debugrevspec '0:wdir() & id(fffb)'
2014 BROKEN should be '2' (node lookup uses unfiltered repo)
2014 BROKEN should be '2' (node lookup uses unfiltered repo)
2015 $ hg debugrevspec '0:wdir() & ffff8'
2015 $ hg debugrevspec '0:wdir() & ffff8'
2016 4
2016 4
2017 $ hg debugrevspec '0:wdir() & fffff'
2017 $ hg debugrevspec '0:wdir() & fffff'
2018 2147483647
2018 2147483647
2019
2019
2020 $ cd ..
2020 $ cd ..
2021
2021
2022 Test branch() with wdir()
2022 Test branch() with wdir()
2023
2023
2024 $ cd repo
2024 $ cd repo
2025
2025
2026 $ log '0:wdir() & branch("literal:Γ©")'
2026 $ log '0:wdir() & branch("literal:Γ©")'
2027 8
2027 8
2028 9
2028 9
2029 2147483647
2029 2147483647
2030 $ log '0:wdir() & branch("re:Γ©")'
2030 $ log '0:wdir() & branch("re:Γ©")'
2031 8
2031 8
2032 9
2032 9
2033 2147483647
2033 2147483647
2034 $ log '0:wdir() & branch("re:^a")'
2034 $ log '0:wdir() & branch("re:^a")'
2035 0
2035 0
2036 2
2036 2
2037 $ log '0:wdir() & branch(8)'
2037 $ log '0:wdir() & branch(8)'
2038 8
2038 8
2039 9
2039 9
2040 2147483647
2040 2147483647
2041
2041
2042 branch(wdir()) returns all revisions belonging to the working branch. The wdir
2042 branch(wdir()) returns all revisions belonging to the working branch. The wdir
2043 itself isn't returned unless it is explicitly populated.
2043 itself isn't returned unless it is explicitly populated.
2044
2044
2045 $ log 'branch(wdir())'
2045 $ log 'branch(wdir())'
2046 8
2046 8
2047 9
2047 9
2048 $ log '0:wdir() & branch(wdir())'
2048 $ log '0:wdir() & branch(wdir())'
2049 8
2049 8
2050 9
2050 9
2051 2147483647
2051 2147483647
2052
2052
2053 $ log 'outgoing()'
2053 $ log 'outgoing()'
2054 8
2054 8
2055 9
2055 9
2056 $ log 'outgoing("../remote1")'
2056 $ log 'outgoing("../remote1")'
2057 8
2057 8
2058 9
2058 9
2059 $ log 'outgoing("../remote2")'
2059 $ log 'outgoing("../remote2")'
2060 3
2060 3
2061 5
2061 5
2062 6
2062 6
2063 7
2063 7
2064 9
2064 9
2065 $ log 'p1(merge())'
2065 $ log 'p1(merge())'
2066 5
2066 5
2067 $ log 'p2(merge())'
2067 $ log 'p2(merge())'
2068 4
2068 4
2069 $ log 'parents(merge())'
2069 $ log 'parents(merge())'
2070 4
2070 4
2071 5
2071 5
2072 $ log 'p1(branchpoint())'
2072 $ log 'p1(branchpoint())'
2073 0
2073 0
2074 2
2074 2
2075 $ log 'p2(branchpoint())'
2075 $ log 'p2(branchpoint())'
2076 $ log 'parents(branchpoint())'
2076 $ log 'parents(branchpoint())'
2077 0
2077 0
2078 2
2078 2
2079 $ log 'removes(a)'
2079 $ log 'removes(a)'
2080 2
2080 2
2081 6
2081 6
2082 $ log 'roots(all())'
2082 $ log 'roots(all())'
2083 0
2083 0
2084 $ log 'reverse(2 or 3 or 4 or 5)'
2084 $ log 'reverse(2 or 3 or 4 or 5)'
2085 5
2085 5
2086 4
2086 4
2087 3
2087 3
2088 2
2088 2
2089 $ log 'reverse(all())'
2089 $ log 'reverse(all())'
2090 9
2090 9
2091 8
2091 8
2092 7
2092 7
2093 6
2093 6
2094 5
2094 5
2095 4
2095 4
2096 3
2096 3
2097 2
2097 2
2098 1
2098 1
2099 0
2099 0
2100 $ log 'reverse(all()) & filelog(b)'
2100 $ log 'reverse(all()) & filelog(b)'
2101 4
2101 4
2102 1
2102 1
2103 $ log 'rev(5)'
2103 $ log 'rev(5)'
2104 5
2104 5
2105 $ log 'sort(limit(reverse(all()), 3))'
2105 $ log 'sort(limit(reverse(all()), 3))'
2106 7
2106 7
2107 8
2107 8
2108 9
2108 9
2109 $ log 'sort(2 or 3 or 4 or 5, date)'
2109 $ log 'sort(2 or 3 or 4 or 5, date)'
2110 2
2110 2
2111 3
2111 3
2112 5
2112 5
2113 4
2113 4
2114 $ log 'tagged()'
2114 $ log 'tagged()'
2115 6
2115 6
2116 $ log 'tag()'
2116 $ log 'tag()'
2117 6
2117 6
2118 $ log 'tag(1.0)'
2118 $ log 'tag(1.0)'
2119 6
2119 6
2120 $ log 'tag(tip)'
2120 $ log 'tag(tip)'
2121 9
2121 9
2122
2122
2123 Test order of revisions in compound expression
2123 Test order of revisions in compound expression
2124 ----------------------------------------------
2124 ----------------------------------------------
2125
2125
2126 The general rule is that only the outermost (= leftmost) predicate can
2126 The general rule is that only the outermost (= leftmost) predicate can
2127 enforce its ordering requirement. The other predicates should take the
2127 enforce its ordering requirement. The other predicates should take the
2128 ordering defined by it.
2128 ordering defined by it.
2129
2129
2130 'A & B' should follow the order of 'A':
2130 'A & B' should follow the order of 'A':
2131
2131
2132 $ log '2:0 & 0::2'
2132 $ log '2:0 & 0::2'
2133 2
2133 2
2134 1
2134 1
2135 0
2135 0
2136
2136
2137 'head()' combines sets in right order:
2137 'head()' combines sets in right order:
2138
2138
2139 $ log '2:0 & head()'
2139 $ log '2:0 & head()'
2140 2
2140 2
2141 1
2141 1
2142 0
2142 0
2143
2143
2144 'x:y' takes ordering parameter into account:
2144 'x:y' takes ordering parameter into account:
2145
2145
2146 $ try -p optimized '3:0 & 0:3 & not 2:1'
2146 $ try -p optimized '3:0 & 0:3 & not 2:1'
2147 * optimized:
2147 * optimized:
2148 (difference
2148 (difference
2149 (and
2149 (and
2150 (range
2150 (range
2151 (symbol '3')
2151 (symbol '3')
2152 (symbol '0'))
2152 (symbol '0'))
2153 (range
2153 (range
2154 (symbol '0')
2154 (symbol '0')
2155 (symbol '3')))
2155 (symbol '3')))
2156 (range
2156 (range
2157 (symbol '2')
2157 (symbol '2')
2158 (symbol '1')))
2158 (symbol '1')))
2159 * set:
2159 * set:
2160 <filteredset
2160 <filteredset
2161 <filteredset
2161 <filteredset
2162 <spanset- 0:4>,
2162 <spanset- 0:4>,
2163 <spanset+ 0:4>>,
2163 <spanset+ 0:4>>,
2164 <not
2164 <not
2165 <spanset+ 1:3>>>
2165 <spanset+ 1:3>>>
2166 3
2166 3
2167 0
2167 0
2168
2168
2169 'a + b', which is optimized to '_list(a b)', should take the ordering of
2169 'a + b', which is optimized to '_list(a b)', should take the ordering of
2170 the left expression:
2170 the left expression:
2171
2171
2172 $ try --optimize '2:0 & (0 + 1 + 2)'
2172 $ try --optimize '2:0 & (0 + 1 + 2)'
2173 (and
2173 (and
2174 (range
2174 (range
2175 (symbol '2')
2175 (symbol '2')
2176 (symbol '0'))
2176 (symbol '0'))
2177 (group
2177 (group
2178 (or
2178 (or
2179 (list
2179 (list
2180 (symbol '0')
2180 (symbol '0')
2181 (symbol '1')
2181 (symbol '1')
2182 (symbol '2')))))
2182 (symbol '2')))))
2183 * optimized:
2183 * optimized:
2184 (and
2184 (and
2185 (range
2185 (range
2186 (symbol '2')
2186 (symbol '2')
2187 (symbol '0'))
2187 (symbol '0'))
2188 (func
2188 (func
2189 (symbol '_list')
2189 (symbol '_list')
2190 (string '0\x001\x002')))
2190 (string '0\x001\x002')))
2191 * set:
2191 * set:
2192 <filteredset
2192 <filteredset
2193 <spanset- 0:3>,
2193 <spanset- 0:3>,
2194 <baseset [0, 1, 2]>>
2194 <baseset [0, 1, 2]>>
2195 2
2195 2
2196 1
2196 1
2197 0
2197 0
2198
2198
2199 'A + B' should take the ordering of the left expression:
2199 'A + B' should take the ordering of the left expression:
2200
2200
2201 $ try --optimize '2:0 & (0:1 + 2)'
2201 $ try --optimize '2:0 & (0:1 + 2)'
2202 (and
2202 (and
2203 (range
2203 (range
2204 (symbol '2')
2204 (symbol '2')
2205 (symbol '0'))
2205 (symbol '0'))
2206 (group
2206 (group
2207 (or
2207 (or
2208 (list
2208 (list
2209 (range
2209 (range
2210 (symbol '0')
2210 (symbol '0')
2211 (symbol '1'))
2211 (symbol '1'))
2212 (symbol '2')))))
2212 (symbol '2')))))
2213 * optimized:
2213 * optimized:
2214 (and
2214 (and
2215 (range
2215 (range
2216 (symbol '2')
2216 (symbol '2')
2217 (symbol '0'))
2217 (symbol '0'))
2218 (or
2218 (or
2219 (list
2219 (list
2220 (range
2220 (range
2221 (symbol '0')
2221 (symbol '0')
2222 (symbol '1'))
2222 (symbol '1'))
2223 (symbol '2'))))
2223 (symbol '2'))))
2224 * set:
2224 * set:
2225 <filteredset
2225 <filteredset
2226 <spanset- 0:3>,
2226 <spanset- 0:3>,
2227 <addset
2227 <addset
2228 <spanset+ 0:2>,
2228 <spanset+ 0:2>,
2229 <baseset [2]>>>
2229 <baseset [2]>>>
2230 2
2230 2
2231 1
2231 1
2232 0
2232 0
2233
2233
2234 '_intlist(a b)' should behave like 'a + b':
2234 '_intlist(a b)' should behave like 'a + b':
2235
2235
2236 $ trylist --optimize '2:0 & %ld' 0 1 2
2236 $ trylist --optimize '2:0 & %ld' 0 1 2
2237 (and
2237 (and
2238 (range
2238 (range
2239 (symbol '2')
2239 (symbol '2')
2240 (symbol '0'))
2240 (symbol '0'))
2241 (func
2241 (func
2242 (symbol '_intlist')
2242 (symbol '_intlist')
2243 (string '0\x001\x002')))
2243 (string '0\x001\x002')))
2244 * optimized:
2244 * optimized:
2245 (andsmally
2245 (andsmally
2246 (range
2246 (range
2247 (symbol '2')
2247 (symbol '2')
2248 (symbol '0'))
2248 (symbol '0'))
2249 (func
2249 (func
2250 (symbol '_intlist')
2250 (symbol '_intlist')
2251 (string '0\x001\x002')))
2251 (string '0\x001\x002')))
2252 * set:
2252 * set:
2253 <filteredset
2253 <filteredset
2254 <spanset- 0:3>,
2254 <spanset- 0:3>,
2255 <baseset+ [0, 1, 2]>>
2255 <baseset+ [0, 1, 2]>>
2256 2
2256 2
2257 1
2257 1
2258 0
2258 0
2259
2259
2260 $ trylist --optimize '%ld & 2:0' 0 2 1
2260 $ trylist --optimize '%ld & 2:0' 0 2 1
2261 (and
2261 (and
2262 (func
2262 (func
2263 (symbol '_intlist')
2263 (symbol '_intlist')
2264 (string '0\x002\x001'))
2264 (string '0\x002\x001'))
2265 (range
2265 (range
2266 (symbol '2')
2266 (symbol '2')
2267 (symbol '0')))
2267 (symbol '0')))
2268 * optimized:
2268 * optimized:
2269 (and
2269 (and
2270 (func
2270 (func
2271 (symbol '_intlist')
2271 (symbol '_intlist')
2272 (string '0\x002\x001'))
2272 (string '0\x002\x001'))
2273 (range
2273 (range
2274 (symbol '2')
2274 (symbol '2')
2275 (symbol '0')))
2275 (symbol '0')))
2276 * set:
2276 * set:
2277 <filteredset
2277 <filteredset
2278 <baseset [0, 2, 1]>,
2278 <baseset [0, 2, 1]>,
2279 <spanset- 0:3>>
2279 <spanset- 0:3>>
2280 0
2280 0
2281 2
2281 2
2282 1
2282 1
2283
2283
2284 '_hexlist(a b)' should behave like 'a + b':
2284 '_hexlist(a b)' should behave like 'a + b':
2285
2285
2286 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2286 $ trylist --optimize --bin '2:0 & %ln' `hg log -T '{node} ' -r0:2`
2287 (and
2287 (and
2288 (range
2288 (range
2289 (symbol '2')
2289 (symbol '2')
2290 (symbol '0'))
2290 (symbol '0'))
2291 (func
2291 (func
2292 (symbol '_hexlist')
2292 (symbol '_hexlist')
2293 (string '*'))) (glob)
2293 (string '*'))) (glob)
2294 * optimized:
2294 * optimized:
2295 (and
2295 (and
2296 (range
2296 (range
2297 (symbol '2')
2297 (symbol '2')
2298 (symbol '0'))
2298 (symbol '0'))
2299 (func
2299 (func
2300 (symbol '_hexlist')
2300 (symbol '_hexlist')
2301 (string '*'))) (glob)
2301 (string '*'))) (glob)
2302 * set:
2302 * set:
2303 <filteredset
2303 <filteredset
2304 <spanset- 0:3>,
2304 <spanset- 0:3>,
2305 <baseset [0, 1, 2]>>
2305 <baseset [0, 1, 2]>>
2306 2
2306 2
2307 1
2307 1
2308 0
2308 0
2309
2309
2310 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2310 $ trylist --optimize --bin '%ln & 2:0' `hg log -T '{node} ' -r0+2+1`
2311 (and
2311 (and
2312 (func
2312 (func
2313 (symbol '_hexlist')
2313 (symbol '_hexlist')
2314 (string '*')) (glob)
2314 (string '*')) (glob)
2315 (range
2315 (range
2316 (symbol '2')
2316 (symbol '2')
2317 (symbol '0')))
2317 (symbol '0')))
2318 * optimized:
2318 * optimized:
2319 (andsmally
2319 (andsmally
2320 (func
2320 (func
2321 (symbol '_hexlist')
2321 (symbol '_hexlist')
2322 (string '*')) (glob)
2322 (string '*')) (glob)
2323 (range
2323 (range
2324 (symbol '2')
2324 (symbol '2')
2325 (symbol '0')))
2325 (symbol '0')))
2326 * set:
2326 * set:
2327 <baseset [0, 2, 1]>
2327 <baseset [0, 2, 1]>
2328 0
2328 0
2329 2
2329 2
2330 1
2330 1
2331
2331
2332 '_list' should not go through the slow follow-order path if order doesn't
2332 '_list' should not go through the slow follow-order path if order doesn't
2333 matter:
2333 matter:
2334
2334
2335 $ try -p optimized '2:0 & not (0 + 1)'
2335 $ try -p optimized '2:0 & not (0 + 1)'
2336 * optimized:
2336 * optimized:
2337 (difference
2337 (difference
2338 (range
2338 (range
2339 (symbol '2')
2339 (symbol '2')
2340 (symbol '0'))
2340 (symbol '0'))
2341 (func
2341 (func
2342 (symbol '_list')
2342 (symbol '_list')
2343 (string '0\x001')))
2343 (string '0\x001')))
2344 * set:
2344 * set:
2345 <filteredset
2345 <filteredset
2346 <spanset- 0:3>,
2346 <spanset- 0:3>,
2347 <not
2347 <not
2348 <baseset [0, 1]>>>
2348 <baseset [0, 1]>>>
2349 2
2349 2
2350
2350
2351 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2351 $ try -p optimized '2:0 & not (0:2 & (0 + 1))'
2352 * optimized:
2352 * optimized:
2353 (difference
2353 (difference
2354 (range
2354 (range
2355 (symbol '2')
2355 (symbol '2')
2356 (symbol '0'))
2356 (symbol '0'))
2357 (and
2357 (and
2358 (range
2358 (range
2359 (symbol '0')
2359 (symbol '0')
2360 (symbol '2'))
2360 (symbol '2'))
2361 (func
2361 (func
2362 (symbol '_list')
2362 (symbol '_list')
2363 (string '0\x001'))))
2363 (string '0\x001'))))
2364 * set:
2364 * set:
2365 <filteredset
2365 <filteredset
2366 <spanset- 0:3>,
2366 <spanset- 0:3>,
2367 <not
2367 <not
2368 <baseset [0, 1]>>>
2368 <baseset [0, 1]>>>
2369 2
2369 2
2370
2370
2371 because 'present()' does nothing other than suppressing an error, the
2371 because 'present()' does nothing other than suppressing an error, the
2372 ordering requirement should be forwarded to the nested expression
2372 ordering requirement should be forwarded to the nested expression
2373
2373
2374 $ try -p optimized 'present(2 + 0 + 1)'
2374 $ try -p optimized 'present(2 + 0 + 1)'
2375 * optimized:
2375 * optimized:
2376 (func
2376 (func
2377 (symbol 'present')
2377 (symbol 'present')
2378 (func
2378 (func
2379 (symbol '_list')
2379 (symbol '_list')
2380 (string '2\x000\x001')))
2380 (string '2\x000\x001')))
2381 * set:
2381 * set:
2382 <baseset [2, 0, 1]>
2382 <baseset [2, 0, 1]>
2383 2
2383 2
2384 0
2384 0
2385 1
2385 1
2386
2386
2387 $ try --optimize '2:0 & present(0 + 1 + 2)'
2387 $ try --optimize '2:0 & present(0 + 1 + 2)'
2388 (and
2388 (and
2389 (range
2389 (range
2390 (symbol '2')
2390 (symbol '2')
2391 (symbol '0'))
2391 (symbol '0'))
2392 (func
2392 (func
2393 (symbol 'present')
2393 (symbol 'present')
2394 (or
2394 (or
2395 (list
2395 (list
2396 (symbol '0')
2396 (symbol '0')
2397 (symbol '1')
2397 (symbol '1')
2398 (symbol '2')))))
2398 (symbol '2')))))
2399 * optimized:
2399 * optimized:
2400 (and
2400 (and
2401 (range
2401 (range
2402 (symbol '2')
2402 (symbol '2')
2403 (symbol '0'))
2403 (symbol '0'))
2404 (func
2404 (func
2405 (symbol 'present')
2405 (symbol 'present')
2406 (func
2406 (func
2407 (symbol '_list')
2407 (symbol '_list')
2408 (string '0\x001\x002'))))
2408 (string '0\x001\x002'))))
2409 * set:
2409 * set:
2410 <filteredset
2410 <filteredset
2411 <spanset- 0:3>,
2411 <spanset- 0:3>,
2412 <baseset [0, 1, 2]>>
2412 <baseset [0, 1, 2]>>
2413 2
2413 2
2414 1
2414 1
2415 0
2415 0
2416
2416
2417 'reverse()' should take effect only if it is the outermost expression:
2417 'reverse()' should take effect only if it is the outermost expression:
2418
2418
2419 $ try --optimize '0:2 & reverse(all())'
2419 $ try --optimize '0:2 & reverse(all())'
2420 (and
2420 (and
2421 (range
2421 (range
2422 (symbol '0')
2422 (symbol '0')
2423 (symbol '2'))
2423 (symbol '2'))
2424 (func
2424 (func
2425 (symbol 'reverse')
2425 (symbol 'reverse')
2426 (func
2426 (func
2427 (symbol 'all')
2427 (symbol 'all')
2428 None)))
2428 None)))
2429 * optimized:
2429 * optimized:
2430 (and
2430 (and
2431 (range
2431 (range
2432 (symbol '0')
2432 (symbol '0')
2433 (symbol '2'))
2433 (symbol '2'))
2434 (func
2434 (func
2435 (symbol 'reverse')
2435 (symbol 'reverse')
2436 (func
2436 (func
2437 (symbol 'all')
2437 (symbol 'all')
2438 None)))
2438 None)))
2439 * set:
2439 * set:
2440 <filteredset
2440 <filteredset
2441 <spanset+ 0:3>,
2441 <spanset+ 0:3>,
2442 <spanset+ 0:10>>
2442 <spanset+ 0:10>>
2443 0
2443 0
2444 1
2444 1
2445 2
2445 2
2446
2446
2447 'sort()' should take effect only if it is the outermost expression:
2447 'sort()' should take effect only if it is the outermost expression:
2448
2448
2449 $ try --optimize '0:2 & sort(all(), -rev)'
2449 $ try --optimize '0:2 & sort(all(), -rev)'
2450 (and
2450 (and
2451 (range
2451 (range
2452 (symbol '0')
2452 (symbol '0')
2453 (symbol '2'))
2453 (symbol '2'))
2454 (func
2454 (func
2455 (symbol 'sort')
2455 (symbol 'sort')
2456 (list
2456 (list
2457 (func
2457 (func
2458 (symbol 'all')
2458 (symbol 'all')
2459 None)
2459 None)
2460 (negate
2460 (negate
2461 (symbol 'rev')))))
2461 (symbol 'rev')))))
2462 * optimized:
2462 * optimized:
2463 (and
2463 (and
2464 (range
2464 (range
2465 (symbol '0')
2465 (symbol '0')
2466 (symbol '2'))
2466 (symbol '2'))
2467 (func
2467 (func
2468 (symbol 'sort')
2468 (symbol 'sort')
2469 (list
2469 (list
2470 (func
2470 (func
2471 (symbol 'all')
2471 (symbol 'all')
2472 None)
2472 None)
2473 (string '-rev'))))
2473 (string '-rev'))))
2474 * set:
2474 * set:
2475 <filteredset
2475 <filteredset
2476 <spanset+ 0:3>,
2476 <spanset+ 0:3>,
2477 <spanset+ 0:10>>
2477 <spanset+ 0:10>>
2478 0
2478 0
2479 1
2479 1
2480 2
2480 2
2481
2481
2482 invalid argument passed to noop sort():
2482 invalid argument passed to noop sort():
2483
2483
2484 $ log '0:2 & sort()'
2484 $ log '0:2 & sort()'
2485 hg: parse error: sort requires one or two arguments
2485 hg: parse error: sort requires one or two arguments
2486 [255]
2486 [255]
2487 $ log '0:2 & sort(all(), -invalid)'
2487 $ log '0:2 & sort(all(), -invalid)'
2488 hg: parse error: unknown sort key '-invalid'
2488 hg: parse error: unknown sort key '-invalid'
2489 [255]
2489 [255]
2490
2490
2491 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2491 for 'A & f(B)', 'B' should not be affected by the order of 'A':
2492
2492
2493 $ try --optimize '2:0 & first(1 + 0 + 2)'
2493 $ try --optimize '2:0 & first(1 + 0 + 2)'
2494 (and
2494 (and
2495 (range
2495 (range
2496 (symbol '2')
2496 (symbol '2')
2497 (symbol '0'))
2497 (symbol '0'))
2498 (func
2498 (func
2499 (symbol 'first')
2499 (symbol 'first')
2500 (or
2500 (or
2501 (list
2501 (list
2502 (symbol '1')
2502 (symbol '1')
2503 (symbol '0')
2503 (symbol '0')
2504 (symbol '2')))))
2504 (symbol '2')))))
2505 * optimized:
2505 * optimized:
2506 (and
2506 (and
2507 (range
2507 (range
2508 (symbol '2')
2508 (symbol '2')
2509 (symbol '0'))
2509 (symbol '0'))
2510 (func
2510 (func
2511 (symbol 'first')
2511 (symbol 'first')
2512 (func
2512 (func
2513 (symbol '_list')
2513 (symbol '_list')
2514 (string '1\x000\x002'))))
2514 (string '1\x000\x002'))))
2515 * set:
2515 * set:
2516 <filteredset
2516 <filteredset
2517 <baseset [1]>,
2517 <baseset [1]>,
2518 <spanset- 0:3>>
2518 <spanset- 0:3>>
2519 1
2519 1
2520
2520
2521 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2521 $ try --optimize '2:0 & not last(0 + 2 + 1)'
2522 (and
2522 (and
2523 (range
2523 (range
2524 (symbol '2')
2524 (symbol '2')
2525 (symbol '0'))
2525 (symbol '0'))
2526 (not
2526 (not
2527 (func
2527 (func
2528 (symbol 'last')
2528 (symbol 'last')
2529 (or
2529 (or
2530 (list
2530 (list
2531 (symbol '0')
2531 (symbol '0')
2532 (symbol '2')
2532 (symbol '2')
2533 (symbol '1'))))))
2533 (symbol '1'))))))
2534 * optimized:
2534 * optimized:
2535 (difference
2535 (difference
2536 (range
2536 (range
2537 (symbol '2')
2537 (symbol '2')
2538 (symbol '0'))
2538 (symbol '0'))
2539 (func
2539 (func
2540 (symbol 'last')
2540 (symbol 'last')
2541 (func
2541 (func
2542 (symbol '_list')
2542 (symbol '_list')
2543 (string '0\x002\x001'))))
2543 (string '0\x002\x001'))))
2544 * set:
2544 * set:
2545 <filteredset
2545 <filteredset
2546 <spanset- 0:3>,
2546 <spanset- 0:3>,
2547 <not
2547 <not
2548 <baseset [1]>>>
2548 <baseset [1]>>>
2549 2
2549 2
2550 0
2550 0
2551
2551
2552 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2552 for 'A & (op)(B)', 'B' should not be affected by the order of 'A':
2553
2553
2554 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2554 $ try --optimize '2:0 & (1 + 0 + 2):(0 + 2 + 1)'
2555 (and
2555 (and
2556 (range
2556 (range
2557 (symbol '2')
2557 (symbol '2')
2558 (symbol '0'))
2558 (symbol '0'))
2559 (range
2559 (range
2560 (group
2560 (group
2561 (or
2561 (or
2562 (list
2562 (list
2563 (symbol '1')
2563 (symbol '1')
2564 (symbol '0')
2564 (symbol '0')
2565 (symbol '2'))))
2565 (symbol '2'))))
2566 (group
2566 (group
2567 (or
2567 (or
2568 (list
2568 (list
2569 (symbol '0')
2569 (symbol '0')
2570 (symbol '2')
2570 (symbol '2')
2571 (symbol '1'))))))
2571 (symbol '1'))))))
2572 * optimized:
2572 * optimized:
2573 (and
2573 (and
2574 (range
2574 (range
2575 (symbol '2')
2575 (symbol '2')
2576 (symbol '0'))
2576 (symbol '0'))
2577 (range
2577 (range
2578 (func
2578 (func
2579 (symbol '_list')
2579 (symbol '_list')
2580 (string '1\x000\x002'))
2580 (string '1\x000\x002'))
2581 (func
2581 (func
2582 (symbol '_list')
2582 (symbol '_list')
2583 (string '0\x002\x001'))))
2583 (string '0\x002\x001'))))
2584 * set:
2584 * set:
2585 <filteredset
2585 <filteredset
2586 <spanset- 0:3>,
2586 <spanset- 0:3>,
2587 <baseset [1]>>
2587 <baseset [1]>>
2588 1
2588 1
2589
2589
2590 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2590 'A & B' can be rewritten as 'flipand(B, A)' by weight.
2591
2591
2592 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2592 $ try --optimize 'contains("glob:*") & (2 + 0 + 1)'
2593 (and
2593 (and
2594 (func
2594 (func
2595 (symbol 'contains')
2595 (symbol 'contains')
2596 (string 'glob:*'))
2596 (string 'glob:*'))
2597 (group
2597 (group
2598 (or
2598 (or
2599 (list
2599 (list
2600 (symbol '2')
2600 (symbol '2')
2601 (symbol '0')
2601 (symbol '0')
2602 (symbol '1')))))
2602 (symbol '1')))))
2603 * optimized:
2603 * optimized:
2604 (andsmally
2604 (andsmally
2605 (func
2605 (func
2606 (symbol 'contains')
2606 (symbol 'contains')
2607 (string 'glob:*'))
2607 (string 'glob:*'))
2608 (func
2608 (func
2609 (symbol '_list')
2609 (symbol '_list')
2610 (string '2\x000\x001')))
2610 (string '2\x000\x001')))
2611 * set:
2611 * set:
2612 <filteredset
2612 <filteredset
2613 <baseset+ [0, 1, 2]>,
2613 <baseset+ [0, 1, 2]>,
2614 <contains 'glob:*'>>
2614 <contains 'glob:*'>>
2615 0
2615 0
2616 1
2616 1
2617 2
2617 2
2618
2618
2619 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2619 and in this example, 'A & B' is rewritten as 'B & A', but 'A' overrides
2620 the order appropriately:
2620 the order appropriately:
2621
2621
2622 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2622 $ try --optimize 'reverse(contains("glob:*")) & (0 + 2 + 1)'
2623 (and
2623 (and
2624 (func
2624 (func
2625 (symbol 'reverse')
2625 (symbol 'reverse')
2626 (func
2626 (func
2627 (symbol 'contains')
2627 (symbol 'contains')
2628 (string 'glob:*')))
2628 (string 'glob:*')))
2629 (group
2629 (group
2630 (or
2630 (or
2631 (list
2631 (list
2632 (symbol '0')
2632 (symbol '0')
2633 (symbol '2')
2633 (symbol '2')
2634 (symbol '1')))))
2634 (symbol '1')))))
2635 * optimized:
2635 * optimized:
2636 (andsmally
2636 (andsmally
2637 (func
2637 (func
2638 (symbol 'reverse')
2638 (symbol 'reverse')
2639 (func
2639 (func
2640 (symbol 'contains')
2640 (symbol 'contains')
2641 (string 'glob:*')))
2641 (string 'glob:*')))
2642 (func
2642 (func
2643 (symbol '_list')
2643 (symbol '_list')
2644 (string '0\x002\x001')))
2644 (string '0\x002\x001')))
2645 * set:
2645 * set:
2646 <filteredset
2646 <filteredset
2647 <baseset- [0, 1, 2]>,
2647 <baseset- [0, 1, 2]>,
2648 <contains 'glob:*'>>
2648 <contains 'glob:*'>>
2649 2
2649 2
2650 1
2650 1
2651 0
2651 0
2652
2652
2653 test sort revset
2653 test sort revset
2654 --------------------------------------------
2654 --------------------------------------------
2655
2655
2656 test when adding two unordered revsets
2656 test when adding two unordered revsets
2657
2657
2658 $ log 'sort(keyword(issue) or modifies(b))'
2658 $ log 'sort(keyword(issue) or modifies(b))'
2659 4
2659 4
2660 6
2660 6
2661
2661
2662 test when sorting a reversed collection in the same way it is
2662 test when sorting a reversed collection in the same way it is
2663
2663
2664 $ log 'sort(reverse(all()), -rev)'
2664 $ log 'sort(reverse(all()), -rev)'
2665 9
2665 9
2666 8
2666 8
2667 7
2667 7
2668 6
2668 6
2669 5
2669 5
2670 4
2670 4
2671 3
2671 3
2672 2
2672 2
2673 1
2673 1
2674 0
2674 0
2675
2675
2676 test when sorting a reversed collection
2676 test when sorting a reversed collection
2677
2677
2678 $ log 'sort(reverse(all()), rev)'
2678 $ log 'sort(reverse(all()), rev)'
2679 0
2679 0
2680 1
2680 1
2681 2
2681 2
2682 3
2682 3
2683 4
2683 4
2684 5
2684 5
2685 6
2685 6
2686 7
2686 7
2687 8
2687 8
2688 9
2688 9
2689
2689
2690
2690
2691 test sorting two sorted collections in different orders
2691 test sorting two sorted collections in different orders
2692
2692
2693 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2693 $ log 'sort(outgoing() or reverse(removes(a)), rev)'
2694 2
2694 2
2695 6
2695 6
2696 8
2696 8
2697 9
2697 9
2698
2698
2699 test sorting two sorted collections in different orders backwards
2699 test sorting two sorted collections in different orders backwards
2700
2700
2701 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2701 $ log 'sort(outgoing() or reverse(removes(a)), -rev)'
2702 9
2702 9
2703 8
2703 8
2704 6
2704 6
2705 2
2705 2
2706
2706
2707 test empty sort key which is noop
2707 test empty sort key which is noop
2708
2708
2709 $ log 'sort(0 + 2 + 1, "")'
2709 $ log 'sort(0 + 2 + 1, "")'
2710 0
2710 0
2711 2
2711 2
2712 1
2712 1
2713
2713
2714 test invalid sort keys
2714 test invalid sort keys
2715
2715
2716 $ log 'sort(all(), -invalid)'
2716 $ log 'sort(all(), -invalid)'
2717 hg: parse error: unknown sort key '-invalid'
2717 hg: parse error: unknown sort key '-invalid'
2718 [255]
2718 [255]
2719
2719
2720 $ cd ..
2720 $ cd ..
2721
2721
2722 test sorting by multiple keys including variable-length strings
2722 test sorting by multiple keys including variable-length strings
2723
2723
2724 $ hg init sorting
2724 $ hg init sorting
2725 $ cd sorting
2725 $ cd sorting
2726 $ cat <<EOF >> .hg/hgrc
2726 $ cat <<EOF >> .hg/hgrc
2727 > [ui]
2727 > [ui]
2728 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2728 > logtemplate = '{rev} {branch|p5}{desc|p5}{author|p5}{date|hgdate}\n'
2729 > [templatealias]
2729 > [templatealias]
2730 > p5(s) = pad(s, 5)
2730 > p5(s) = pad(s, 5)
2731 > EOF
2731 > EOF
2732 $ hg branch -qf b12
2732 $ hg branch -qf b12
2733 $ hg ci -m m111 -u u112 -d '111 10800'
2733 $ hg ci -m m111 -u u112 -d '111 10800'
2734 $ hg branch -qf b11
2734 $ hg branch -qf b11
2735 $ hg ci -m m12 -u u111 -d '112 7200'
2735 $ hg ci -m m12 -u u111 -d '112 7200'
2736 $ hg branch -qf b111
2736 $ hg branch -qf b111
2737 $ hg ci -m m11 -u u12 -d '111 3600'
2737 $ hg ci -m m11 -u u12 -d '111 3600'
2738 $ hg branch -qf b112
2738 $ hg branch -qf b112
2739 $ hg ci -m m111 -u u11 -d '120 0'
2739 $ hg ci -m m111 -u u11 -d '120 0'
2740 $ hg branch -qf b111
2740 $ hg branch -qf b111
2741 $ hg ci -m m112 -u u111 -d '110 14400'
2741 $ hg ci -m m112 -u u111 -d '110 14400'
2742 created new head
2742 created new head
2743
2743
2744 compare revisions (has fast path):
2744 compare revisions (has fast path):
2745
2745
2746 $ hg log -r 'sort(all(), rev)'
2746 $ hg log -r 'sort(all(), rev)'
2747 0 b12 m111 u112 111 10800
2747 0 b12 m111 u112 111 10800
2748 1 b11 m12 u111 112 7200
2748 1 b11 m12 u111 112 7200
2749 2 b111 m11 u12 111 3600
2749 2 b111 m11 u12 111 3600
2750 3 b112 m111 u11 120 0
2750 3 b112 m111 u11 120 0
2751 4 b111 m112 u111 110 14400
2751 4 b111 m112 u111 110 14400
2752
2752
2753 $ hg log -r 'sort(all(), -rev)'
2753 $ hg log -r 'sort(all(), -rev)'
2754 4 b111 m112 u111 110 14400
2754 4 b111 m112 u111 110 14400
2755 3 b112 m111 u11 120 0
2755 3 b112 m111 u11 120 0
2756 2 b111 m11 u12 111 3600
2756 2 b111 m11 u12 111 3600
2757 1 b11 m12 u111 112 7200
2757 1 b11 m12 u111 112 7200
2758 0 b12 m111 u112 111 10800
2758 0 b12 m111 u112 111 10800
2759
2759
2760 compare variable-length strings (issue5218):
2760 compare variable-length strings (issue5218):
2761
2761
2762 $ hg log -r 'sort(all(), branch)'
2762 $ hg log -r 'sort(all(), branch)'
2763 1 b11 m12 u111 112 7200
2763 1 b11 m12 u111 112 7200
2764 2 b111 m11 u12 111 3600
2764 2 b111 m11 u12 111 3600
2765 4 b111 m112 u111 110 14400
2765 4 b111 m112 u111 110 14400
2766 3 b112 m111 u11 120 0
2766 3 b112 m111 u11 120 0
2767 0 b12 m111 u112 111 10800
2767 0 b12 m111 u112 111 10800
2768
2768
2769 $ hg log -r 'sort(all(), -branch)'
2769 $ hg log -r 'sort(all(), -branch)'
2770 0 b12 m111 u112 111 10800
2770 0 b12 m111 u112 111 10800
2771 3 b112 m111 u11 120 0
2771 3 b112 m111 u11 120 0
2772 2 b111 m11 u12 111 3600
2772 2 b111 m11 u12 111 3600
2773 4 b111 m112 u111 110 14400
2773 4 b111 m112 u111 110 14400
2774 1 b11 m12 u111 112 7200
2774 1 b11 m12 u111 112 7200
2775
2775
2776 $ hg log -r 'sort(all(), desc)'
2776 $ hg log -r 'sort(all(), desc)'
2777 2 b111 m11 u12 111 3600
2777 2 b111 m11 u12 111 3600
2778 0 b12 m111 u112 111 10800
2778 0 b12 m111 u112 111 10800
2779 3 b112 m111 u11 120 0
2779 3 b112 m111 u11 120 0
2780 4 b111 m112 u111 110 14400
2780 4 b111 m112 u111 110 14400
2781 1 b11 m12 u111 112 7200
2781 1 b11 m12 u111 112 7200
2782
2782
2783 $ hg log -r 'sort(all(), -desc)'
2783 $ hg log -r 'sort(all(), -desc)'
2784 1 b11 m12 u111 112 7200
2784 1 b11 m12 u111 112 7200
2785 4 b111 m112 u111 110 14400
2785 4 b111 m112 u111 110 14400
2786 0 b12 m111 u112 111 10800
2786 0 b12 m111 u112 111 10800
2787 3 b112 m111 u11 120 0
2787 3 b112 m111 u11 120 0
2788 2 b111 m11 u12 111 3600
2788 2 b111 m11 u12 111 3600
2789
2789
2790 $ hg log -r 'sort(all(), user)'
2790 $ hg log -r 'sort(all(), user)'
2791 3 b112 m111 u11 120 0
2791 3 b112 m111 u11 120 0
2792 1 b11 m12 u111 112 7200
2792 1 b11 m12 u111 112 7200
2793 4 b111 m112 u111 110 14400
2793 4 b111 m112 u111 110 14400
2794 0 b12 m111 u112 111 10800
2794 0 b12 m111 u112 111 10800
2795 2 b111 m11 u12 111 3600
2795 2 b111 m11 u12 111 3600
2796
2796
2797 $ hg log -r 'sort(all(), -user)'
2797 $ hg log -r 'sort(all(), -user)'
2798 2 b111 m11 u12 111 3600
2798 2 b111 m11 u12 111 3600
2799 0 b12 m111 u112 111 10800
2799 0 b12 m111 u112 111 10800
2800 1 b11 m12 u111 112 7200
2800 1 b11 m12 u111 112 7200
2801 4 b111 m112 u111 110 14400
2801 4 b111 m112 u111 110 14400
2802 3 b112 m111 u11 120 0
2802 3 b112 m111 u11 120 0
2803
2803
2804 compare dates (tz offset should have no effect):
2804 compare dates (tz offset should have no effect):
2805
2805
2806 $ hg log -r 'sort(all(), date)'
2806 $ hg log -r 'sort(all(), date)'
2807 4 b111 m112 u111 110 14400
2807 4 b111 m112 u111 110 14400
2808 0 b12 m111 u112 111 10800
2808 0 b12 m111 u112 111 10800
2809 2 b111 m11 u12 111 3600
2809 2 b111 m11 u12 111 3600
2810 1 b11 m12 u111 112 7200
2810 1 b11 m12 u111 112 7200
2811 3 b112 m111 u11 120 0
2811 3 b112 m111 u11 120 0
2812
2812
2813 $ hg log -r 'sort(all(), -date)'
2813 $ hg log -r 'sort(all(), -date)'
2814 3 b112 m111 u11 120 0
2814 3 b112 m111 u11 120 0
2815 1 b11 m12 u111 112 7200
2815 1 b11 m12 u111 112 7200
2816 0 b12 m111 u112 111 10800
2816 0 b12 m111 u112 111 10800
2817 2 b111 m11 u12 111 3600
2817 2 b111 m11 u12 111 3600
2818 4 b111 m112 u111 110 14400
2818 4 b111 m112 u111 110 14400
2819
2819
2820 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2820 be aware that 'sort(x, -k)' is not exactly the same as 'reverse(sort(x, k))'
2821 because '-k' reverses the comparison, not the list itself:
2821 because '-k' reverses the comparison, not the list itself:
2822
2822
2823 $ hg log -r 'sort(0 + 2, date)'
2823 $ hg log -r 'sort(0 + 2, date)'
2824 0 b12 m111 u112 111 10800
2824 0 b12 m111 u112 111 10800
2825 2 b111 m11 u12 111 3600
2825 2 b111 m11 u12 111 3600
2826
2826
2827 $ hg log -r 'sort(0 + 2, -date)'
2827 $ hg log -r 'sort(0 + 2, -date)'
2828 0 b12 m111 u112 111 10800
2828 0 b12 m111 u112 111 10800
2829 2 b111 m11 u12 111 3600
2829 2 b111 m11 u12 111 3600
2830
2830
2831 $ hg log -r 'reverse(sort(0 + 2, date))'
2831 $ hg log -r 'reverse(sort(0 + 2, date))'
2832 2 b111 m11 u12 111 3600
2832 2 b111 m11 u12 111 3600
2833 0 b12 m111 u112 111 10800
2833 0 b12 m111 u112 111 10800
2834
2834
2835 sort by multiple keys:
2835 sort by multiple keys:
2836
2836
2837 $ hg log -r 'sort(all(), "branch -rev")'
2837 $ hg log -r 'sort(all(), "branch -rev")'
2838 1 b11 m12 u111 112 7200
2838 1 b11 m12 u111 112 7200
2839 4 b111 m112 u111 110 14400
2839 4 b111 m112 u111 110 14400
2840 2 b111 m11 u12 111 3600
2840 2 b111 m11 u12 111 3600
2841 3 b112 m111 u11 120 0
2841 3 b112 m111 u11 120 0
2842 0 b12 m111 u112 111 10800
2842 0 b12 m111 u112 111 10800
2843
2843
2844 $ hg log -r 'sort(all(), "-desc -date")'
2844 $ hg log -r 'sort(all(), "-desc -date")'
2845 1 b11 m12 u111 112 7200
2845 1 b11 m12 u111 112 7200
2846 4 b111 m112 u111 110 14400
2846 4 b111 m112 u111 110 14400
2847 3 b112 m111 u11 120 0
2847 3 b112 m111 u11 120 0
2848 0 b12 m111 u112 111 10800
2848 0 b12 m111 u112 111 10800
2849 2 b111 m11 u12 111 3600
2849 2 b111 m11 u12 111 3600
2850
2850
2851 $ hg log -r 'sort(all(), "user -branch date rev")'
2851 $ hg log -r 'sort(all(), "user -branch date rev")'
2852 3 b112 m111 u11 120 0
2852 3 b112 m111 u11 120 0
2853 4 b111 m112 u111 110 14400
2853 4 b111 m112 u111 110 14400
2854 1 b11 m12 u111 112 7200
2854 1 b11 m12 u111 112 7200
2855 0 b12 m111 u112 111 10800
2855 0 b12 m111 u112 111 10800
2856 2 b111 m11 u12 111 3600
2856 2 b111 m11 u12 111 3600
2857
2857
2858 toposort prioritises graph branches
2858 toposort prioritises graph branches
2859
2859
2860 $ hg up 2
2860 $ hg up 2
2861 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2861 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
2862 $ touch a
2862 $ touch a
2863 $ hg addremove
2863 $ hg addremove
2864 adding a
2864 adding a
2865 $ hg ci -m 't1' -u 'tu' -d '130 0'
2865 $ hg ci -m 't1' -u 'tu' -d '130 0'
2866 created new head
2866 created new head
2867 $ echo 'a' >> a
2867 $ echo 'a' >> a
2868 $ hg ci -m 't2' -u 'tu' -d '130 0'
2868 $ hg ci -m 't2' -u 'tu' -d '130 0'
2869 $ hg book book1
2869 $ hg book book1
2870 $ hg up 4
2870 $ hg up 4
2871 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2871 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
2872 (leaving bookmark book1)
2872 (leaving bookmark book1)
2873 $ touch a
2873 $ touch a
2874 $ hg addremove
2874 $ hg addremove
2875 adding a
2875 adding a
2876 $ hg ci -m 't3' -u 'tu' -d '130 0'
2876 $ hg ci -m 't3' -u 'tu' -d '130 0'
2877
2877
2878 $ hg log -r 'sort(all(), topo)'
2878 $ hg log -r 'sort(all(), topo)'
2879 7 b111 t3 tu 130 0
2879 7 b111 t3 tu 130 0
2880 4 b111 m112 u111 110 14400
2880 4 b111 m112 u111 110 14400
2881 3 b112 m111 u11 120 0
2881 3 b112 m111 u11 120 0
2882 6 b111 t2 tu 130 0
2882 6 b111 t2 tu 130 0
2883 5 b111 t1 tu 130 0
2883 5 b111 t1 tu 130 0
2884 2 b111 m11 u12 111 3600
2884 2 b111 m11 u12 111 3600
2885 1 b11 m12 u111 112 7200
2885 1 b11 m12 u111 112 7200
2886 0 b12 m111 u112 111 10800
2886 0 b12 m111 u112 111 10800
2887
2887
2888 $ hg log -r 'sort(all(), -topo)'
2888 $ hg log -r 'sort(all(), -topo)'
2889 0 b12 m111 u112 111 10800
2889 0 b12 m111 u112 111 10800
2890 1 b11 m12 u111 112 7200
2890 1 b11 m12 u111 112 7200
2891 2 b111 m11 u12 111 3600
2891 2 b111 m11 u12 111 3600
2892 5 b111 t1 tu 130 0
2892 5 b111 t1 tu 130 0
2893 6 b111 t2 tu 130 0
2893 6 b111 t2 tu 130 0
2894 3 b112 m111 u11 120 0
2894 3 b112 m111 u11 120 0
2895 4 b111 m112 u111 110 14400
2895 4 b111 m112 u111 110 14400
2896 7 b111 t3 tu 130 0
2896 7 b111 t3 tu 130 0
2897
2897
2898 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2898 $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
2899 6 b111 t2 tu 130 0
2899 6 b111 t2 tu 130 0
2900 5 b111 t1 tu 130 0
2900 5 b111 t1 tu 130 0
2901 7 b111 t3 tu 130 0
2901 7 b111 t3 tu 130 0
2902 4 b111 m112 u111 110 14400
2902 4 b111 m112 u111 110 14400
2903 3 b112 m111 u11 120 0
2903 3 b112 m111 u11 120 0
2904 2 b111 m11 u12 111 3600
2904 2 b111 m11 u12 111 3600
2905 1 b11 m12 u111 112 7200
2905 1 b11 m12 u111 112 7200
2906 0 b12 m111 u112 111 10800
2906 0 b12 m111 u112 111 10800
2907
2907
2908 topographical sorting can't be combined with other sort keys, and you can't
2908 topographical sorting can't be combined with other sort keys, and you can't
2909 use the topo.firstbranch option when topo sort is not active:
2909 use the topo.firstbranch option when topo sort is not active:
2910
2910
2911 $ hg log -r 'sort(all(), "topo user")'
2911 $ hg log -r 'sort(all(), "topo user")'
2912 hg: parse error: topo sort order cannot be combined with other sort keys
2912 hg: parse error: topo sort order cannot be combined with other sort keys
2913 [255]
2913 [255]
2914
2914
2915 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2915 $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
2916 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2916 hg: parse error: topo.firstbranch can only be used when using the topo sort key
2917 [255]
2917 [255]
2918
2918
2919 topo.firstbranch should accept any kind of expressions:
2919 topo.firstbranch should accept any kind of expressions:
2920
2920
2921 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2921 $ hg log -r 'sort(0, topo, topo.firstbranch=(book1))'
2922 0 b12 m111 u112 111 10800
2922 0 b12 m111 u112 111 10800
2923
2923
2924 $ cd ..
2924 $ cd ..
2925 $ cd repo
2925 $ cd repo
2926
2926
2927 test multiline revset with errors
2927 test multiline revset with errors
2928
2928
2929 $ echo > multiline-revset
2929 $ echo > multiline-revset
2930 $ echo '. +' >> multiline-revset
2930 $ echo '. +' >> multiline-revset
2931 $ echo '.^ +' >> multiline-revset
2931 $ echo '.^ +' >> multiline-revset
2932 $ hg log -r "`cat multiline-revset`"
2932 $ hg log -r "`cat multiline-revset`"
2933 hg: parse error at 9: not a prefix: end
2933 hg: parse error at 9: not a prefix: end
2934 ( . + .^ +
2934 ( . + .^ +
2935 ^ here)
2935 ^ here)
2936 [255]
2936 [255]
2937 $ hg debugrevspec -v 'revset(first(rev(0)))' -p all
2937 $ hg debugrevspec -v 'revset(first(rev(0)))' -p all
2938 * parsed:
2938 * parsed:
2939 (func
2939 (func
2940 (symbol 'revset')
2940 (symbol 'revset')
2941 (func
2941 (func
2942 (symbol 'first')
2942 (symbol 'first')
2943 (func
2943 (func
2944 (symbol 'rev')
2944 (symbol 'rev')
2945 (symbol '0'))))
2945 (symbol '0'))))
2946 * expanded:
2946 * expanded:
2947 (func
2947 (func
2948 (symbol 'revset')
2948 (symbol 'revset')
2949 (func
2949 (func
2950 (symbol 'first')
2950 (symbol 'first')
2951 (func
2951 (func
2952 (symbol 'rev')
2952 (symbol 'rev')
2953 (symbol '0'))))
2953 (symbol '0'))))
2954 * concatenated:
2954 * concatenated:
2955 (func
2955 (func
2956 (symbol 'revset')
2956 (symbol 'revset')
2957 (func
2957 (func
2958 (symbol 'first')
2958 (symbol 'first')
2959 (func
2959 (func
2960 (symbol 'rev')
2960 (symbol 'rev')
2961 (symbol '0'))))
2961 (symbol '0'))))
2962 * analyzed:
2962 * analyzed:
2963 (func
2963 (func
2964 (symbol 'revset')
2964 (symbol 'revset')
2965 (func
2965 (func
2966 (symbol 'first')
2966 (symbol 'first')
2967 (func
2967 (func
2968 (symbol 'rev')
2968 (symbol 'rev')
2969 (symbol '0'))))
2969 (symbol '0'))))
2970 * optimized:
2970 * optimized:
2971 (func
2971 (func
2972 (symbol 'revset')
2972 (symbol 'revset')
2973 (func
2973 (func
2974 (symbol 'first')
2974 (symbol 'first')
2975 (func
2975 (func
2976 (symbol 'rev')
2976 (symbol 'rev')
2977 (symbol '0'))))
2977 (symbol '0'))))
2978 * set:
2978 * set:
2979 <baseset+ [0]>
2979 <baseset+ [0]>
2980 0
2980 0
2981
2981
2982 abort if the revset doesn't expect given size
2982 abort if the revset doesn't expect given size
2983 $ log 'expectsize()'
2983 $ log 'expectsize()'
2984 hg: parse error: invalid set of arguments
2984 hg: parse error: invalid set of arguments
2985 [255]
2985 [255]
2986 $ log 'expectsize(0:2, a)'
2986 $ log 'expectsize(0:2, a)'
2987 hg: parse error: expectsize requires a size range or a positive integer
2987 hg: parse error: expectsize requires a size range or a positive integer
2988 [255]
2988 [255]
2989 $ log 'expectsize(0:2, 3)'
2989 $ log 'expectsize(0:2, 3)'
2990 0
2990 0
2991 1
2991 1
2992 2
2992 2
2993
2993
2994 $ log 'expectsize(2:0, 3)'
2994 $ log 'expectsize(2:0, 3)'
2995 2
2995 2
2996 1
2996 1
2997 0
2997 0
2998 $ log 'expectsize(0:1, 1)'
2998 $ log 'expectsize(0:1, 1)'
2999 abort: revset size mismatch. expected 1, got 2!
2999 abort: revset size mismatch. expected 1, got 2!
3000 [255]
3000 [255]
3001 $ log 'expectsize(0:4, -1)'
3001 $ log 'expectsize(0:4, -1)'
3002 hg: parse error: negative size
3002 hg: parse error: negative size
3003 [255]
3003 [255]
3004 $ log 'expectsize(0:2, 2:4)'
3004 $ log 'expectsize(0:2, 2:4)'
3005 0
3005 0
3006 1
3006 1
3007 2
3007 2
3008 $ log 'expectsize(0:1, 3:5)'
3008 $ log 'expectsize(0:1, 3:5)'
3009 abort: revset size mismatch. expected between 3 and 5, got 2!
3009 abort: revset size mismatch. expected between 3 and 5, got 2!
3010 [255]
3010 [255]
3011 $ log 'expectsize(0:1, -1:2)'
3011 $ log 'expectsize(0:1, -1:2)'
3012 hg: parse error: negative size
3012 hg: parse error: negative size
3013 [255]
3013 [255]
3014 $ log 'expectsize(0:1, 1:-2)'
3014 $ log 'expectsize(0:1, 1:-2)'
3015 hg: parse error: negative size
3015 hg: parse error: negative size
3016 [255]
3016 [255]
3017 $ log 'expectsize(0:2, a:4)'
3017 $ log 'expectsize(0:2, a:4)'
3018 hg: parse error: size range bounds must be integers
3018 hg: parse error: size range bounds must be integers
3019 [255]
3019 [255]
3020 $ log 'expectsize(0:2, 2:b)'
3020 $ log 'expectsize(0:2, 2:b)'
3021 hg: parse error: size range bounds must be integers
3021 hg: parse error: size range bounds must be integers
3022 [255]
3022 [255]
3023 $ log 'expectsize(0:2, 2:)'
3023 $ log 'expectsize(0:2, 2:)'
3024 0
3024 0
3025 1
3025 1
3026 2
3026 2
3027 $ log 'expectsize(0:2, :5)'
3027 $ log 'expectsize(0:2, :5)'
3028 0
3028 0
3029 1
3029 1
3030 2
3030 2
3031 $ log 'expectsize(0:2, :)'
3031 $ log 'expectsize(0:2, :)'
3032 0
3032 0
3033 1
3033 1
3034 2
3034 2
3035 $ log 'expectsize(0:2, 4:)'
3035 $ log 'expectsize(0:2, 4:)'
3036 abort: revset size mismatch. expected between 4 and 11, got 3!
3036 abort: revset size mismatch. expected between 4 and 11, got 3!
3037 [255]
3037 [255]
3038 $ log 'expectsize(0:2, :2)'
3038 $ log 'expectsize(0:2, :2)'
3039 abort: revset size mismatch. expected between 0 and 2, got 3!
3039 abort: revset size mismatch. expected between 0 and 2, got 3!
3040 [255]
3040 [255]
General Comments 0
You need to be logged in to leave comments. Login now