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