Show More
@@ -1,1065 +1,1065 b'' | |||||
1 | #if windows |
|
1 | #if windows | |
2 | $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH" |
|
2 | $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH" | |
3 | #else |
|
3 | #else | |
4 | $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH" |
|
4 | $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH" | |
5 | #endif |
|
5 | #endif | |
6 | $ export PYTHONPATH |
|
6 | $ export PYTHONPATH | |
7 |
|
7 | |||
8 | typical client does not want echo-back messages, so test without it: |
|
8 | typical client does not want echo-back messages, so test without it: | |
9 |
|
9 | |||
10 | $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new |
|
10 | $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new | |
11 | $ mv $HGRCPATH.new $HGRCPATH |
|
11 | $ mv $HGRCPATH.new $HGRCPATH | |
12 |
|
12 | |||
13 | $ hg init repo |
|
13 | $ hg init repo | |
14 | $ cd repo |
|
14 | $ cd repo | |
15 |
|
15 | |||
16 | >>> from __future__ import absolute_import |
|
16 | >>> from __future__ import absolute_import | |
17 | >>> import os |
|
17 | >>> import os | |
18 | >>> import sys |
|
18 | >>> import sys | |
19 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
19 | >>> from hgclient import bprint, check, readchannel, runcommand | |
20 | >>> @check |
|
20 | >>> @check | |
21 | ... def hellomessage(server): |
|
21 | ... def hellomessage(server): | |
22 | ... ch, data = readchannel(server) |
|
22 | ... ch, data = readchannel(server) | |
23 | ... bprint(b'%c, %r' % (ch, data)) |
|
23 | ... bprint(b'%c, %r' % (ch, data)) | |
24 | ... # run an arbitrary command to make sure the next thing the server |
|
24 | ... # run an arbitrary command to make sure the next thing the server | |
25 | ... # sends isn't part of the hello message |
|
25 | ... # sends isn't part of the hello message | |
26 | ... runcommand(server, [b'id']) |
|
26 | ... runcommand(server, [b'id']) | |
27 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
27 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) | |
28 | *** runcommand id |
|
28 | *** runcommand id | |
29 | 000000000000 tip |
|
29 | 000000000000 tip | |
30 |
|
30 | |||
31 | >>> from hgclient import check |
|
31 | >>> from hgclient import check | |
32 | >>> @check |
|
32 | >>> @check | |
33 | ... def unknowncommand(server): |
|
33 | ... def unknowncommand(server): | |
34 | ... server.stdin.write(b'unknowncommand\n') |
|
34 | ... server.stdin.write(b'unknowncommand\n') | |
35 | abort: unknown command unknowncommand |
|
35 | abort: unknown command unknowncommand | |
36 |
|
36 | |||
37 | >>> from hgclient import check, readchannel, runcommand |
|
37 | >>> from hgclient import check, readchannel, runcommand | |
38 | >>> @check |
|
38 | >>> @check | |
39 | ... def checkruncommand(server): |
|
39 | ... def checkruncommand(server): | |
40 | ... # hello block |
|
40 | ... # hello block | |
41 | ... readchannel(server) |
|
41 | ... readchannel(server) | |
42 | ... |
|
42 | ... | |
43 | ... # no args |
|
43 | ... # no args | |
44 | ... runcommand(server, []) |
|
44 | ... runcommand(server, []) | |
45 | ... |
|
45 | ... | |
46 | ... # global options |
|
46 | ... # global options | |
47 | ... runcommand(server, [b'id', b'--quiet']) |
|
47 | ... runcommand(server, [b'id', b'--quiet']) | |
48 | ... |
|
48 | ... | |
49 | ... # make sure global options don't stick through requests |
|
49 | ... # make sure global options don't stick through requests | |
50 | ... runcommand(server, [b'id']) |
|
50 | ... runcommand(server, [b'id']) | |
51 | ... |
|
51 | ... | |
52 | ... # --config |
|
52 | ... # --config | |
53 | ... runcommand(server, [b'id', b'--config', b'ui.quiet=True']) |
|
53 | ... runcommand(server, [b'id', b'--config', b'ui.quiet=True']) | |
54 | ... |
|
54 | ... | |
55 | ... # make sure --config doesn't stick |
|
55 | ... # make sure --config doesn't stick | |
56 | ... runcommand(server, [b'id']) |
|
56 | ... runcommand(server, [b'id']) | |
57 | ... |
|
57 | ... | |
58 | ... # negative return code should be masked |
|
58 | ... # negative return code should be masked | |
59 | ... runcommand(server, [b'id', b'-runknown']) |
|
59 | ... runcommand(server, [b'id', b'-runknown']) | |
60 | *** runcommand |
|
60 | *** runcommand | |
61 | Mercurial Distributed SCM |
|
61 | Mercurial Distributed SCM | |
62 |
|
62 | |||
63 | basic commands: |
|
63 | basic commands: | |
64 |
|
64 | |||
65 | add add the specified files on the next commit |
|
65 | add add the specified files on the next commit | |
66 | annotate show changeset information by line for each file |
|
66 | annotate show changeset information by line for each file | |
67 | clone make a copy of an existing repository |
|
67 | clone make a copy of an existing repository | |
68 | commit commit the specified files or all outstanding changes |
|
68 | commit commit the specified files or all outstanding changes | |
69 | diff diff repository (or selected files) |
|
69 | diff diff repository (or selected files) | |
70 | export dump the header and diffs for one or more changesets |
|
70 | export dump the header and diffs for one or more changesets | |
71 | forget forget the specified files on the next commit |
|
71 | forget forget the specified files on the next commit | |
72 | init create a new repository in the given directory |
|
72 | init create a new repository in the given directory | |
73 | log show revision history of entire repository or files |
|
73 | log show revision history of entire repository or files | |
74 | merge merge another revision into working directory |
|
74 | merge merge another revision into working directory | |
75 | pull pull changes from the specified source |
|
75 | pull pull changes from the specified source | |
76 | push push changes to the specified destination |
|
76 | push push changes to the specified destination | |
77 | remove remove the specified files on the next commit |
|
77 | remove remove the specified files on the next commit | |
78 | serve start stand-alone webserver |
|
78 | serve start stand-alone webserver | |
79 | status show changed files in the working directory |
|
79 | status show changed files in the working directory | |
80 | summary summarize working directory state |
|
80 | summary summarize working directory state | |
81 | update update working directory (or switch revisions) |
|
81 | update update working directory (or switch revisions) | |
82 |
|
82 | |||
83 | (use 'hg help' for the full list of commands or 'hg -v' for details) |
|
83 | (use 'hg help' for the full list of commands or 'hg -v' for details) | |
84 | *** runcommand id --quiet |
|
84 | *** runcommand id --quiet | |
85 | 000000000000 |
|
85 | 000000000000 | |
86 | *** runcommand id |
|
86 | *** runcommand id | |
87 | 000000000000 tip |
|
87 | 000000000000 tip | |
88 | *** runcommand id --config ui.quiet=True |
|
88 | *** runcommand id --config ui.quiet=True | |
89 | 000000000000 |
|
89 | 000000000000 | |
90 | *** runcommand id |
|
90 | *** runcommand id | |
91 | 000000000000 tip |
|
91 | 000000000000 tip | |
92 | *** runcommand id -runknown |
|
92 | *** runcommand id -runknown | |
93 | abort: unknown revision 'unknown'! |
|
93 | abort: unknown revision 'unknown'! | |
94 | [255] |
|
94 | [255] | |
95 |
|
95 | |||
96 | >>> from hgclient import bprint, check, readchannel |
|
96 | >>> from hgclient import bprint, check, readchannel | |
97 | >>> @check |
|
97 | >>> @check | |
98 | ... def inputeof(server): |
|
98 | ... def inputeof(server): | |
99 | ... readchannel(server) |
|
99 | ... readchannel(server) | |
100 | ... server.stdin.write(b'runcommand\n') |
|
100 | ... server.stdin.write(b'runcommand\n') | |
101 | ... # close stdin while server is waiting for input |
|
101 | ... # close stdin while server is waiting for input | |
102 | ... server.stdin.close() |
|
102 | ... server.stdin.close() | |
103 | ... |
|
103 | ... | |
104 | ... # server exits with 1 if the pipe closed while reading the command |
|
104 | ... # server exits with 1 if the pipe closed while reading the command | |
105 | ... bprint(b'server exit code =', b'%d' % server.wait()) |
|
105 | ... bprint(b'server exit code =', b'%d' % server.wait()) | |
106 | server exit code = 1 |
|
106 | server exit code = 1 | |
107 |
|
107 | |||
108 | >>> from hgclient import check, readchannel, runcommand, stringio |
|
108 | >>> from hgclient import check, readchannel, runcommand, stringio | |
109 | >>> @check |
|
109 | >>> @check | |
110 | ... def serverinput(server): |
|
110 | ... def serverinput(server): | |
111 | ... readchannel(server) |
|
111 | ... readchannel(server) | |
112 | ... |
|
112 | ... | |
113 | ... patch = b""" |
|
113 | ... patch = b""" | |
114 | ... # HG changeset patch |
|
114 | ... # HG changeset patch | |
115 | ... # User test |
|
115 | ... # User test | |
116 | ... # Date 0 0 |
|
116 | ... # Date 0 0 | |
117 | ... # Node ID c103a3dec114d882c98382d684d8af798d09d857 |
|
117 | ... # Node ID c103a3dec114d882c98382d684d8af798d09d857 | |
118 | ... # Parent 0000000000000000000000000000000000000000 |
|
118 | ... # Parent 0000000000000000000000000000000000000000 | |
119 | ... 1 |
|
119 | ... 1 | |
120 | ... |
|
120 | ... | |
121 | ... diff -r 000000000000 -r c103a3dec114 a |
|
121 | ... diff -r 000000000000 -r c103a3dec114 a | |
122 | ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
122 | ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
123 | ... +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
123 | ... +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
124 | ... @@ -0,0 +1,1 @@ |
|
124 | ... @@ -0,0 +1,1 @@ | |
125 | ... +1 |
|
125 | ... +1 | |
126 | ... """ |
|
126 | ... """ | |
127 | ... |
|
127 | ... | |
128 | ... runcommand(server, [b'import', b'-'], input=stringio(patch)) |
|
128 | ... runcommand(server, [b'import', b'-'], input=stringio(patch)) | |
129 | ... runcommand(server, [b'log']) |
|
129 | ... runcommand(server, [b'log']) | |
130 | *** runcommand import - |
|
130 | *** runcommand import - | |
131 | applying patch from stdin |
|
131 | applying patch from stdin | |
132 | *** runcommand log |
|
132 | *** runcommand log | |
133 | changeset: 0:eff892de26ec |
|
133 | changeset: 0:eff892de26ec | |
134 | tag: tip |
|
134 | tag: tip | |
135 | user: test |
|
135 | user: test | |
136 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
136 | date: Thu Jan 01 00:00:00 1970 +0000 | |
137 | summary: 1 |
|
137 | summary: 1 | |
138 |
|
138 | |||
139 |
|
139 | |||
140 | check strict parsing of early options: |
|
140 | check strict parsing of early options: | |
141 |
|
141 | |||
142 | >>> import os |
|
142 | >>> import os | |
143 | >>> from hgclient import check, readchannel, runcommand |
|
143 | >>> from hgclient import check, readchannel, runcommand | |
144 | >>> os.environ['HGPLAIN'] = '+strictflags' |
|
144 | >>> os.environ['HGPLAIN'] = '+strictflags' | |
145 | >>> @check |
|
145 | >>> @check | |
146 | ... def cwd(server): |
|
146 | ... def cwd(server): | |
147 | ... readchannel(server) |
|
147 | ... readchannel(server) | |
148 | ... runcommand(server, [b'log', b'-b', b'--config=alias.log=!echo pwned', |
|
148 | ... runcommand(server, [b'log', b'-b', b'--config=alias.log=!echo pwned', | |
149 | ... b'default']) |
|
149 | ... b'default']) | |
150 | *** runcommand log -b --config=alias.log=!echo pwned default |
|
150 | *** runcommand log -b --config=alias.log=!echo pwned default | |
151 | abort: unknown revision '--config=alias.log=!echo pwned'! |
|
151 | abort: unknown revision '--config=alias.log=!echo pwned'! | |
152 | [255] |
|
152 | [255] | |
153 |
|
153 | |||
154 | check that "histedit --commands=-" can read rules from the input channel: |
|
154 | check that "histedit --commands=-" can read rules from the input channel: | |
155 |
|
155 | |||
156 | >>> from hgclient import check, readchannel, runcommand, stringio |
|
156 | >>> from hgclient import check, readchannel, runcommand, stringio | |
157 | >>> @check |
|
157 | >>> @check | |
158 | ... def serverinput(server): |
|
158 | ... def serverinput(server): | |
159 | ... readchannel(server) |
|
159 | ... readchannel(server) | |
160 | ... rules = b'pick eff892de26ec\n' |
|
160 | ... rules = b'pick eff892de26ec\n' | |
161 | ... runcommand(server, [b'histedit', b'0', b'--commands=-', |
|
161 | ... runcommand(server, [b'histedit', b'0', b'--commands=-', | |
162 | ... b'--config', b'extensions.histedit='], |
|
162 | ... b'--config', b'extensions.histedit='], | |
163 | ... input=stringio(rules)) |
|
163 | ... input=stringio(rules)) | |
164 | *** runcommand histedit 0 --commands=- --config extensions.histedit= |
|
164 | *** runcommand histedit 0 --commands=- --config extensions.histedit= | |
165 |
|
165 | |||
166 | check that --cwd doesn't persist between requests: |
|
166 | check that --cwd doesn't persist between requests: | |
167 |
|
167 | |||
168 | $ mkdir foo |
|
168 | $ mkdir foo | |
169 | $ touch foo/bar |
|
169 | $ touch foo/bar | |
170 | >>> from hgclient import check, readchannel, runcommand |
|
170 | >>> from hgclient import check, readchannel, runcommand | |
171 | >>> @check |
|
171 | >>> @check | |
172 | ... def cwd(server): |
|
172 | ... def cwd(server): | |
173 | ... readchannel(server) |
|
173 | ... readchannel(server) | |
174 | ... runcommand(server, [b'--cwd', b'foo', b'st', b'bar']) |
|
174 | ... runcommand(server, [b'--cwd', b'foo', b'st', b'bar']) | |
175 | ... runcommand(server, [b'st', b'foo/bar']) |
|
175 | ... runcommand(server, [b'st', b'foo/bar']) | |
176 | *** runcommand --cwd foo st bar |
|
176 | *** runcommand --cwd foo st bar | |
177 | ? bar |
|
177 | ? bar | |
178 | *** runcommand st foo/bar |
|
178 | *** runcommand st foo/bar | |
179 | ? foo/bar |
|
179 | ? foo/bar | |
180 |
|
180 | |||
181 | $ rm foo/bar |
|
181 | $ rm foo/bar | |
182 |
|
182 | |||
183 |
|
183 | |||
184 | check that local configs for the cached repo aren't inherited when -R is used: |
|
184 | check that local configs for the cached repo aren't inherited when -R is used: | |
185 |
|
185 | |||
186 | $ cat <<EOF >> .hg/hgrc |
|
186 | $ cat <<EOF >> .hg/hgrc | |
187 | > [ui] |
|
187 | > [ui] | |
188 | > foo = bar |
|
188 | > foo = bar | |
189 | > EOF |
|
189 | > EOF | |
190 |
|
190 | |||
191 | #if no-extraextensions |
|
191 | #if no-extraextensions | |
192 |
|
192 | |||
193 | >>> from hgclient import check, readchannel, runcommand, sep |
|
193 | >>> from hgclient import check, readchannel, runcommand, sep | |
194 | >>> @check |
|
194 | >>> @check | |
195 | ... def localhgrc(server): |
|
195 | ... def localhgrc(server): | |
196 | ... readchannel(server) |
|
196 | ... readchannel(server) | |
197 | ... |
|
197 | ... | |
198 | ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should |
|
198 | ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should | |
199 | ... # show it |
|
199 | ... # show it | |
200 | ... runcommand(server, [b'showconfig'], outfilter=sep) |
|
200 | ... runcommand(server, [b'showconfig'], outfilter=sep) | |
201 | ... |
|
201 | ... | |
202 | ... # but not for this repo |
|
202 | ... # but not for this repo | |
203 | ... runcommand(server, [b'init', b'foo']) |
|
203 | ... runcommand(server, [b'init', b'foo']) | |
204 | ... runcommand(server, [b'-R', b'foo', b'showconfig', b'ui', b'defaults']) |
|
204 | ... runcommand(server, [b'-R', b'foo', b'showconfig', b'ui', b'defaults']) | |
205 | *** runcommand showconfig |
|
205 | *** runcommand showconfig | |
206 | bundle.mainreporoot=$TESTTMP/repo |
|
206 | bundle.mainreporoot=$TESTTMP/repo | |
207 | devel.all-warnings=true |
|
207 | devel.all-warnings=true | |
208 | devel.default-date=0 0 |
|
208 | devel.default-date=0 0 | |
209 | extensions.fsmonitor= (fsmonitor !) |
|
209 | extensions.fsmonitor= (fsmonitor !) | |
210 | largefiles.usercache=$TESTTMP/.cache/largefiles |
|
210 | largefiles.usercache=$TESTTMP/.cache/largefiles | |
211 | lfs.usercache=$TESTTMP/.cache/lfs |
|
211 | lfs.usercache=$TESTTMP/.cache/lfs | |
212 | ui.slash=True |
|
212 | ui.slash=True | |
213 | ui.interactive=False |
|
213 | ui.interactive=False | |
214 | ui.merge=internal:merge |
|
214 | ui.merge=internal:merge | |
215 | ui.mergemarkers=detailed |
|
215 | ui.mergemarkers=detailed | |
216 | ui.foo=bar |
|
216 | ui.foo=bar | |
217 | ui.nontty=true |
|
217 | ui.nontty=true | |
218 | web.address=localhost |
|
218 | web.address=localhost | |
219 | web\.ipv6=(?:True|False) (re) |
|
219 | web\.ipv6=(?:True|False) (re) | |
220 | web.server-header=testing stub value |
|
220 | web.server-header=testing stub value | |
221 | *** runcommand init foo |
|
221 | *** runcommand init foo | |
222 | *** runcommand -R foo showconfig ui defaults |
|
222 | *** runcommand -R foo showconfig ui defaults | |
223 | ui.slash=True |
|
223 | ui.slash=True | |
224 | ui.interactive=False |
|
224 | ui.interactive=False | |
225 | ui.merge=internal:merge |
|
225 | ui.merge=internal:merge | |
226 | ui.mergemarkers=detailed |
|
226 | ui.mergemarkers=detailed | |
227 | ui.nontty=true |
|
227 | ui.nontty=true | |
228 | #endif |
|
228 | #endif | |
229 |
|
229 | |||
230 | $ rm -R foo |
|
230 | $ rm -R foo | |
231 |
|
231 | |||
232 | #if windows |
|
232 | #if windows | |
233 | $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH" |
|
233 | $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH" | |
234 | #else |
|
234 | #else | |
235 | $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH" |
|
235 | $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH" | |
236 | #endif |
|
236 | #endif | |
237 |
|
237 | |||
238 | $ cat <<EOF > hook.py |
|
238 | $ cat <<EOF > hook.py | |
239 | > import sys |
|
239 | > import sys | |
240 | > from hgclient import bprint |
|
240 | > from hgclient import bprint | |
241 | > def hook(**args): |
|
241 | > def hook(**args): | |
242 | > bprint(b'hook talking') |
|
242 | > bprint(b'hook talking') | |
243 | > bprint(b'now try to read something: %r' % sys.stdin.read()) |
|
243 | > bprint(b'now try to read something: %r' % sys.stdin.read()) | |
244 | > EOF |
|
244 | > EOF | |
245 |
|
245 | |||
246 | >>> from hgclient import check, readchannel, runcommand, stringio |
|
246 | >>> from hgclient import check, readchannel, runcommand, stringio | |
247 | >>> @check |
|
247 | >>> @check | |
248 | ... def hookoutput(server): |
|
248 | ... def hookoutput(server): | |
249 | ... readchannel(server) |
|
249 | ... readchannel(server) | |
250 | ... runcommand(server, [b'--config', |
|
250 | ... runcommand(server, [b'--config', | |
251 | ... b'hooks.pre-identify=python:hook.hook', |
|
251 | ... b'hooks.pre-identify=python:hook.hook', | |
252 | ... b'id'], |
|
252 | ... b'id'], | |
253 | ... input=stringio(b'some input')) |
|
253 | ... input=stringio(b'some input')) | |
254 | *** runcommand --config hooks.pre-identify=python:hook.hook id |
|
254 | *** runcommand --config hooks.pre-identify=python:hook.hook id | |
255 | eff892de26ec tip |
|
255 | eff892de26ec tip | |
256 | hook talking |
|
256 | hook talking | |
257 | now try to read something: '' |
|
257 | now try to read something: '' | |
258 |
|
258 | |||
259 | Clean hook cached version |
|
259 | Clean hook cached version | |
260 | $ rm hook.py* |
|
260 | $ rm hook.py* | |
261 | $ rm -Rf __pycache__ |
|
261 | $ rm -Rf __pycache__ | |
262 |
|
262 | |||
263 | $ echo a >> a |
|
263 | $ echo a >> a | |
264 | >>> import os |
|
264 | >>> import os | |
265 | >>> from hgclient import check, readchannel, runcommand |
|
265 | >>> from hgclient import check, readchannel, runcommand | |
266 | >>> @check |
|
266 | >>> @check | |
267 | ... def outsidechanges(server): |
|
267 | ... def outsidechanges(server): | |
268 | ... readchannel(server) |
|
268 | ... readchannel(server) | |
269 | ... runcommand(server, [b'status']) |
|
269 | ... runcommand(server, [b'status']) | |
270 | ... os.system('hg ci -Am2') |
|
270 | ... os.system('hg ci -Am2') | |
271 | ... runcommand(server, [b'tip']) |
|
271 | ... runcommand(server, [b'tip']) | |
272 | ... runcommand(server, [b'status']) |
|
272 | ... runcommand(server, [b'status']) | |
273 | *** runcommand status |
|
273 | *** runcommand status | |
274 | M a |
|
274 | M a | |
275 | *** runcommand tip |
|
275 | *** runcommand tip | |
276 | changeset: 1:d3a0a68be6de |
|
276 | changeset: 1:d3a0a68be6de | |
277 | tag: tip |
|
277 | tag: tip | |
278 | user: test |
|
278 | user: test | |
279 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
279 | date: Thu Jan 01 00:00:00 1970 +0000 | |
280 | summary: 2 |
|
280 | summary: 2 | |
281 |
|
281 | |||
282 | *** runcommand status |
|
282 | *** runcommand status | |
283 |
|
283 | |||
284 | >>> import os |
|
284 | >>> import os | |
285 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
285 | >>> from hgclient import bprint, check, readchannel, runcommand | |
286 | >>> @check |
|
286 | >>> @check | |
287 | ... def bookmarks(server): |
|
287 | ... def bookmarks(server): | |
288 | ... readchannel(server) |
|
288 | ... readchannel(server) | |
289 | ... runcommand(server, [b'bookmarks']) |
|
289 | ... runcommand(server, [b'bookmarks']) | |
290 | ... |
|
290 | ... | |
291 | ... # changes .hg/bookmarks |
|
291 | ... # changes .hg/bookmarks | |
292 | ... os.system('hg bookmark -i bm1') |
|
292 | ... os.system('hg bookmark -i bm1') | |
293 | ... os.system('hg bookmark -i bm2') |
|
293 | ... os.system('hg bookmark -i bm2') | |
294 | ... runcommand(server, [b'bookmarks']) |
|
294 | ... runcommand(server, [b'bookmarks']) | |
295 | ... |
|
295 | ... | |
296 | ... # changes .hg/bookmarks.current |
|
296 | ... # changes .hg/bookmarks.current | |
297 | ... os.system('hg upd bm1 -q') |
|
297 | ... os.system('hg upd bm1 -q') | |
298 | ... runcommand(server, [b'bookmarks']) |
|
298 | ... runcommand(server, [b'bookmarks']) | |
299 | ... |
|
299 | ... | |
300 | ... runcommand(server, [b'bookmarks', b'bm3']) |
|
300 | ... runcommand(server, [b'bookmarks', b'bm3']) | |
301 | ... f = open('a', 'ab') |
|
301 | ... f = open('a', 'ab') | |
302 | ... f.write(b'a\n') and None |
|
302 | ... f.write(b'a\n') and None | |
303 | ... f.close() |
|
303 | ... f.close() | |
304 | ... runcommand(server, [b'commit', b'-Amm']) |
|
304 | ... runcommand(server, [b'commit', b'-Amm']) | |
305 | ... runcommand(server, [b'bookmarks']) |
|
305 | ... runcommand(server, [b'bookmarks']) | |
306 | ... bprint(b'') |
|
306 | ... bprint(b'') | |
307 | *** runcommand bookmarks |
|
307 | *** runcommand bookmarks | |
308 | no bookmarks set |
|
308 | no bookmarks set | |
309 | *** runcommand bookmarks |
|
309 | *** runcommand bookmarks | |
310 | bm1 1:d3a0a68be6de |
|
310 | bm1 1:d3a0a68be6de | |
311 | bm2 1:d3a0a68be6de |
|
311 | bm2 1:d3a0a68be6de | |
312 | *** runcommand bookmarks |
|
312 | *** runcommand bookmarks | |
313 | * bm1 1:d3a0a68be6de |
|
313 | * bm1 1:d3a0a68be6de | |
314 | bm2 1:d3a0a68be6de |
|
314 | bm2 1:d3a0a68be6de | |
315 | *** runcommand bookmarks bm3 |
|
315 | *** runcommand bookmarks bm3 | |
316 | *** runcommand commit -Amm |
|
316 | *** runcommand commit -Amm | |
317 | *** runcommand bookmarks |
|
317 | *** runcommand bookmarks | |
318 | bm1 1:d3a0a68be6de |
|
318 | bm1 1:d3a0a68be6de | |
319 | bm2 1:d3a0a68be6de |
|
319 | bm2 1:d3a0a68be6de | |
320 | * bm3 2:aef17e88f5f0 |
|
320 | * bm3 2:aef17e88f5f0 | |
321 |
|
321 | |||
322 |
|
322 | |||
323 | >>> import os |
|
323 | >>> import os | |
324 | >>> from hgclient import check, readchannel, runcommand |
|
324 | >>> from hgclient import check, readchannel, runcommand | |
325 | >>> @check |
|
325 | >>> @check | |
326 | ... def tagscache(server): |
|
326 | ... def tagscache(server): | |
327 | ... readchannel(server) |
|
327 | ... readchannel(server) | |
328 | ... runcommand(server, [b'id', b'-t', b'-r', b'0']) |
|
328 | ... runcommand(server, [b'id', b'-t', b'-r', b'0']) | |
329 | ... os.system('hg tag -r 0 foo') |
|
329 | ... os.system('hg tag -r 0 foo') | |
330 | ... runcommand(server, [b'id', b'-t', b'-r', b'0']) |
|
330 | ... runcommand(server, [b'id', b'-t', b'-r', b'0']) | |
331 | *** runcommand id -t -r 0 |
|
331 | *** runcommand id -t -r 0 | |
332 |
|
332 | |||
333 | *** runcommand id -t -r 0 |
|
333 | *** runcommand id -t -r 0 | |
334 | foo |
|
334 | foo | |
335 |
|
335 | |||
336 | >>> import os |
|
336 | >>> import os | |
337 | >>> from hgclient import check, readchannel, runcommand |
|
337 | >>> from hgclient import check, readchannel, runcommand | |
338 | >>> @check |
|
338 | >>> @check | |
339 | ... def setphase(server): |
|
339 | ... def setphase(server): | |
340 | ... readchannel(server) |
|
340 | ... readchannel(server) | |
341 | ... runcommand(server, [b'phase', b'-r', b'.']) |
|
341 | ... runcommand(server, [b'phase', b'-r', b'.']) | |
342 | ... os.system('hg phase -r . -p') |
|
342 | ... os.system('hg phase -r . -p') | |
343 | ... runcommand(server, [b'phase', b'-r', b'.']) |
|
343 | ... runcommand(server, [b'phase', b'-r', b'.']) | |
344 | *** runcommand phase -r . |
|
344 | *** runcommand phase -r . | |
345 | 3: draft |
|
345 | 3: draft | |
346 | *** runcommand phase -r . |
|
346 | *** runcommand phase -r . | |
347 | 3: public |
|
347 | 3: public | |
348 |
|
348 | |||
349 | $ echo a >> a |
|
349 | $ echo a >> a | |
350 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
350 | >>> from hgclient import bprint, check, readchannel, runcommand | |
351 | >>> @check |
|
351 | >>> @check | |
352 | ... def rollback(server): |
|
352 | ... def rollback(server): | |
353 | ... readchannel(server) |
|
353 | ... readchannel(server) | |
354 | ... runcommand(server, [b'phase', b'-r', b'.', b'-p']) |
|
354 | ... runcommand(server, [b'phase', b'-r', b'.', b'-p']) | |
355 | ... runcommand(server, [b'commit', b'-Am.']) |
|
355 | ... runcommand(server, [b'commit', b'-Am.']) | |
356 | ... runcommand(server, [b'rollback']) |
|
356 | ... runcommand(server, [b'rollback']) | |
357 | ... runcommand(server, [b'phase', b'-r', b'.']) |
|
357 | ... runcommand(server, [b'phase', b'-r', b'.']) | |
358 | ... bprint(b'') |
|
358 | ... bprint(b'') | |
359 | *** runcommand phase -r . -p |
|
359 | *** runcommand phase -r . -p | |
360 | no phases changed |
|
360 | no phases changed | |
361 | *** runcommand commit -Am. |
|
361 | *** runcommand commit -Am. | |
362 | *** runcommand rollback |
|
362 | *** runcommand rollback | |
363 | repository tip rolled back to revision 3 (undo commit) |
|
363 | repository tip rolled back to revision 3 (undo commit) | |
364 | working directory now based on revision 3 |
|
364 | working directory now based on revision 3 | |
365 | *** runcommand phase -r . |
|
365 | *** runcommand phase -r . | |
366 | 3: public |
|
366 | 3: public | |
367 |
|
367 | |||
368 |
|
368 | |||
369 | >>> import os |
|
369 | >>> import os | |
370 | >>> from hgclient import check, readchannel, runcommand |
|
370 | >>> from hgclient import check, readchannel, runcommand | |
371 | >>> @check |
|
371 | >>> @check | |
372 | ... def branch(server): |
|
372 | ... def branch(server): | |
373 | ... readchannel(server) |
|
373 | ... readchannel(server) | |
374 | ... runcommand(server, [b'branch']) |
|
374 | ... runcommand(server, [b'branch']) | |
375 | ... os.system('hg branch foo') |
|
375 | ... os.system('hg branch foo') | |
376 | ... runcommand(server, [b'branch']) |
|
376 | ... runcommand(server, [b'branch']) | |
377 | ... os.system('hg branch default') |
|
377 | ... os.system('hg branch default') | |
378 | *** runcommand branch |
|
378 | *** runcommand branch | |
379 | default |
|
379 | default | |
380 | marked working directory as branch foo |
|
380 | marked working directory as branch foo | |
381 | (branches are permanent and global, did you want a bookmark?) |
|
381 | (branches are permanent and global, did you want a bookmark?) | |
382 | *** runcommand branch |
|
382 | *** runcommand branch | |
383 | foo |
|
383 | foo | |
384 | marked working directory as branch default |
|
384 | marked working directory as branch default | |
385 | (branches are permanent and global, did you want a bookmark?) |
|
385 | (branches are permanent and global, did you want a bookmark?) | |
386 |
|
386 | |||
387 | $ touch .hgignore |
|
387 | $ touch .hgignore | |
388 | >>> import os |
|
388 | >>> import os | |
389 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
389 | >>> from hgclient import bprint, check, readchannel, runcommand | |
390 | >>> @check |
|
390 | >>> @check | |
391 | ... def hgignore(server): |
|
391 | ... def hgignore(server): | |
392 | ... readchannel(server) |
|
392 | ... readchannel(server) | |
393 | ... runcommand(server, [b'commit', b'-Am.']) |
|
393 | ... runcommand(server, [b'commit', b'-Am.']) | |
394 | ... f = open('ignored-file', 'ab') |
|
394 | ... f = open('ignored-file', 'ab') | |
395 | ... f.write(b'') and None |
|
395 | ... f.write(b'') and None | |
396 | ... f.close() |
|
396 | ... f.close() | |
397 | ... f = open('.hgignore', 'ab') |
|
397 | ... f = open('.hgignore', 'ab') | |
398 | ... f.write(b'ignored-file') |
|
398 | ... f.write(b'ignored-file') | |
399 | ... f.close() |
|
399 | ... f.close() | |
400 | ... runcommand(server, [b'status', b'-i', b'-u']) |
|
400 | ... runcommand(server, [b'status', b'-i', b'-u']) | |
401 | ... bprint(b'') |
|
401 | ... bprint(b'') | |
402 | *** runcommand commit -Am. |
|
402 | *** runcommand commit -Am. | |
403 | adding .hgignore |
|
403 | adding .hgignore | |
404 | *** runcommand status -i -u |
|
404 | *** runcommand status -i -u | |
405 | I ignored-file |
|
405 | I ignored-file | |
406 |
|
406 | |||
407 |
|
407 | |||
408 | cache of non-public revisions should be invalidated on repository change |
|
408 | cache of non-public revisions should be invalidated on repository change | |
409 | (issue4855): |
|
409 | (issue4855): | |
410 |
|
410 | |||
411 | >>> import os |
|
411 | >>> import os | |
412 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
412 | >>> from hgclient import bprint, check, readchannel, runcommand | |
413 | >>> @check |
|
413 | >>> @check | |
414 | ... def phasesetscacheaftercommit(server): |
|
414 | ... def phasesetscacheaftercommit(server): | |
415 | ... readchannel(server) |
|
415 | ... readchannel(server) | |
416 | ... # load _phasecache._phaserevs and _phasesets |
|
416 | ... # load _phasecache._phaserevs and _phasesets | |
417 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
417 | ... runcommand(server, [b'log', b'-qr', b'draft()']) | |
418 | ... # create draft commits by another process |
|
418 | ... # create draft commits by another process | |
419 | ... for i in range(5, 7): |
|
419 | ... for i in range(5, 7): | |
420 | ... f = open('a', 'ab') |
|
420 | ... f = open('a', 'ab') | |
421 | ... f.seek(0, os.SEEK_END) |
|
421 | ... f.seek(0, os.SEEK_END) | |
422 | ... f.write(b'a\n') and None |
|
422 | ... f.write(b'a\n') and None | |
423 | ... f.close() |
|
423 | ... f.close() | |
424 | ... os.system('hg commit -Aqm%d' % i) |
|
424 | ... os.system('hg commit -Aqm%d' % i) | |
425 | ... # new commits should be listed as draft revisions |
|
425 | ... # new commits should be listed as draft revisions | |
426 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
426 | ... runcommand(server, [b'log', b'-qr', b'draft()']) | |
427 | ... bprint(b'') |
|
427 | ... bprint(b'') | |
428 | *** runcommand log -qr draft() |
|
428 | *** runcommand log -qr draft() | |
429 | 4:7966c8e3734d |
|
429 | 4:7966c8e3734d | |
430 | *** runcommand log -qr draft() |
|
430 | *** runcommand log -qr draft() | |
431 | 4:7966c8e3734d |
|
431 | 4:7966c8e3734d | |
432 | 5:41f6602d1c4f |
|
432 | 5:41f6602d1c4f | |
433 | 6:10501e202c35 |
|
433 | 6:10501e202c35 | |
434 |
|
434 | |||
435 |
|
435 | |||
436 | >>> import os |
|
436 | >>> import os | |
437 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
437 | >>> from hgclient import bprint, check, readchannel, runcommand | |
438 | >>> @check |
|
438 | >>> @check | |
439 | ... def phasesetscacheafterstrip(server): |
|
439 | ... def phasesetscacheafterstrip(server): | |
440 | ... readchannel(server) |
|
440 | ... readchannel(server) | |
441 | ... # load _phasecache._phaserevs and _phasesets |
|
441 | ... # load _phasecache._phaserevs and _phasesets | |
442 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
442 | ... runcommand(server, [b'log', b'-qr', b'draft()']) | |
443 | ... # strip cached revisions by another process |
|
443 | ... # strip cached revisions by another process | |
444 | ... os.system('hg --config extensions.strip= strip -q 5') |
|
444 | ... os.system('hg --config extensions.strip= strip -q 5') | |
445 | ... # shouldn't abort by "unknown revision '6'" |
|
445 | ... # shouldn't abort by "unknown revision '6'" | |
446 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
446 | ... runcommand(server, [b'log', b'-qr', b'draft()']) | |
447 | ... bprint(b'') |
|
447 | ... bprint(b'') | |
448 | *** runcommand log -qr draft() |
|
448 | *** runcommand log -qr draft() | |
449 | 4:7966c8e3734d |
|
449 | 4:7966c8e3734d | |
450 | 5:41f6602d1c4f |
|
450 | 5:41f6602d1c4f | |
451 | 6:10501e202c35 |
|
451 | 6:10501e202c35 | |
452 | *** runcommand log -qr draft() |
|
452 | *** runcommand log -qr draft() | |
453 | 4:7966c8e3734d |
|
453 | 4:7966c8e3734d | |
454 |
|
454 | |||
455 |
|
455 | |||
456 | cache of phase roots should be invalidated on strip (issue3827): |
|
456 | cache of phase roots should be invalidated on strip (issue3827): | |
457 |
|
457 | |||
458 | >>> import os |
|
458 | >>> import os | |
459 | >>> from hgclient import check, readchannel, runcommand, sep |
|
459 | >>> from hgclient import check, readchannel, runcommand, sep | |
460 | >>> @check |
|
460 | >>> @check | |
461 | ... def phasecacheafterstrip(server): |
|
461 | ... def phasecacheafterstrip(server): | |
462 | ... readchannel(server) |
|
462 | ... readchannel(server) | |
463 | ... |
|
463 | ... | |
464 | ... # create new head, 5:731265503d86 |
|
464 | ... # create new head, 5:731265503d86 | |
465 | ... runcommand(server, [b'update', b'-C', b'0']) |
|
465 | ... runcommand(server, [b'update', b'-C', b'0']) | |
466 | ... f = open('a', 'ab') |
|
466 | ... f = open('a', 'ab') | |
467 | ... f.write(b'a\n') and None |
|
467 | ... f.write(b'a\n') and None | |
468 | ... f.close() |
|
468 | ... f.close() | |
469 | ... runcommand(server, [b'commit', b'-Am.', b'a']) |
|
469 | ... runcommand(server, [b'commit', b'-Am.', b'a']) | |
470 | ... runcommand(server, [b'log', b'-Gq']) |
|
470 | ... runcommand(server, [b'log', b'-Gq']) | |
471 | ... |
|
471 | ... | |
472 | ... # make it public; draft marker moves to 4:7966c8e3734d |
|
472 | ... # make it public; draft marker moves to 4:7966c8e3734d | |
473 | ... runcommand(server, [b'phase', b'-p', b'.']) |
|
473 | ... runcommand(server, [b'phase', b'-p', b'.']) | |
474 | ... # load _phasecache.phaseroots |
|
474 | ... # load _phasecache.phaseroots | |
475 | ... runcommand(server, [b'phase', b'.'], outfilter=sep) |
|
475 | ... runcommand(server, [b'phase', b'.'], outfilter=sep) | |
476 | ... |
|
476 | ... | |
477 | ... # strip 1::4 outside server |
|
477 | ... # strip 1::4 outside server | |
478 | ... os.system('hg -q --config extensions.mq= strip 1') |
|
478 | ... os.system('hg -q --config extensions.mq= strip 1') | |
479 | ... |
|
479 | ... | |
480 | ... # shouldn't raise "7966c8e3734d: no node!" |
|
480 | ... # shouldn't raise "7966c8e3734d: no node!" | |
481 | ... runcommand(server, [b'branches']) |
|
481 | ... runcommand(server, [b'branches']) | |
482 | *** runcommand update -C 0 |
|
482 | *** runcommand update -C 0 | |
483 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
483 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
484 | (leaving bookmark bm3) |
|
484 | (leaving bookmark bm3) | |
485 | *** runcommand commit -Am. a |
|
485 | *** runcommand commit -Am. a | |
486 | created new head |
|
486 | created new head | |
487 | *** runcommand log -Gq |
|
487 | *** runcommand log -Gq | |
488 | @ 5:731265503d86 |
|
488 | @ 5:731265503d86 | |
489 | | |
|
489 | | | |
490 | | o 4:7966c8e3734d |
|
490 | | o 4:7966c8e3734d | |
491 | | | |
|
491 | | | | |
492 | | o 3:b9b85890c400 |
|
492 | | o 3:b9b85890c400 | |
493 | | | |
|
493 | | | | |
494 | | o 2:aef17e88f5f0 |
|
494 | | o 2:aef17e88f5f0 | |
495 | | | |
|
495 | | | | |
496 | | o 1:d3a0a68be6de |
|
496 | | o 1:d3a0a68be6de | |
497 | |/ |
|
497 | |/ | |
498 | o 0:eff892de26ec |
|
498 | o 0:eff892de26ec | |
499 |
|
499 | |||
500 | *** runcommand phase -p . |
|
500 | *** runcommand phase -p . | |
501 | *** runcommand phase . |
|
501 | *** runcommand phase . | |
502 | 5: public |
|
502 | 5: public | |
503 | *** runcommand branches |
|
503 | *** runcommand branches | |
504 | default 1:731265503d86 |
|
504 | default 1:731265503d86 | |
505 |
|
505 | |||
506 | in-memory cache must be reloaded if transaction is aborted. otherwise |
|
506 | in-memory cache must be reloaded if transaction is aborted. otherwise | |
507 | changelog and manifest would have invalid node: |
|
507 | changelog and manifest would have invalid node: | |
508 |
|
508 | |||
509 | $ echo a >> a |
|
509 | $ echo a >> a | |
510 | >>> from hgclient import check, readchannel, runcommand |
|
510 | >>> from hgclient import check, readchannel, runcommand | |
511 | >>> @check |
|
511 | >>> @check | |
512 | ... def txabort(server): |
|
512 | ... def txabort(server): | |
513 | ... readchannel(server) |
|
513 | ... readchannel(server) | |
514 | ... runcommand(server, [b'commit', b'--config', b'hooks.pretxncommit=false', |
|
514 | ... runcommand(server, [b'commit', b'--config', b'hooks.pretxncommit=false', | |
515 | ... b'-mfoo']) |
|
515 | ... b'-mfoo']) | |
516 | ... runcommand(server, [b'verify']) |
|
516 | ... runcommand(server, [b'verify']) | |
517 | *** runcommand commit --config hooks.pretxncommit=false -mfoo |
|
517 | *** runcommand commit --config hooks.pretxncommit=false -mfoo | |
518 | transaction abort! |
|
518 | transaction abort! | |
519 | rollback completed |
|
519 | rollback completed | |
520 | abort: pretxncommit hook exited with status 1 |
|
520 | abort: pretxncommit hook exited with status 1 | |
521 | [255] |
|
521 | [255] | |
522 | *** runcommand verify |
|
522 | *** runcommand verify | |
523 | checking changesets |
|
523 | checking changesets | |
524 | checking manifests |
|
524 | checking manifests | |
525 | crosschecking files in changesets and manifests |
|
525 | crosschecking files in changesets and manifests | |
526 | checking files |
|
526 | checking files | |
527 | checked 2 changesets with 2 changes to 1 files |
|
527 | checked 2 changesets with 2 changes to 1 files | |
528 | $ hg revert --no-backup -aq |
|
528 | $ hg revert --no-backup -aq | |
529 |
|
529 | |||
530 | $ cat >> .hg/hgrc << EOF |
|
530 | $ cat >> .hg/hgrc << EOF | |
531 | > [experimental] |
|
531 | > [experimental] | |
532 | > evolution.createmarkers=True |
|
532 | > evolution.createmarkers=True | |
533 | > EOF |
|
533 | > EOF | |
534 |
|
534 | |||
535 | >>> import os |
|
535 | >>> import os | |
536 | >>> from hgclient import check, readchannel, runcommand |
|
536 | >>> from hgclient import check, readchannel, runcommand | |
537 | >>> @check |
|
537 | >>> @check | |
538 | ... def obsolete(server): |
|
538 | ... def obsolete(server): | |
539 | ... readchannel(server) |
|
539 | ... readchannel(server) | |
540 | ... |
|
540 | ... | |
541 | ... runcommand(server, [b'up', b'null']) |
|
541 | ... runcommand(server, [b'up', b'null']) | |
542 | ... runcommand(server, [b'phase', b'-df', b'tip']) |
|
542 | ... runcommand(server, [b'phase', b'-df', b'tip']) | |
543 | ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`' |
|
543 | ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`' | |
544 | ... if os.name == 'nt': |
|
544 | ... if os.name == 'nt': | |
545 | ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe |
|
545 | ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe | |
546 | ... os.system(cmd) |
|
546 | ... os.system(cmd) | |
547 | ... runcommand(server, [b'log', b'--hidden']) |
|
547 | ... runcommand(server, [b'log', b'--hidden']) | |
548 | ... runcommand(server, [b'log']) |
|
548 | ... runcommand(server, [b'log']) | |
549 | *** runcommand up null |
|
549 | *** runcommand up null | |
550 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
550 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
551 | *** runcommand phase -df tip |
|
551 | *** runcommand phase -df tip | |
552 | obsoleted 1 changesets |
|
552 | obsoleted 1 changesets | |
553 | *** runcommand log --hidden |
|
553 | *** runcommand log --hidden | |
554 | changeset: 1:731265503d86 |
|
554 | changeset: 1:731265503d86 | |
555 | tag: tip |
|
555 | tag: tip | |
556 | user: test |
|
556 | user: test | |
557 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
557 | date: Thu Jan 01 00:00:00 1970 +0000 | |
558 | obsolete: pruned |
|
558 | obsolete: pruned | |
559 | summary: . |
|
559 | summary: . | |
560 |
|
560 | |||
561 | changeset: 0:eff892de26ec |
|
561 | changeset: 0:eff892de26ec | |
562 | bookmark: bm1 |
|
562 | bookmark: bm1 | |
563 | bookmark: bm2 |
|
563 | bookmark: bm2 | |
564 | bookmark: bm3 |
|
564 | bookmark: bm3 | |
565 | user: test |
|
565 | user: test | |
566 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
566 | date: Thu Jan 01 00:00:00 1970 +0000 | |
567 | summary: 1 |
|
567 | summary: 1 | |
568 |
|
568 | |||
569 | *** runcommand log |
|
569 | *** runcommand log | |
570 | changeset: 0:eff892de26ec |
|
570 | changeset: 0:eff892de26ec | |
571 | bookmark: bm1 |
|
571 | bookmark: bm1 | |
572 | bookmark: bm2 |
|
572 | bookmark: bm2 | |
573 | bookmark: bm3 |
|
573 | bookmark: bm3 | |
574 | tag: tip |
|
574 | tag: tip | |
575 | user: test |
|
575 | user: test | |
576 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
576 | date: Thu Jan 01 00:00:00 1970 +0000 | |
577 | summary: 1 |
|
577 | summary: 1 | |
578 |
|
578 | |||
579 |
|
579 | |||
580 | $ cat <<EOF >> .hg/hgrc |
|
580 | $ cat <<EOF >> .hg/hgrc | |
581 | > [extensions] |
|
581 | > [extensions] | |
582 | > mq = |
|
582 | > mq = | |
583 | > EOF |
|
583 | > EOF | |
584 |
|
584 | |||
585 | >>> import os |
|
585 | >>> import os | |
586 | >>> from hgclient import check, readchannel, runcommand |
|
586 | >>> from hgclient import check, readchannel, runcommand | |
587 | >>> @check |
|
587 | >>> @check | |
588 | ... def mqoutsidechanges(server): |
|
588 | ... def mqoutsidechanges(server): | |
589 | ... readchannel(server) |
|
589 | ... readchannel(server) | |
590 | ... |
|
590 | ... | |
591 | ... # load repo.mq |
|
591 | ... # load repo.mq | |
592 | ... runcommand(server, [b'qapplied']) |
|
592 | ... runcommand(server, [b'qapplied']) | |
593 | ... os.system('hg qnew 0.diff') |
|
593 | ... os.system('hg qnew 0.diff') | |
594 | ... # repo.mq should be invalidated |
|
594 | ... # repo.mq should be invalidated | |
595 | ... runcommand(server, [b'qapplied']) |
|
595 | ... runcommand(server, [b'qapplied']) | |
596 | ... |
|
596 | ... | |
597 | ... runcommand(server, [b'qpop', b'--all']) |
|
597 | ... runcommand(server, [b'qpop', b'--all']) | |
598 | ... os.system('hg qqueue --create foo') |
|
598 | ... os.system('hg qqueue --create foo') | |
599 | ... # repo.mq should be recreated to point to new queue |
|
599 | ... # repo.mq should be recreated to point to new queue | |
600 | ... runcommand(server, [b'qqueue', b'--active']) |
|
600 | ... runcommand(server, [b'qqueue', b'--active']) | |
601 | *** runcommand qapplied |
|
601 | *** runcommand qapplied | |
602 | *** runcommand qapplied |
|
602 | *** runcommand qapplied | |
603 | 0.diff |
|
603 | 0.diff | |
604 | *** runcommand qpop --all |
|
604 | *** runcommand qpop --all | |
605 | popping 0.diff |
|
605 | popping 0.diff | |
606 | patch queue now empty |
|
606 | patch queue now empty | |
607 | *** runcommand qqueue --active |
|
607 | *** runcommand qqueue --active | |
608 | foo |
|
608 | foo | |
609 |
|
609 | |||
610 | $ cat <<EOF > dbgui.py |
|
610 | $ cat <<'EOF' > ../dbgui.py | |
611 | > import os |
|
611 | > import os | |
612 | > import sys |
|
612 | > import sys | |
613 | > from mercurial import commands, registrar |
|
613 | > from mercurial import commands, registrar | |
614 | > cmdtable = {} |
|
614 | > cmdtable = {} | |
615 | > command = registrar.command(cmdtable) |
|
615 | > command = registrar.command(cmdtable) | |
616 | > @command(b"debuggetpass", norepo=True) |
|
616 | > @command(b"debuggetpass", norepo=True) | |
617 | > def debuggetpass(ui): |
|
617 | > def debuggetpass(ui): | |
618 |
> ui.write(b"%s |
|
618 | > ui.write(b"%s\n" % ui.getpass()) | |
619 | > @command(b"debugprompt", norepo=True) |
|
619 | > @command(b"debugprompt", norepo=True) | |
620 | > def debugprompt(ui): |
|
620 | > def debugprompt(ui): | |
621 |
> ui.write(b"%s |
|
621 | > ui.write(b"%s\n" % ui.prompt(b"prompt:")) | |
622 | > @command(b"debugreadstdin", norepo=True) |
|
622 | > @command(b"debugreadstdin", norepo=True) | |
623 | > def debugreadstdin(ui): |
|
623 | > def debugreadstdin(ui): | |
624 | > ui.write(b"read: %r\n" % sys.stdin.read(1)) |
|
624 | > ui.write(b"read: %r\n" % sys.stdin.read(1)) | |
625 | > @command(b"debugwritestdout", norepo=True) |
|
625 | > @command(b"debugwritestdout", norepo=True) | |
626 | > def debugwritestdout(ui): |
|
626 | > def debugwritestdout(ui): | |
627 | > os.write(1, b"low-level stdout fd and\n") |
|
627 | > os.write(1, b"low-level stdout fd and\n") | |
628 | > sys.stdout.write("stdout should be redirected to stderr\n") |
|
628 | > sys.stdout.write("stdout should be redirected to stderr\n") | |
629 | > sys.stdout.flush() |
|
629 | > sys.stdout.flush() | |
630 | > EOF |
|
630 | > EOF | |
631 | $ cat <<EOF >> .hg/hgrc |
|
631 | $ cat <<EOF >> .hg/hgrc | |
632 | > [extensions] |
|
632 | > [extensions] | |
633 | > dbgui = dbgui.py |
|
633 | > dbgui = ../dbgui.py | |
634 | > EOF |
|
634 | > EOF | |
635 |
|
635 | |||
636 | >>> from hgclient import check, readchannel, runcommand, stringio |
|
636 | >>> from hgclient import check, readchannel, runcommand, stringio | |
637 | >>> @check |
|
637 | >>> @check | |
638 | ... def getpass(server): |
|
638 | ... def getpass(server): | |
639 | ... readchannel(server) |
|
639 | ... readchannel(server) | |
640 | ... runcommand(server, [b'debuggetpass', b'--config', |
|
640 | ... runcommand(server, [b'debuggetpass', b'--config', | |
641 | ... b'ui.interactive=True'], |
|
641 | ... b'ui.interactive=True'], | |
642 | ... input=stringio(b'1234\n')) |
|
642 | ... input=stringio(b'1234\n')) | |
643 | ... runcommand(server, [b'debuggetpass', b'--config', |
|
643 | ... runcommand(server, [b'debuggetpass', b'--config', | |
644 | ... b'ui.interactive=True'], |
|
644 | ... b'ui.interactive=True'], | |
645 | ... input=stringio(b'\n')) |
|
645 | ... input=stringio(b'\n')) | |
646 | ... runcommand(server, [b'debuggetpass', b'--config', |
|
646 | ... runcommand(server, [b'debuggetpass', b'--config', | |
647 | ... b'ui.interactive=True'], |
|
647 | ... b'ui.interactive=True'], | |
648 | ... input=stringio(b'')) |
|
648 | ... input=stringio(b'')) | |
649 | ... runcommand(server, [b'debugprompt', b'--config', |
|
649 | ... runcommand(server, [b'debugprompt', b'--config', | |
650 | ... b'ui.interactive=True'], |
|
650 | ... b'ui.interactive=True'], | |
651 | ... input=stringio(b'5678\n')) |
|
651 | ... input=stringio(b'5678\n')) | |
652 | ... runcommand(server, [b'debugreadstdin']) |
|
652 | ... runcommand(server, [b'debugreadstdin']) | |
653 | ... runcommand(server, [b'debugwritestdout']) |
|
653 | ... runcommand(server, [b'debugwritestdout']) | |
654 | *** runcommand debuggetpass --config ui.interactive=True |
|
654 | *** runcommand debuggetpass --config ui.interactive=True | |
655 | password: 1234 |
|
655 | password: 1234 | |
656 | *** runcommand debuggetpass --config ui.interactive=True |
|
656 | *** runcommand debuggetpass --config ui.interactive=True | |
657 | password: |
|
657 | password: | |
658 | *** runcommand debuggetpass --config ui.interactive=True |
|
658 | *** runcommand debuggetpass --config ui.interactive=True | |
659 | password: abort: response expected |
|
659 | password: abort: response expected | |
660 | [255] |
|
660 | [255] | |
661 | *** runcommand debugprompt --config ui.interactive=True |
|
661 | *** runcommand debugprompt --config ui.interactive=True | |
662 | prompt: 5678 |
|
662 | prompt: 5678 | |
663 | *** runcommand debugreadstdin |
|
663 | *** runcommand debugreadstdin | |
664 | read: '' |
|
664 | read: '' | |
665 | *** runcommand debugwritestdout |
|
665 | *** runcommand debugwritestdout | |
666 | low-level stdout fd and |
|
666 | low-level stdout fd and | |
667 | stdout should be redirected to stderr |
|
667 | stdout should be redirected to stderr | |
668 |
|
668 | |||
669 |
|
669 | |||
670 | run commandserver in commandserver, which is silly but should work: |
|
670 | run commandserver in commandserver, which is silly but should work: | |
671 |
|
671 | |||
672 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio |
|
672 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio | |
673 | >>> @check |
|
673 | >>> @check | |
674 | ... def nested(server): |
|
674 | ... def nested(server): | |
675 | ... bprint(b'%c, %r' % readchannel(server)) |
|
675 | ... bprint(b'%c, %r' % readchannel(server)) | |
676 | ... class nestedserver(object): |
|
676 | ... class nestedserver(object): | |
677 | ... stdin = stringio(b'getencoding\n') |
|
677 | ... stdin = stringio(b'getencoding\n') | |
678 | ... stdout = stringio() |
|
678 | ... stdout = stringio() | |
679 | ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'], |
|
679 | ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'], | |
680 | ... output=nestedserver.stdout, input=nestedserver.stdin) |
|
680 | ... output=nestedserver.stdout, input=nestedserver.stdin) | |
681 | ... nestedserver.stdout.seek(0) |
|
681 | ... nestedserver.stdout.seek(0) | |
682 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello |
|
682 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello | |
683 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding |
|
683 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding | |
684 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
684 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) | |
685 | *** runcommand serve --cmdserver pipe |
|
685 | *** runcommand serve --cmdserver pipe | |
686 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
686 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) | |
687 | r, '*' (glob) |
|
687 | r, '*' (glob) | |
688 |
|
688 | |||
689 |
|
689 | |||
690 | start without repository: |
|
690 | start without repository: | |
691 |
|
691 | |||
692 | $ cd .. |
|
692 | $ cd .. | |
693 |
|
693 | |||
694 | >>> from hgclient import bprint, check, readchannel, runcommand |
|
694 | >>> from hgclient import bprint, check, readchannel, runcommand | |
695 | >>> @check |
|
695 | >>> @check | |
696 | ... def hellomessage(server): |
|
696 | ... def hellomessage(server): | |
697 | ... ch, data = readchannel(server) |
|
697 | ... ch, data = readchannel(server) | |
698 | ... bprint(b'%c, %r' % (ch, data)) |
|
698 | ... bprint(b'%c, %r' % (ch, data)) | |
699 | ... # run an arbitrary command to make sure the next thing the server |
|
699 | ... # run an arbitrary command to make sure the next thing the server | |
700 | ... # sends isn't part of the hello message |
|
700 | ... # sends isn't part of the hello message | |
701 | ... runcommand(server, [b'id']) |
|
701 | ... runcommand(server, [b'id']) | |
702 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
702 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) | |
703 | *** runcommand id |
|
703 | *** runcommand id | |
704 | abort: there is no Mercurial repository here (.hg not found) |
|
704 | abort: there is no Mercurial repository here (.hg not found) | |
705 | [255] |
|
705 | [255] | |
706 |
|
706 | |||
707 | >>> from hgclient import check, readchannel, runcommand |
|
707 | >>> from hgclient import check, readchannel, runcommand | |
708 | >>> @check |
|
708 | >>> @check | |
709 | ... def startwithoutrepo(server): |
|
709 | ... def startwithoutrepo(server): | |
710 | ... readchannel(server) |
|
710 | ... readchannel(server) | |
711 | ... runcommand(server, [b'init', b'repo2']) |
|
711 | ... runcommand(server, [b'init', b'repo2']) | |
712 | ... runcommand(server, [b'id', b'-R', b'repo2']) |
|
712 | ... runcommand(server, [b'id', b'-R', b'repo2']) | |
713 | *** runcommand init repo2 |
|
713 | *** runcommand init repo2 | |
714 | *** runcommand id -R repo2 |
|
714 | *** runcommand id -R repo2 | |
715 | 000000000000 tip |
|
715 | 000000000000 tip | |
716 |
|
716 | |||
717 |
|
717 | |||
718 | don't fall back to cwd if invalid -R path is specified (issue4805): |
|
718 | don't fall back to cwd if invalid -R path is specified (issue4805): | |
719 |
|
719 | |||
720 | $ cd repo |
|
720 | $ cd repo | |
721 | $ hg serve --cmdserver pipe -R ../nonexistent |
|
721 | $ hg serve --cmdserver pipe -R ../nonexistent | |
722 | abort: repository ../nonexistent not found! |
|
722 | abort: repository ../nonexistent not found! | |
723 | [255] |
|
723 | [255] | |
724 | $ cd .. |
|
724 | $ cd .. | |
725 |
|
725 | |||
726 |
|
726 | |||
727 | structured message channel: |
|
727 | structured message channel: | |
728 |
|
728 | |||
729 | $ cat <<'EOF' >> repo2/.hg/hgrc |
|
729 | $ cat <<'EOF' >> repo2/.hg/hgrc | |
730 | > [ui] |
|
730 | > [ui] | |
731 | > # server --config should precede repository option |
|
731 | > # server --config should precede repository option | |
732 | > message-output = stdio |
|
732 | > message-output = stdio | |
733 | > EOF |
|
733 | > EOF | |
734 |
|
734 | |||
735 | >>> from hgclient import bprint, checkwith, readchannel, runcommand |
|
735 | >>> from hgclient import bprint, checkwith, readchannel, runcommand | |
736 | >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel', |
|
736 | >>> @checkwith(extraargs=[b'--config', b'ui.message-output=channel', | |
737 | ... b'--config', b'cmdserver.message-encodings=foo cbor']) |
|
737 | ... b'--config', b'cmdserver.message-encodings=foo cbor']) | |
738 | ... def verify(server): |
|
738 | ... def verify(server): | |
739 | ... _ch, data = readchannel(server) |
|
739 | ... _ch, data = readchannel(server) | |
740 | ... bprint(data) |
|
740 | ... bprint(data) | |
741 | ... runcommand(server, [b'-R', b'repo2', b'verify']) |
|
741 | ... runcommand(server, [b'-R', b'repo2', b'verify']) | |
742 | capabilities: getencoding runcommand |
|
742 | capabilities: getencoding runcommand | |
743 | encoding: ascii |
|
743 | encoding: ascii | |
744 | message-encoding: cbor |
|
744 | message-encoding: cbor | |
745 | pid: * (glob) |
|
745 | pid: * (glob) | |
746 | pgid: * (glob) |
|
746 | pgid: * (glob) | |
747 | *** runcommand -R repo2 verify |
|
747 | *** runcommand -R repo2 verify | |
748 | message: '\xa2DdataTchecking changesets\nDtypeFstatus' |
|
748 | message: '\xa2DdataTchecking changesets\nDtypeFstatus' | |
749 | message: '\xa2DdataSchecking manifests\nDtypeFstatus' |
|
749 | message: '\xa2DdataSchecking manifests\nDtypeFstatus' | |
750 | message: '\xa2DdataX0crosschecking files in changesets and manifests\nDtypeFstatus' |
|
750 | message: '\xa2DdataX0crosschecking files in changesets and manifests\nDtypeFstatus' | |
751 | message: '\xa2DdataOchecking files\nDtypeFstatus' |
|
751 | message: '\xa2DdataOchecking files\nDtypeFstatus' | |
752 | message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus' |
|
752 | message: '\xa2DdataX/checked 0 changesets with 0 changes to 0 files\nDtypeFstatus' | |
753 |
|
753 | |||
754 | bad message encoding: |
|
754 | bad message encoding: | |
755 |
|
755 | |||
756 | $ hg serve --cmdserver pipe --config ui.message-output=channel |
|
756 | $ hg serve --cmdserver pipe --config ui.message-output=channel | |
757 | abort: no supported message encodings: |
|
757 | abort: no supported message encodings: | |
758 | [255] |
|
758 | [255] | |
759 | $ hg serve --cmdserver pipe --config ui.message-output=channel \ |
|
759 | $ hg serve --cmdserver pipe --config ui.message-output=channel \ | |
760 | > --config cmdserver.message-encodings='foo bar' |
|
760 | > --config cmdserver.message-encodings='foo bar' | |
761 | abort: no supported message encodings: foo bar |
|
761 | abort: no supported message encodings: foo bar | |
762 | [255] |
|
762 | [255] | |
763 |
|
763 | |||
764 | unix domain socket: |
|
764 | unix domain socket: | |
765 |
|
765 | |||
766 | $ cd repo |
|
766 | $ cd repo | |
767 | $ hg update -q |
|
767 | $ hg update -q | |
768 |
|
768 | |||
769 | #if unix-socket unix-permissions |
|
769 | #if unix-socket unix-permissions | |
770 |
|
770 | |||
771 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver |
|
771 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver | |
772 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') |
|
772 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') | |
773 | >>> def hellomessage(conn): |
|
773 | >>> def hellomessage(conn): | |
774 | ... ch, data = readchannel(conn) |
|
774 | ... ch, data = readchannel(conn) | |
775 | ... bprint(b'%c, %r' % (ch, data)) |
|
775 | ... bprint(b'%c, %r' % (ch, data)) | |
776 | ... runcommand(conn, [b'id']) |
|
776 | ... runcommand(conn, [b'id']) | |
777 | >>> check(hellomessage, server.connect) |
|
777 | >>> check(hellomessage, server.connect) | |
778 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
778 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) | |
779 | *** runcommand id |
|
779 | *** runcommand id | |
780 | eff892de26ec tip bm1/bm2/bm3 |
|
780 | eff892de26ec tip bm1/bm2/bm3 | |
781 | >>> def unknowncommand(conn): |
|
781 | >>> def unknowncommand(conn): | |
782 | ... readchannel(conn) |
|
782 | ... readchannel(conn) | |
783 | ... conn.stdin.write(b'unknowncommand\n') |
|
783 | ... conn.stdin.write(b'unknowncommand\n') | |
784 | >>> check(unknowncommand, server.connect) # error sent to server.log |
|
784 | >>> check(unknowncommand, server.connect) # error sent to server.log | |
785 | >>> def serverinput(conn): |
|
785 | >>> def serverinput(conn): | |
786 | ... readchannel(conn) |
|
786 | ... readchannel(conn) | |
787 | ... patch = b""" |
|
787 | ... patch = b""" | |
788 | ... # HG changeset patch |
|
788 | ... # HG changeset patch | |
789 | ... # User test |
|
789 | ... # User test | |
790 | ... # Date 0 0 |
|
790 | ... # Date 0 0 | |
791 | ... 2 |
|
791 | ... 2 | |
792 | ... |
|
792 | ... | |
793 | ... diff -r eff892de26ec -r 1ed24be7e7a0 a |
|
793 | ... diff -r eff892de26ec -r 1ed24be7e7a0 a | |
794 | ... --- a/a |
|
794 | ... --- a/a | |
795 | ... +++ b/a |
|
795 | ... +++ b/a | |
796 | ... @@ -1,1 +1,2 @@ |
|
796 | ... @@ -1,1 +1,2 @@ | |
797 | ... 1 |
|
797 | ... 1 | |
798 | ... +2 |
|
798 | ... +2 | |
799 | ... """ |
|
799 | ... """ | |
800 | ... runcommand(conn, [b'import', b'-'], input=stringio(patch)) |
|
800 | ... runcommand(conn, [b'import', b'-'], input=stringio(patch)) | |
801 | ... runcommand(conn, [b'log', b'-rtip', b'-q']) |
|
801 | ... runcommand(conn, [b'log', b'-rtip', b'-q']) | |
802 | >>> check(serverinput, server.connect) |
|
802 | >>> check(serverinput, server.connect) | |
803 | *** runcommand import - |
|
803 | *** runcommand import - | |
804 | applying patch from stdin |
|
804 | applying patch from stdin | |
805 | *** runcommand log -rtip -q |
|
805 | *** runcommand log -rtip -q | |
806 | 2:1ed24be7e7a0 |
|
806 | 2:1ed24be7e7a0 | |
807 | >>> server.shutdown() |
|
807 | >>> server.shutdown() | |
808 |
|
808 | |||
809 | $ cat .hg/server.log |
|
809 | $ cat .hg/server.log | |
810 | listening at .hg/server.sock |
|
810 | listening at .hg/server.sock | |
811 | abort: unknown command unknowncommand |
|
811 | abort: unknown command unknowncommand | |
812 | killed! |
|
812 | killed! | |
813 | $ rm .hg/server.log |
|
813 | $ rm .hg/server.log | |
814 |
|
814 | |||
815 | if server crashed before hello, traceback will be sent to 'e' channel as |
|
815 | if server crashed before hello, traceback will be sent to 'e' channel as | |
816 | last ditch: |
|
816 | last ditch: | |
817 |
|
817 | |||
818 | $ cat <<EOF >> .hg/hgrc |
|
818 | $ cat <<EOF >> .hg/hgrc | |
819 | > [cmdserver] |
|
819 | > [cmdserver] | |
820 | > log = inexistent/path.log |
|
820 | > log = inexistent/path.log | |
821 | > EOF |
|
821 | > EOF | |
822 | >>> from hgclient import bprint, check, readchannel, unixserver |
|
822 | >>> from hgclient import bprint, check, readchannel, unixserver | |
823 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') |
|
823 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') | |
824 | >>> def earlycrash(conn): |
|
824 | >>> def earlycrash(conn): | |
825 | ... while True: |
|
825 | ... while True: | |
826 | ... try: |
|
826 | ... try: | |
827 | ... ch, data = readchannel(conn) |
|
827 | ... ch, data = readchannel(conn) | |
828 | ... for l in data.splitlines(True): |
|
828 | ... for l in data.splitlines(True): | |
829 | ... if not l.startswith(b' '): |
|
829 | ... if not l.startswith(b' '): | |
830 | ... bprint(b'%c, %r' % (ch, l)) |
|
830 | ... bprint(b'%c, %r' % (ch, l)) | |
831 | ... except EOFError: |
|
831 | ... except EOFError: | |
832 | ... break |
|
832 | ... break | |
833 | >>> check(earlycrash, server.connect) |
|
833 | >>> check(earlycrash, server.connect) | |
834 | e, 'Traceback (most recent call last):\n' |
|
834 | e, 'Traceback (most recent call last):\n' | |
835 | e, "(IOError|FileNotFoundError): .*" (re) |
|
835 | e, "(IOError|FileNotFoundError): .*" (re) | |
836 | >>> server.shutdown() |
|
836 | >>> server.shutdown() | |
837 |
|
837 | |||
838 | $ cat .hg/server.log | grep -v '^ ' |
|
838 | $ cat .hg/server.log | grep -v '^ ' | |
839 | listening at .hg/server.sock |
|
839 | listening at .hg/server.sock | |
840 | Traceback (most recent call last): |
|
840 | Traceback (most recent call last): | |
841 | (IOError|FileNotFoundError): .* (re) |
|
841 | (IOError|FileNotFoundError): .* (re) | |
842 | killed! |
|
842 | killed! | |
843 | #endif |
|
843 | #endif | |
844 | #if no-unix-socket |
|
844 | #if no-unix-socket | |
845 |
|
845 | |||
846 | $ hg serve --cmdserver unix -a .hg/server.sock |
|
846 | $ hg serve --cmdserver unix -a .hg/server.sock | |
847 | abort: unsupported platform |
|
847 | abort: unsupported platform | |
848 | [255] |
|
848 | [255] | |
849 |
|
849 | |||
850 | #endif |
|
850 | #endif | |
851 |
|
851 | |||
852 | $ cd .. |
|
852 | $ cd .. | |
853 |
|
853 | |||
854 | Test that accessing to invalid changelog cache is avoided at |
|
854 | Test that accessing to invalid changelog cache is avoided at | |
855 | subsequent operations even if repo object is reused even after failure |
|
855 | subsequent operations even if repo object is reused even after failure | |
856 | of transaction (see 0a7610758c42 also) |
|
856 | of transaction (see 0a7610758c42 also) | |
857 |
|
857 | |||
858 | "hg log" after failure of transaction is needed to detect invalid |
|
858 | "hg log" after failure of transaction is needed to detect invalid | |
859 | cache in repoview: this can't detect by "hg verify" only. |
|
859 | cache in repoview: this can't detect by "hg verify" only. | |
860 |
|
860 | |||
861 | Combination of "finalization" and "empty-ness of changelog" (2 x 2 = |
|
861 | Combination of "finalization" and "empty-ness of changelog" (2 x 2 = | |
862 | 4) are tested, because '00changelog.i' are differently changed in each |
|
862 | 4) are tested, because '00changelog.i' are differently changed in each | |
863 | cases. |
|
863 | cases. | |
864 |
|
864 | |||
865 | $ cat > $TESTTMP/failafterfinalize.py <<EOF |
|
865 | $ cat > $TESTTMP/failafterfinalize.py <<EOF | |
866 | > # extension to abort transaction after finalization forcibly |
|
866 | > # extension to abort transaction after finalization forcibly | |
867 | > from mercurial import commands, error, extensions, lock as lockmod |
|
867 | > from mercurial import commands, error, extensions, lock as lockmod | |
868 | > from mercurial import registrar |
|
868 | > from mercurial import registrar | |
869 | > cmdtable = {} |
|
869 | > cmdtable = {} | |
870 | > command = registrar.command(cmdtable) |
|
870 | > command = registrar.command(cmdtable) | |
871 | > configtable = {} |
|
871 | > configtable = {} | |
872 | > configitem = registrar.configitem(configtable) |
|
872 | > configitem = registrar.configitem(configtable) | |
873 | > configitem(b'failafterfinalize', b'fail', |
|
873 | > configitem(b'failafterfinalize', b'fail', | |
874 | > default=None, |
|
874 | > default=None, | |
875 | > ) |
|
875 | > ) | |
876 | > def fail(tr): |
|
876 | > def fail(tr): | |
877 | > raise error.Abort(b'fail after finalization') |
|
877 | > raise error.Abort(b'fail after finalization') | |
878 | > def reposetup(ui, repo): |
|
878 | > def reposetup(ui, repo): | |
879 | > class failrepo(repo.__class__): |
|
879 | > class failrepo(repo.__class__): | |
880 | > def commitctx(self, ctx, error=False): |
|
880 | > def commitctx(self, ctx, error=False): | |
881 | > if self.ui.configbool(b'failafterfinalize', b'fail'): |
|
881 | > if self.ui.configbool(b'failafterfinalize', b'fail'): | |
882 | > # 'sorted()' by ASCII code on category names causes |
|
882 | > # 'sorted()' by ASCII code on category names causes | |
883 | > # invoking 'fail' after finalization of changelog |
|
883 | > # invoking 'fail' after finalization of changelog | |
884 | > # using "'cl-%i' % id(self)" as category name |
|
884 | > # using "'cl-%i' % id(self)" as category name | |
885 | > self.currenttransaction().addfinalize(b'zzzzzzzz', fail) |
|
885 | > self.currenttransaction().addfinalize(b'zzzzzzzz', fail) | |
886 | > return super(failrepo, self).commitctx(ctx, error) |
|
886 | > return super(failrepo, self).commitctx(ctx, error) | |
887 | > repo.__class__ = failrepo |
|
887 | > repo.__class__ = failrepo | |
888 | > EOF |
|
888 | > EOF | |
889 |
|
889 | |||
890 | $ hg init repo3 |
|
890 | $ hg init repo3 | |
891 | $ cd repo3 |
|
891 | $ cd repo3 | |
892 |
|
892 | |||
893 | $ cat <<EOF >> $HGRCPATH |
|
893 | $ cat <<EOF >> $HGRCPATH | |
894 | > [ui] |
|
894 | > [ui] | |
895 | > logtemplate = {rev} {desc|firstline} ({files})\n |
|
895 | > logtemplate = {rev} {desc|firstline} ({files})\n | |
896 | > |
|
896 | > | |
897 | > [extensions] |
|
897 | > [extensions] | |
898 | > failafterfinalize = $TESTTMP/failafterfinalize.py |
|
898 | > failafterfinalize = $TESTTMP/failafterfinalize.py | |
899 | > EOF |
|
899 | > EOF | |
900 |
|
900 | |||
901 | - test failure with "empty changelog" |
|
901 | - test failure with "empty changelog" | |
902 |
|
902 | |||
903 | $ echo foo > foo |
|
903 | $ echo foo > foo | |
904 | $ hg add foo |
|
904 | $ hg add foo | |
905 |
|
905 | |||
906 | (failure before finalization) |
|
906 | (failure before finalization) | |
907 |
|
907 | |||
908 | >>> from hgclient import check, readchannel, runcommand |
|
908 | >>> from hgclient import check, readchannel, runcommand | |
909 | >>> @check |
|
909 | >>> @check | |
910 | ... def abort(server): |
|
910 | ... def abort(server): | |
911 | ... readchannel(server) |
|
911 | ... readchannel(server) | |
912 | ... runcommand(server, [b'commit', |
|
912 | ... runcommand(server, [b'commit', | |
913 | ... b'--config', b'hooks.pretxncommit=false', |
|
913 | ... b'--config', b'hooks.pretxncommit=false', | |
914 | ... b'-mfoo']) |
|
914 | ... b'-mfoo']) | |
915 | ... runcommand(server, [b'log']) |
|
915 | ... runcommand(server, [b'log']) | |
916 | ... runcommand(server, [b'verify', b'-q']) |
|
916 | ... runcommand(server, [b'verify', b'-q']) | |
917 | *** runcommand commit --config hooks.pretxncommit=false -mfoo |
|
917 | *** runcommand commit --config hooks.pretxncommit=false -mfoo | |
918 | transaction abort! |
|
918 | transaction abort! | |
919 | rollback completed |
|
919 | rollback completed | |
920 | abort: pretxncommit hook exited with status 1 |
|
920 | abort: pretxncommit hook exited with status 1 | |
921 | [255] |
|
921 | [255] | |
922 | *** runcommand log |
|
922 | *** runcommand log | |
923 | *** runcommand verify -q |
|
923 | *** runcommand verify -q | |
924 |
|
924 | |||
925 | (failure after finalization) |
|
925 | (failure after finalization) | |
926 |
|
926 | |||
927 | >>> from hgclient import check, readchannel, runcommand |
|
927 | >>> from hgclient import check, readchannel, runcommand | |
928 | >>> @check |
|
928 | >>> @check | |
929 | ... def abort(server): |
|
929 | ... def abort(server): | |
930 | ... readchannel(server) |
|
930 | ... readchannel(server) | |
931 | ... runcommand(server, [b'commit', |
|
931 | ... runcommand(server, [b'commit', | |
932 | ... b'--config', b'failafterfinalize.fail=true', |
|
932 | ... b'--config', b'failafterfinalize.fail=true', | |
933 | ... b'-mfoo']) |
|
933 | ... b'-mfoo']) | |
934 | ... runcommand(server, [b'log']) |
|
934 | ... runcommand(server, [b'log']) | |
935 | ... runcommand(server, [b'verify', b'-q']) |
|
935 | ... runcommand(server, [b'verify', b'-q']) | |
936 | *** runcommand commit --config failafterfinalize.fail=true -mfoo |
|
936 | *** runcommand commit --config failafterfinalize.fail=true -mfoo | |
937 | transaction abort! |
|
937 | transaction abort! | |
938 | rollback completed |
|
938 | rollback completed | |
939 | abort: fail after finalization |
|
939 | abort: fail after finalization | |
940 | [255] |
|
940 | [255] | |
941 | *** runcommand log |
|
941 | *** runcommand log | |
942 | *** runcommand verify -q |
|
942 | *** runcommand verify -q | |
943 |
|
943 | |||
944 | - test failure with "not-empty changelog" |
|
944 | - test failure with "not-empty changelog" | |
945 |
|
945 | |||
946 | $ echo bar > bar |
|
946 | $ echo bar > bar | |
947 | $ hg add bar |
|
947 | $ hg add bar | |
948 | $ hg commit -mbar bar |
|
948 | $ hg commit -mbar bar | |
949 |
|
949 | |||
950 | (failure before finalization) |
|
950 | (failure before finalization) | |
951 |
|
951 | |||
952 | >>> from hgclient import check, readchannel, runcommand |
|
952 | >>> from hgclient import check, readchannel, runcommand | |
953 | >>> @check |
|
953 | >>> @check | |
954 | ... def abort(server): |
|
954 | ... def abort(server): | |
955 | ... readchannel(server) |
|
955 | ... readchannel(server) | |
956 | ... runcommand(server, [b'commit', |
|
956 | ... runcommand(server, [b'commit', | |
957 | ... b'--config', b'hooks.pretxncommit=false', |
|
957 | ... b'--config', b'hooks.pretxncommit=false', | |
958 | ... b'-mfoo', b'foo']) |
|
958 | ... b'-mfoo', b'foo']) | |
959 | ... runcommand(server, [b'log']) |
|
959 | ... runcommand(server, [b'log']) | |
960 | ... runcommand(server, [b'verify', b'-q']) |
|
960 | ... runcommand(server, [b'verify', b'-q']) | |
961 | *** runcommand commit --config hooks.pretxncommit=false -mfoo foo |
|
961 | *** runcommand commit --config hooks.pretxncommit=false -mfoo foo | |
962 | transaction abort! |
|
962 | transaction abort! | |
963 | rollback completed |
|
963 | rollback completed | |
964 | abort: pretxncommit hook exited with status 1 |
|
964 | abort: pretxncommit hook exited with status 1 | |
965 | [255] |
|
965 | [255] | |
966 | *** runcommand log |
|
966 | *** runcommand log | |
967 | 0 bar (bar) |
|
967 | 0 bar (bar) | |
968 | *** runcommand verify -q |
|
968 | *** runcommand verify -q | |
969 |
|
969 | |||
970 | (failure after finalization) |
|
970 | (failure after finalization) | |
971 |
|
971 | |||
972 | >>> from hgclient import check, readchannel, runcommand |
|
972 | >>> from hgclient import check, readchannel, runcommand | |
973 | >>> @check |
|
973 | >>> @check | |
974 | ... def abort(server): |
|
974 | ... def abort(server): | |
975 | ... readchannel(server) |
|
975 | ... readchannel(server) | |
976 | ... runcommand(server, [b'commit', |
|
976 | ... runcommand(server, [b'commit', | |
977 | ... b'--config', b'failafterfinalize.fail=true', |
|
977 | ... b'--config', b'failafterfinalize.fail=true', | |
978 | ... b'-mfoo', b'foo']) |
|
978 | ... b'-mfoo', b'foo']) | |
979 | ... runcommand(server, [b'log']) |
|
979 | ... runcommand(server, [b'log']) | |
980 | ... runcommand(server, [b'verify', b'-q']) |
|
980 | ... runcommand(server, [b'verify', b'-q']) | |
981 | *** runcommand commit --config failafterfinalize.fail=true -mfoo foo |
|
981 | *** runcommand commit --config failafterfinalize.fail=true -mfoo foo | |
982 | transaction abort! |
|
982 | transaction abort! | |
983 | rollback completed |
|
983 | rollback completed | |
984 | abort: fail after finalization |
|
984 | abort: fail after finalization | |
985 | [255] |
|
985 | [255] | |
986 | *** runcommand log |
|
986 | *** runcommand log | |
987 | 0 bar (bar) |
|
987 | 0 bar (bar) | |
988 | *** runcommand verify -q |
|
988 | *** runcommand verify -q | |
989 |
|
989 | |||
990 | $ cd .. |
|
990 | $ cd .. | |
991 |
|
991 | |||
992 | Test symlink traversal over cached audited paths: |
|
992 | Test symlink traversal over cached audited paths: | |
993 | ------------------------------------------------- |
|
993 | ------------------------------------------------- | |
994 |
|
994 | |||
995 | #if symlink |
|
995 | #if symlink | |
996 |
|
996 | |||
997 | set up symlink hell |
|
997 | set up symlink hell | |
998 |
|
998 | |||
999 | $ mkdir merge-symlink-out |
|
999 | $ mkdir merge-symlink-out | |
1000 | $ hg init merge-symlink |
|
1000 | $ hg init merge-symlink | |
1001 | $ cd merge-symlink |
|
1001 | $ cd merge-symlink | |
1002 | $ touch base |
|
1002 | $ touch base | |
1003 | $ hg commit -qAm base |
|
1003 | $ hg commit -qAm base | |
1004 | $ ln -s ../merge-symlink-out a |
|
1004 | $ ln -s ../merge-symlink-out a | |
1005 | $ hg commit -qAm 'symlink a -> ../merge-symlink-out' |
|
1005 | $ hg commit -qAm 'symlink a -> ../merge-symlink-out' | |
1006 | $ hg up -q 0 |
|
1006 | $ hg up -q 0 | |
1007 | $ mkdir a |
|
1007 | $ mkdir a | |
1008 | $ touch a/poisoned |
|
1008 | $ touch a/poisoned | |
1009 | $ hg commit -qAm 'file a/poisoned' |
|
1009 | $ hg commit -qAm 'file a/poisoned' | |
1010 | $ hg log -G -T '{rev}: {desc}\n' |
|
1010 | $ hg log -G -T '{rev}: {desc}\n' | |
1011 | @ 2: file a/poisoned |
|
1011 | @ 2: file a/poisoned | |
1012 | | |
|
1012 | | | |
1013 | | o 1: symlink a -> ../merge-symlink-out |
|
1013 | | o 1: symlink a -> ../merge-symlink-out | |
1014 | |/ |
|
1014 | |/ | |
1015 | o 0: base |
|
1015 | o 0: base | |
1016 |
|
1016 | |||
1017 |
|
1017 | |||
1018 | try trivial merge after update: cache of audited paths should be discarded, |
|
1018 | try trivial merge after update: cache of audited paths should be discarded, | |
1019 | and the merge should fail (issue5628) |
|
1019 | and the merge should fail (issue5628) | |
1020 |
|
1020 | |||
1021 | $ hg up -q null |
|
1021 | $ hg up -q null | |
1022 | >>> from hgclient import check, readchannel, runcommand |
|
1022 | >>> from hgclient import check, readchannel, runcommand | |
1023 | >>> @check |
|
1023 | >>> @check | |
1024 | ... def merge(server): |
|
1024 | ... def merge(server): | |
1025 | ... readchannel(server) |
|
1025 | ... readchannel(server) | |
1026 | ... # audit a/poisoned as a good path |
|
1026 | ... # audit a/poisoned as a good path | |
1027 | ... runcommand(server, [b'up', b'-qC', b'2']) |
|
1027 | ... runcommand(server, [b'up', b'-qC', b'2']) | |
1028 | ... runcommand(server, [b'up', b'-qC', b'1']) |
|
1028 | ... runcommand(server, [b'up', b'-qC', b'1']) | |
1029 | ... # here a is a symlink, so a/poisoned is bad |
|
1029 | ... # here a is a symlink, so a/poisoned is bad | |
1030 | ... runcommand(server, [b'merge', b'2']) |
|
1030 | ... runcommand(server, [b'merge', b'2']) | |
1031 | *** runcommand up -qC 2 |
|
1031 | *** runcommand up -qC 2 | |
1032 | *** runcommand up -qC 1 |
|
1032 | *** runcommand up -qC 1 | |
1033 | *** runcommand merge 2 |
|
1033 | *** runcommand merge 2 | |
1034 | abort: path 'a/poisoned' traverses symbolic link 'a' |
|
1034 | abort: path 'a/poisoned' traverses symbolic link 'a' | |
1035 | [255] |
|
1035 | [255] | |
1036 | $ ls ../merge-symlink-out |
|
1036 | $ ls ../merge-symlink-out | |
1037 |
|
1037 | |||
1038 | cache of repo.auditor should be discarded, so matcher would never traverse |
|
1038 | cache of repo.auditor should be discarded, so matcher would never traverse | |
1039 | symlinks: |
|
1039 | symlinks: | |
1040 |
|
1040 | |||
1041 | $ hg up -qC 0 |
|
1041 | $ hg up -qC 0 | |
1042 | $ touch ../merge-symlink-out/poisoned |
|
1042 | $ touch ../merge-symlink-out/poisoned | |
1043 | >>> from hgclient import check, readchannel, runcommand |
|
1043 | >>> from hgclient import check, readchannel, runcommand | |
1044 | >>> @check |
|
1044 | >>> @check | |
1045 | ... def files(server): |
|
1045 | ... def files(server): | |
1046 | ... readchannel(server) |
|
1046 | ... readchannel(server) | |
1047 | ... runcommand(server, [b'up', b'-qC', b'2']) |
|
1047 | ... runcommand(server, [b'up', b'-qC', b'2']) | |
1048 | ... # audit a/poisoned as a good path |
|
1048 | ... # audit a/poisoned as a good path | |
1049 | ... runcommand(server, [b'files', b'a/poisoned']) |
|
1049 | ... runcommand(server, [b'files', b'a/poisoned']) | |
1050 | ... runcommand(server, [b'up', b'-qC', b'0']) |
|
1050 | ... runcommand(server, [b'up', b'-qC', b'0']) | |
1051 | ... runcommand(server, [b'up', b'-qC', b'1']) |
|
1051 | ... runcommand(server, [b'up', b'-qC', b'1']) | |
1052 | ... # here 'a' is a symlink, so a/poisoned should be warned |
|
1052 | ... # here 'a' is a symlink, so a/poisoned should be warned | |
1053 | ... runcommand(server, [b'files', b'a/poisoned']) |
|
1053 | ... runcommand(server, [b'files', b'a/poisoned']) | |
1054 | *** runcommand up -qC 2 |
|
1054 | *** runcommand up -qC 2 | |
1055 | *** runcommand files a/poisoned |
|
1055 | *** runcommand files a/poisoned | |
1056 | a/poisoned |
|
1056 | a/poisoned | |
1057 | *** runcommand up -qC 0 |
|
1057 | *** runcommand up -qC 0 | |
1058 | *** runcommand up -qC 1 |
|
1058 | *** runcommand up -qC 1 | |
1059 | *** runcommand files a/poisoned |
|
1059 | *** runcommand files a/poisoned | |
1060 | abort: path 'a/poisoned' traverses symbolic link 'a' |
|
1060 | abort: path 'a/poisoned' traverses symbolic link 'a' | |
1061 | [255] |
|
1061 | [255] | |
1062 |
|
1062 | |||
1063 | $ cd .. |
|
1063 | $ cd .. | |
1064 |
|
1064 | |||
1065 | #endif |
|
1065 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now