Show More
@@ -1,551 +1,543 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 | $ hg init repo |
|
8 | $ hg init repo | |
9 | $ cd repo |
|
9 | $ cd repo | |
10 |
|
10 | |||
11 | >>> import re |
|
|||
12 | >>> from hgclient import readchannel, runcommand, check |
|
11 | >>> from hgclient import readchannel, runcommand, check | |
13 | >>> @check |
|
12 | >>> @check | |
14 | ... def hellomessage(server): |
|
13 | ... def hellomessage(server): | |
15 | ... ch, data = readchannel(server) |
|
14 | ... ch, data = readchannel(server) | |
16 | ... # escaping python tests output not supported |
|
15 | ... print '%c, %r' % (ch, data) | |
17 | ... print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', |
|
|||
18 | ... 'encoding: ***', data)) |
|
|||
19 | ... |
|
|||
20 | ... # run an arbitrary command to make sure the next thing the server |
|
16 | ... # run an arbitrary command to make sure the next thing the server | |
21 | ... # sends isn't part of the hello message |
|
17 | ... # sends isn't part of the hello message | |
22 | ... runcommand(server, ['id']) |
|
18 | ... runcommand(server, ['id']) | |
23 |
o, 'capabilities: getencoding runcommand\nencoding: * |
|
19 | o, 'capabilities: getencoding runcommand\nencoding: *' (glob) | |
24 | runcommand id |
|
20 | runcommand id | |
25 | 000000000000 tip |
|
21 | 000000000000 tip | |
26 |
|
22 | |||
27 | >>> from hgclient import check |
|
23 | >>> from hgclient import check | |
28 | >>> @check |
|
24 | >>> @check | |
29 | ... def unknowncommand(server): |
|
25 | ... def unknowncommand(server): | |
30 | ... server.stdin.write('unknowncommand\n') |
|
26 | ... server.stdin.write('unknowncommand\n') | |
31 | abort: unknown command unknowncommand |
|
27 | abort: unknown command unknowncommand | |
32 |
|
28 | |||
33 | >>> from hgclient import readchannel, runcommand, check |
|
29 | >>> from hgclient import readchannel, runcommand, check | |
34 | >>> @check |
|
30 | >>> @check | |
35 | ... def checkruncommand(server): |
|
31 | ... def checkruncommand(server): | |
36 | ... # hello block |
|
32 | ... # hello block | |
37 | ... readchannel(server) |
|
33 | ... readchannel(server) | |
38 | ... |
|
34 | ... | |
39 | ... # no args |
|
35 | ... # no args | |
40 | ... runcommand(server, []) |
|
36 | ... runcommand(server, []) | |
41 | ... |
|
37 | ... | |
42 | ... # global options |
|
38 | ... # global options | |
43 | ... runcommand(server, ['id', '--quiet']) |
|
39 | ... runcommand(server, ['id', '--quiet']) | |
44 | ... |
|
40 | ... | |
45 | ... # make sure global options don't stick through requests |
|
41 | ... # make sure global options don't stick through requests | |
46 | ... runcommand(server, ['id']) |
|
42 | ... runcommand(server, ['id']) | |
47 | ... |
|
43 | ... | |
48 | ... # --config |
|
44 | ... # --config | |
49 | ... runcommand(server, ['id', '--config', 'ui.quiet=True']) |
|
45 | ... runcommand(server, ['id', '--config', 'ui.quiet=True']) | |
50 | ... |
|
46 | ... | |
51 | ... # make sure --config doesn't stick |
|
47 | ... # make sure --config doesn't stick | |
52 | ... runcommand(server, ['id']) |
|
48 | ... runcommand(server, ['id']) | |
53 | ... |
|
49 | ... | |
54 | ... # negative return code should be masked |
|
50 | ... # negative return code should be masked | |
55 | ... runcommand(server, ['id', '-runknown']) |
|
51 | ... runcommand(server, ['id', '-runknown']) | |
56 | runcommand |
|
52 | runcommand | |
57 | Mercurial Distributed SCM |
|
53 | Mercurial Distributed SCM | |
58 |
|
54 | |||
59 | basic commands: |
|
55 | basic commands: | |
60 |
|
56 | |||
61 | add add the specified files on the next commit |
|
57 | add add the specified files on the next commit | |
62 | annotate show changeset information by line for each file |
|
58 | annotate show changeset information by line for each file | |
63 | clone make a copy of an existing repository |
|
59 | clone make a copy of an existing repository | |
64 | commit commit the specified files or all outstanding changes |
|
60 | commit commit the specified files or all outstanding changes | |
65 | diff diff repository (or selected files) |
|
61 | diff diff repository (or selected files) | |
66 | export dump the header and diffs for one or more changesets |
|
62 | export dump the header and diffs for one or more changesets | |
67 | forget forget the specified files on the next commit |
|
63 | forget forget the specified files on the next commit | |
68 | init create a new repository in the given directory |
|
64 | init create a new repository in the given directory | |
69 | log show revision history of entire repository or files |
|
65 | log show revision history of entire repository or files | |
70 | merge merge working directory with another revision |
|
66 | merge merge working directory with another revision | |
71 | pull pull changes from the specified source |
|
67 | pull pull changes from the specified source | |
72 | push push changes to the specified destination |
|
68 | push push changes to the specified destination | |
73 | remove remove the specified files on the next commit |
|
69 | remove remove the specified files on the next commit | |
74 | serve start stand-alone webserver |
|
70 | serve start stand-alone webserver | |
75 | status show changed files in the working directory |
|
71 | status show changed files in the working directory | |
76 | summary summarize working directory state |
|
72 | summary summarize working directory state | |
77 | update update working directory (or switch revisions) |
|
73 | update update working directory (or switch revisions) | |
78 |
|
74 | |||
79 | (use "hg help" for the full list of commands or "hg -v" for details) |
|
75 | (use "hg help" for the full list of commands or "hg -v" for details) | |
80 | runcommand id --quiet |
|
76 | runcommand id --quiet | |
81 | 000000000000 |
|
77 | 000000000000 | |
82 | runcommand id |
|
78 | runcommand id | |
83 | 000000000000 tip |
|
79 | 000000000000 tip | |
84 | runcommand id --config ui.quiet=True |
|
80 | runcommand id --config ui.quiet=True | |
85 | 000000000000 |
|
81 | 000000000000 | |
86 | runcommand id |
|
82 | runcommand id | |
87 | 000000000000 tip |
|
83 | 000000000000 tip | |
88 | runcommand id -runknown |
|
84 | runcommand id -runknown | |
89 | abort: unknown revision 'unknown'! |
|
85 | abort: unknown revision 'unknown'! | |
90 | [255] |
|
86 | [255] | |
91 |
|
87 | |||
92 | >>> from hgclient import readchannel, check |
|
88 | >>> from hgclient import readchannel, check | |
93 | >>> @check |
|
89 | >>> @check | |
94 | ... def inputeof(server): |
|
90 | ... def inputeof(server): | |
95 | ... readchannel(server) |
|
91 | ... readchannel(server) | |
96 | ... server.stdin.write('runcommand\n') |
|
92 | ... server.stdin.write('runcommand\n') | |
97 | ... # close stdin while server is waiting for input |
|
93 | ... # close stdin while server is waiting for input | |
98 | ... server.stdin.close() |
|
94 | ... server.stdin.close() | |
99 | ... |
|
95 | ... | |
100 | ... # server exits with 1 if the pipe closed while reading the command |
|
96 | ... # server exits with 1 if the pipe closed while reading the command | |
101 | ... print 'server exit code =', server.wait() |
|
97 | ... print 'server exit code =', server.wait() | |
102 | server exit code = 1 |
|
98 | server exit code = 1 | |
103 |
|
99 | |||
104 | >>> import cStringIO |
|
100 | >>> import cStringIO | |
105 | >>> from hgclient import readchannel, runcommand, check |
|
101 | >>> from hgclient import readchannel, runcommand, check | |
106 | >>> @check |
|
102 | >>> @check | |
107 | ... def serverinput(server): |
|
103 | ... def serverinput(server): | |
108 | ... readchannel(server) |
|
104 | ... readchannel(server) | |
109 | ... |
|
105 | ... | |
110 | ... patch = """ |
|
106 | ... patch = """ | |
111 | ... # HG changeset patch |
|
107 | ... # HG changeset patch | |
112 | ... # User test |
|
108 | ... # User test | |
113 | ... # Date 0 0 |
|
109 | ... # Date 0 0 | |
114 | ... # Node ID c103a3dec114d882c98382d684d8af798d09d857 |
|
110 | ... # Node ID c103a3dec114d882c98382d684d8af798d09d857 | |
115 | ... # Parent 0000000000000000000000000000000000000000 |
|
111 | ... # Parent 0000000000000000000000000000000000000000 | |
116 | ... 1 |
|
112 | ... 1 | |
117 | ... |
|
113 | ... | |
118 | ... diff -r 000000000000 -r c103a3dec114 a |
|
114 | ... diff -r 000000000000 -r c103a3dec114 a | |
119 | ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
|
115 | ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000 | |
120 | ... +++ b/a Thu Jan 01 00:00:00 1970 +0000 |
|
116 | ... +++ b/a Thu Jan 01 00:00:00 1970 +0000 | |
121 | ... @@ -0,0 +1,1 @@ |
|
117 | ... @@ -0,0 +1,1 @@ | |
122 | ... +1 |
|
118 | ... +1 | |
123 | ... """ |
|
119 | ... """ | |
124 | ... |
|
120 | ... | |
125 | ... runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch)) |
|
121 | ... runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch)) | |
126 | ... runcommand(server, ['log']) |
|
122 | ... runcommand(server, ['log']) | |
127 | runcommand import - |
|
123 | runcommand import - | |
128 | applying patch from stdin |
|
124 | applying patch from stdin | |
129 | runcommand log |
|
125 | runcommand log | |
130 | changeset: 0:eff892de26ec |
|
126 | changeset: 0:eff892de26ec | |
131 | tag: tip |
|
127 | tag: tip | |
132 | user: test |
|
128 | user: test | |
133 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
129 | date: Thu Jan 01 00:00:00 1970 +0000 | |
134 | summary: 1 |
|
130 | summary: 1 | |
135 |
|
131 | |||
136 |
|
132 | |||
137 | check that --cwd doesn't persist between requests: |
|
133 | check that --cwd doesn't persist between requests: | |
138 |
|
134 | |||
139 | $ mkdir foo |
|
135 | $ mkdir foo | |
140 | $ touch foo/bar |
|
136 | $ touch foo/bar | |
141 | >>> from hgclient import readchannel, runcommand, check |
|
137 | >>> from hgclient import readchannel, runcommand, check | |
142 | >>> @check |
|
138 | >>> @check | |
143 | ... def cwd(server): |
|
139 | ... def cwd(server): | |
144 | ... readchannel(server) |
|
140 | ... readchannel(server) | |
145 | ... runcommand(server, ['--cwd', 'foo', 'st', 'bar']) |
|
141 | ... runcommand(server, ['--cwd', 'foo', 'st', 'bar']) | |
146 | ... runcommand(server, ['st', 'foo/bar']) |
|
142 | ... runcommand(server, ['st', 'foo/bar']) | |
147 | runcommand --cwd foo st bar |
|
143 | runcommand --cwd foo st bar | |
148 | ? bar |
|
144 | ? bar | |
149 | runcommand st foo/bar |
|
145 | runcommand st foo/bar | |
150 | ? foo/bar |
|
146 | ? foo/bar | |
151 |
|
147 | |||
152 | $ rm foo/bar |
|
148 | $ rm foo/bar | |
153 |
|
149 | |||
154 |
|
150 | |||
155 | check that local configs for the cached repo aren't inherited when -R is used: |
|
151 | check that local configs for the cached repo aren't inherited when -R is used: | |
156 |
|
152 | |||
157 | $ cat <<EOF >> .hg/hgrc |
|
153 | $ cat <<EOF >> .hg/hgrc | |
158 | > [ui] |
|
154 | > [ui] | |
159 | > foo = bar |
|
155 | > foo = bar | |
160 | > EOF |
|
156 | > EOF | |
161 |
|
157 | |||
162 | >>> from hgclient import readchannel, sep, runcommand, check |
|
158 | >>> from hgclient import readchannel, sep, runcommand, check | |
163 | >>> @check |
|
159 | >>> @check | |
164 | ... def localhgrc(server): |
|
160 | ... def localhgrc(server): | |
165 | ... readchannel(server) |
|
161 | ... readchannel(server) | |
166 | ... |
|
162 | ... | |
167 | ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should |
|
163 | ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should | |
168 | ... # show it |
|
164 | ... # show it | |
169 | ... runcommand(server, ['showconfig'], outfilter=sep) |
|
165 | ... runcommand(server, ['showconfig'], outfilter=sep) | |
170 | ... |
|
166 | ... | |
171 | ... # but not for this repo |
|
167 | ... # but not for this repo | |
172 | ... runcommand(server, ['init', 'foo']) |
|
168 | ... runcommand(server, ['init', 'foo']) | |
173 | ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults']) |
|
169 | ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults']) | |
174 | runcommand showconfig |
|
170 | runcommand showconfig | |
175 | bundle.mainreporoot=$TESTTMP/repo |
|
171 | bundle.mainreporoot=$TESTTMP/repo | |
176 | defaults.backout=-d "0 0" |
|
172 | defaults.backout=-d "0 0" | |
177 | defaults.commit=-d "0 0" |
|
173 | defaults.commit=-d "0 0" | |
178 | defaults.shelve=--date "0 0" |
|
174 | defaults.shelve=--date "0 0" | |
179 | defaults.tag=-d "0 0" |
|
175 | defaults.tag=-d "0 0" | |
180 | ui.slash=True |
|
176 | ui.slash=True | |
181 | ui.interactive=False |
|
177 | ui.interactive=False | |
182 | ui.mergemarkers=detailed |
|
178 | ui.mergemarkers=detailed | |
183 | ui.foo=bar |
|
179 | ui.foo=bar | |
184 | ui.nontty=true |
|
180 | ui.nontty=true | |
185 | runcommand init foo |
|
181 | runcommand init foo | |
186 | runcommand -R foo showconfig ui defaults |
|
182 | runcommand -R foo showconfig ui defaults | |
187 | defaults.backout=-d "0 0" |
|
183 | defaults.backout=-d "0 0" | |
188 | defaults.commit=-d "0 0" |
|
184 | defaults.commit=-d "0 0" | |
189 | defaults.shelve=--date "0 0" |
|
185 | defaults.shelve=--date "0 0" | |
190 | defaults.tag=-d "0 0" |
|
186 | defaults.tag=-d "0 0" | |
191 | ui.slash=True |
|
187 | ui.slash=True | |
192 | ui.interactive=False |
|
188 | ui.interactive=False | |
193 | ui.mergemarkers=detailed |
|
189 | ui.mergemarkers=detailed | |
194 | ui.nontty=true |
|
190 | ui.nontty=true | |
195 |
|
191 | |||
196 | $ rm -R foo |
|
192 | $ rm -R foo | |
197 |
|
193 | |||
198 | #if windows |
|
194 | #if windows | |
199 | $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH" |
|
195 | $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH" | |
200 | #else |
|
196 | #else | |
201 | $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH" |
|
197 | $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH" | |
202 | #endif |
|
198 | #endif | |
203 |
|
199 | |||
204 | $ cat <<EOF > hook.py |
|
200 | $ cat <<EOF > hook.py | |
205 | > import sys |
|
201 | > import sys | |
206 | > def hook(**args): |
|
202 | > def hook(**args): | |
207 | > print 'hook talking' |
|
203 | > print 'hook talking' | |
208 | > print 'now try to read something: %r' % sys.stdin.read() |
|
204 | > print 'now try to read something: %r' % sys.stdin.read() | |
209 | > EOF |
|
205 | > EOF | |
210 |
|
206 | |||
211 | >>> import cStringIO |
|
207 | >>> import cStringIO | |
212 | >>> from hgclient import readchannel, runcommand, check |
|
208 | >>> from hgclient import readchannel, runcommand, check | |
213 | >>> @check |
|
209 | >>> @check | |
214 | ... def hookoutput(server): |
|
210 | ... def hookoutput(server): | |
215 | ... readchannel(server) |
|
211 | ... readchannel(server) | |
216 | ... runcommand(server, ['--config', |
|
212 | ... runcommand(server, ['--config', | |
217 | ... 'hooks.pre-identify=python:hook.hook', |
|
213 | ... 'hooks.pre-identify=python:hook.hook', | |
218 | ... 'id'], |
|
214 | ... 'id'], | |
219 | ... input=cStringIO.StringIO('some input')) |
|
215 | ... input=cStringIO.StringIO('some input')) | |
220 | runcommand --config hooks.pre-identify=python:hook.hook id |
|
216 | runcommand --config hooks.pre-identify=python:hook.hook id | |
221 | hook talking |
|
217 | hook talking | |
222 | now try to read something: 'some input' |
|
218 | now try to read something: 'some input' | |
223 | eff892de26ec tip |
|
219 | eff892de26ec tip | |
224 |
|
220 | |||
225 | $ rm hook.py* |
|
221 | $ rm hook.py* | |
226 |
|
222 | |||
227 | $ echo a >> a |
|
223 | $ echo a >> a | |
228 | >>> import os |
|
224 | >>> import os | |
229 | >>> from hgclient import readchannel, runcommand, check |
|
225 | >>> from hgclient import readchannel, runcommand, check | |
230 | >>> @check |
|
226 | >>> @check | |
231 | ... def outsidechanges(server): |
|
227 | ... def outsidechanges(server): | |
232 | ... readchannel(server) |
|
228 | ... readchannel(server) | |
233 | ... runcommand(server, ['status']) |
|
229 | ... runcommand(server, ['status']) | |
234 | ... os.system('hg ci -Am2') |
|
230 | ... os.system('hg ci -Am2') | |
235 | ... runcommand(server, ['tip']) |
|
231 | ... runcommand(server, ['tip']) | |
236 | ... runcommand(server, ['status']) |
|
232 | ... runcommand(server, ['status']) | |
237 | runcommand status |
|
233 | runcommand status | |
238 | M a |
|
234 | M a | |
239 | runcommand tip |
|
235 | runcommand tip | |
240 | changeset: 1:d3a0a68be6de |
|
236 | changeset: 1:d3a0a68be6de | |
241 | tag: tip |
|
237 | tag: tip | |
242 | user: test |
|
238 | user: test | |
243 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
239 | date: Thu Jan 01 00:00:00 1970 +0000 | |
244 | summary: 2 |
|
240 | summary: 2 | |
245 |
|
241 | |||
246 | runcommand status |
|
242 | runcommand status | |
247 |
|
243 | |||
248 | >>> import os |
|
244 | >>> import os | |
249 | >>> from hgclient import readchannel, runcommand, check |
|
245 | >>> from hgclient import readchannel, runcommand, check | |
250 | >>> @check |
|
246 | >>> @check | |
251 | ... def bookmarks(server): |
|
247 | ... def bookmarks(server): | |
252 | ... readchannel(server) |
|
248 | ... readchannel(server) | |
253 | ... runcommand(server, ['bookmarks']) |
|
249 | ... runcommand(server, ['bookmarks']) | |
254 | ... |
|
250 | ... | |
255 | ... # changes .hg/bookmarks |
|
251 | ... # changes .hg/bookmarks | |
256 | ... os.system('hg bookmark -i bm1') |
|
252 | ... os.system('hg bookmark -i bm1') | |
257 | ... os.system('hg bookmark -i bm2') |
|
253 | ... os.system('hg bookmark -i bm2') | |
258 | ... runcommand(server, ['bookmarks']) |
|
254 | ... runcommand(server, ['bookmarks']) | |
259 | ... |
|
255 | ... | |
260 | ... # changes .hg/bookmarks.current |
|
256 | ... # changes .hg/bookmarks.current | |
261 | ... os.system('hg upd bm1 -q') |
|
257 | ... os.system('hg upd bm1 -q') | |
262 | ... runcommand(server, ['bookmarks']) |
|
258 | ... runcommand(server, ['bookmarks']) | |
263 | ... |
|
259 | ... | |
264 | ... runcommand(server, ['bookmarks', 'bm3']) |
|
260 | ... runcommand(server, ['bookmarks', 'bm3']) | |
265 | ... f = open('a', 'ab') |
|
261 | ... f = open('a', 'ab') | |
266 | ... f.write('a\n') |
|
262 | ... f.write('a\n') | |
267 | ... f.close() |
|
263 | ... f.close() | |
268 | ... runcommand(server, ['commit', '-Amm']) |
|
264 | ... runcommand(server, ['commit', '-Amm']) | |
269 | ... runcommand(server, ['bookmarks']) |
|
265 | ... runcommand(server, ['bookmarks']) | |
270 | runcommand bookmarks |
|
266 | runcommand bookmarks | |
271 | no bookmarks set |
|
267 | no bookmarks set | |
272 | runcommand bookmarks |
|
268 | runcommand bookmarks | |
273 | bm1 1:d3a0a68be6de |
|
269 | bm1 1:d3a0a68be6de | |
274 | bm2 1:d3a0a68be6de |
|
270 | bm2 1:d3a0a68be6de | |
275 | runcommand bookmarks |
|
271 | runcommand bookmarks | |
276 | * bm1 1:d3a0a68be6de |
|
272 | * bm1 1:d3a0a68be6de | |
277 | bm2 1:d3a0a68be6de |
|
273 | bm2 1:d3a0a68be6de | |
278 | runcommand bookmarks bm3 |
|
274 | runcommand bookmarks bm3 | |
279 | runcommand commit -Amm |
|
275 | runcommand commit -Amm | |
280 | runcommand bookmarks |
|
276 | runcommand bookmarks | |
281 | bm1 1:d3a0a68be6de |
|
277 | bm1 1:d3a0a68be6de | |
282 | bm2 1:d3a0a68be6de |
|
278 | bm2 1:d3a0a68be6de | |
283 | * bm3 2:aef17e88f5f0 |
|
279 | * bm3 2:aef17e88f5f0 | |
284 |
|
280 | |||
285 | >>> import os |
|
281 | >>> import os | |
286 | >>> from hgclient import readchannel, runcommand, check |
|
282 | >>> from hgclient import readchannel, runcommand, check | |
287 | >>> @check |
|
283 | >>> @check | |
288 | ... def tagscache(server): |
|
284 | ... def tagscache(server): | |
289 | ... readchannel(server) |
|
285 | ... readchannel(server) | |
290 | ... runcommand(server, ['id', '-t', '-r', '0']) |
|
286 | ... runcommand(server, ['id', '-t', '-r', '0']) | |
291 | ... os.system('hg tag -r 0 foo') |
|
287 | ... os.system('hg tag -r 0 foo') | |
292 | ... runcommand(server, ['id', '-t', '-r', '0']) |
|
288 | ... runcommand(server, ['id', '-t', '-r', '0']) | |
293 | runcommand id -t -r 0 |
|
289 | runcommand id -t -r 0 | |
294 |
|
290 | |||
295 | runcommand id -t -r 0 |
|
291 | runcommand id -t -r 0 | |
296 | foo |
|
292 | foo | |
297 |
|
293 | |||
298 | >>> import os |
|
294 | >>> import os | |
299 | >>> from hgclient import readchannel, runcommand, check |
|
295 | >>> from hgclient import readchannel, runcommand, check | |
300 | >>> @check |
|
296 | >>> @check | |
301 | ... def setphase(server): |
|
297 | ... def setphase(server): | |
302 | ... readchannel(server) |
|
298 | ... readchannel(server) | |
303 | ... runcommand(server, ['phase', '-r', '.']) |
|
299 | ... runcommand(server, ['phase', '-r', '.']) | |
304 | ... os.system('hg phase -r . -p') |
|
300 | ... os.system('hg phase -r . -p') | |
305 | ... runcommand(server, ['phase', '-r', '.']) |
|
301 | ... runcommand(server, ['phase', '-r', '.']) | |
306 | runcommand phase -r . |
|
302 | runcommand phase -r . | |
307 | 3: draft |
|
303 | 3: draft | |
308 | runcommand phase -r . |
|
304 | runcommand phase -r . | |
309 | 3: public |
|
305 | 3: public | |
310 |
|
306 | |||
311 | $ echo a >> a |
|
307 | $ echo a >> a | |
312 | >>> from hgclient import readchannel, runcommand, check |
|
308 | >>> from hgclient import readchannel, runcommand, check | |
313 | >>> @check |
|
309 | >>> @check | |
314 | ... def rollback(server): |
|
310 | ... def rollback(server): | |
315 | ... readchannel(server) |
|
311 | ... readchannel(server) | |
316 | ... runcommand(server, ['phase', '-r', '.', '-p']) |
|
312 | ... runcommand(server, ['phase', '-r', '.', '-p']) | |
317 | ... runcommand(server, ['commit', '-Am.']) |
|
313 | ... runcommand(server, ['commit', '-Am.']) | |
318 | ... runcommand(server, ['rollback']) |
|
314 | ... runcommand(server, ['rollback']) | |
319 | ... runcommand(server, ['phase', '-r', '.']) |
|
315 | ... runcommand(server, ['phase', '-r', '.']) | |
320 | runcommand phase -r . -p |
|
316 | runcommand phase -r . -p | |
321 | no phases changed |
|
317 | no phases changed | |
322 | [1] |
|
318 | [1] | |
323 | runcommand commit -Am. |
|
319 | runcommand commit -Am. | |
324 | runcommand rollback |
|
320 | runcommand rollback | |
325 | repository tip rolled back to revision 3 (undo commit) |
|
321 | repository tip rolled back to revision 3 (undo commit) | |
326 | working directory now based on revision 3 |
|
322 | working directory now based on revision 3 | |
327 | runcommand phase -r . |
|
323 | runcommand phase -r . | |
328 | 3: public |
|
324 | 3: public | |
329 |
|
325 | |||
330 | >>> import os |
|
326 | >>> import os | |
331 | >>> from hgclient import readchannel, runcommand, check |
|
327 | >>> from hgclient import readchannel, runcommand, check | |
332 | >>> @check |
|
328 | >>> @check | |
333 | ... def branch(server): |
|
329 | ... def branch(server): | |
334 | ... readchannel(server) |
|
330 | ... readchannel(server) | |
335 | ... runcommand(server, ['branch']) |
|
331 | ... runcommand(server, ['branch']) | |
336 | ... os.system('hg branch foo') |
|
332 | ... os.system('hg branch foo') | |
337 | ... runcommand(server, ['branch']) |
|
333 | ... runcommand(server, ['branch']) | |
338 | ... os.system('hg branch default') |
|
334 | ... os.system('hg branch default') | |
339 | runcommand branch |
|
335 | runcommand branch | |
340 | default |
|
336 | default | |
341 | marked working directory as branch foo |
|
337 | marked working directory as branch foo | |
342 | (branches are permanent and global, did you want a bookmark?) |
|
338 | (branches are permanent and global, did you want a bookmark?) | |
343 | runcommand branch |
|
339 | runcommand branch | |
344 | foo |
|
340 | foo | |
345 | marked working directory as branch default |
|
341 | marked working directory as branch default | |
346 | (branches are permanent and global, did you want a bookmark?) |
|
342 | (branches are permanent and global, did you want a bookmark?) | |
347 |
|
343 | |||
348 | $ touch .hgignore |
|
344 | $ touch .hgignore | |
349 | >>> import os |
|
345 | >>> import os | |
350 | >>> from hgclient import readchannel, runcommand, check |
|
346 | >>> from hgclient import readchannel, runcommand, check | |
351 | >>> @check |
|
347 | >>> @check | |
352 | ... def hgignore(server): |
|
348 | ... def hgignore(server): | |
353 | ... readchannel(server) |
|
349 | ... readchannel(server) | |
354 | ... runcommand(server, ['commit', '-Am.']) |
|
350 | ... runcommand(server, ['commit', '-Am.']) | |
355 | ... f = open('ignored-file', 'ab') |
|
351 | ... f = open('ignored-file', 'ab') | |
356 | ... f.write('') |
|
352 | ... f.write('') | |
357 | ... f.close() |
|
353 | ... f.close() | |
358 | ... f = open('.hgignore', 'ab') |
|
354 | ... f = open('.hgignore', 'ab') | |
359 | ... f.write('ignored-file') |
|
355 | ... f.write('ignored-file') | |
360 | ... f.close() |
|
356 | ... f.close() | |
361 | ... runcommand(server, ['status', '-i', '-u']) |
|
357 | ... runcommand(server, ['status', '-i', '-u']) | |
362 | runcommand commit -Am. |
|
358 | runcommand commit -Am. | |
363 | adding .hgignore |
|
359 | adding .hgignore | |
364 | runcommand status -i -u |
|
360 | runcommand status -i -u | |
365 | I ignored-file |
|
361 | I ignored-file | |
366 |
|
362 | |||
367 | >>> import os |
|
363 | >>> import os | |
368 | >>> from hgclient import readchannel, sep, runcommand, check |
|
364 | >>> from hgclient import readchannel, sep, runcommand, check | |
369 | >>> @check |
|
365 | >>> @check | |
370 | ... def phasecacheafterstrip(server): |
|
366 | ... def phasecacheafterstrip(server): | |
371 | ... readchannel(server) |
|
367 | ... readchannel(server) | |
372 | ... |
|
368 | ... | |
373 | ... # create new head, 5:731265503d86 |
|
369 | ... # create new head, 5:731265503d86 | |
374 | ... runcommand(server, ['update', '-C', '0']) |
|
370 | ... runcommand(server, ['update', '-C', '0']) | |
375 | ... f = open('a', 'ab') |
|
371 | ... f = open('a', 'ab') | |
376 | ... f.write('a\n') |
|
372 | ... f.write('a\n') | |
377 | ... f.close() |
|
373 | ... f.close() | |
378 | ... runcommand(server, ['commit', '-Am.', 'a']) |
|
374 | ... runcommand(server, ['commit', '-Am.', 'a']) | |
379 | ... runcommand(server, ['log', '-Gq']) |
|
375 | ... runcommand(server, ['log', '-Gq']) | |
380 | ... |
|
376 | ... | |
381 | ... # make it public; draft marker moves to 4:7966c8e3734d |
|
377 | ... # make it public; draft marker moves to 4:7966c8e3734d | |
382 | ... runcommand(server, ['phase', '-p', '.']) |
|
378 | ... runcommand(server, ['phase', '-p', '.']) | |
383 | ... # load _phasecache.phaseroots |
|
379 | ... # load _phasecache.phaseroots | |
384 | ... runcommand(server, ['phase', '.'], outfilter=sep) |
|
380 | ... runcommand(server, ['phase', '.'], outfilter=sep) | |
385 | ... |
|
381 | ... | |
386 | ... # strip 1::4 outside server |
|
382 | ... # strip 1::4 outside server | |
387 | ... os.system('hg -q --config extensions.mq= strip 1') |
|
383 | ... os.system('hg -q --config extensions.mq= strip 1') | |
388 | ... |
|
384 | ... | |
389 | ... # shouldn't raise "7966c8e3734d: no node!" |
|
385 | ... # shouldn't raise "7966c8e3734d: no node!" | |
390 | ... runcommand(server, ['branches']) |
|
386 | ... runcommand(server, ['branches']) | |
391 | runcommand update -C 0 |
|
387 | runcommand update -C 0 | |
392 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
388 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
393 | (leaving bookmark bm3) |
|
389 | (leaving bookmark bm3) | |
394 | runcommand commit -Am. a |
|
390 | runcommand commit -Am. a | |
395 | created new head |
|
391 | created new head | |
396 | runcommand log -Gq |
|
392 | runcommand log -Gq | |
397 | @ 5:731265503d86 |
|
393 | @ 5:731265503d86 | |
398 | | |
|
394 | | | |
399 | | o 4:7966c8e3734d |
|
395 | | o 4:7966c8e3734d | |
400 | | | |
|
396 | | | | |
401 | | o 3:b9b85890c400 |
|
397 | | o 3:b9b85890c400 | |
402 | | | |
|
398 | | | | |
403 | | o 2:aef17e88f5f0 |
|
399 | | o 2:aef17e88f5f0 | |
404 | | | |
|
400 | | | | |
405 | | o 1:d3a0a68be6de |
|
401 | | o 1:d3a0a68be6de | |
406 | |/ |
|
402 | |/ | |
407 | o 0:eff892de26ec |
|
403 | o 0:eff892de26ec | |
408 |
|
404 | |||
409 | runcommand phase -p . |
|
405 | runcommand phase -p . | |
410 | runcommand phase . |
|
406 | runcommand phase . | |
411 | 5: public |
|
407 | 5: public | |
412 | runcommand branches |
|
408 | runcommand branches | |
413 | default 1:731265503d86 |
|
409 | default 1:731265503d86 | |
414 |
|
410 | |||
415 | $ cat <<EOF > obs.py |
|
411 | $ cat <<EOF > obs.py | |
416 | > import mercurial.obsolete |
|
412 | > import mercurial.obsolete | |
417 | > mercurial.obsolete._enabled = True |
|
413 | > mercurial.obsolete._enabled = True | |
418 | > EOF |
|
414 | > EOF | |
419 | $ cat <<EOF >> .hg/hgrc |
|
415 | $ cat <<EOF >> .hg/hgrc | |
420 | > [extensions] |
|
416 | > [extensions] | |
421 | > obs = obs.py |
|
417 | > obs = obs.py | |
422 | > EOF |
|
418 | > EOF | |
423 |
|
419 | |||
424 | >>> import os |
|
420 | >>> import os | |
425 | >>> from hgclient import readchannel, runcommand, check |
|
421 | >>> from hgclient import readchannel, runcommand, check | |
426 | >>> @check |
|
422 | >>> @check | |
427 | ... def obsolete(server): |
|
423 | ... def obsolete(server): | |
428 | ... readchannel(server) |
|
424 | ... readchannel(server) | |
429 | ... |
|
425 | ... | |
430 | ... runcommand(server, ['up', 'null']) |
|
426 | ... runcommand(server, ['up', 'null']) | |
431 | ... runcommand(server, ['phase', '-df', 'tip']) |
|
427 | ... runcommand(server, ['phase', '-df', 'tip']) | |
432 | ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`' |
|
428 | ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`' | |
433 | ... if os.name == 'nt': |
|
429 | ... if os.name == 'nt': | |
434 | ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe |
|
430 | ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe | |
435 | ... os.system(cmd) |
|
431 | ... os.system(cmd) | |
436 | ... runcommand(server, ['log', '--hidden']) |
|
432 | ... runcommand(server, ['log', '--hidden']) | |
437 | ... runcommand(server, ['log']) |
|
433 | ... runcommand(server, ['log']) | |
438 | runcommand up null |
|
434 | runcommand up null | |
439 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
435 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
440 | runcommand phase -df tip |
|
436 | runcommand phase -df tip | |
441 | runcommand log --hidden |
|
437 | runcommand log --hidden | |
442 | changeset: 1:731265503d86 |
|
438 | changeset: 1:731265503d86 | |
443 | tag: tip |
|
439 | tag: tip | |
444 | user: test |
|
440 | user: test | |
445 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
441 | date: Thu Jan 01 00:00:00 1970 +0000 | |
446 | summary: . |
|
442 | summary: . | |
447 |
|
443 | |||
448 | changeset: 0:eff892de26ec |
|
444 | changeset: 0:eff892de26ec | |
449 | bookmark: bm1 |
|
445 | bookmark: bm1 | |
450 | bookmark: bm2 |
|
446 | bookmark: bm2 | |
451 | bookmark: bm3 |
|
447 | bookmark: bm3 | |
452 | user: test |
|
448 | user: test | |
453 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
449 | date: Thu Jan 01 00:00:00 1970 +0000 | |
454 | summary: 1 |
|
450 | summary: 1 | |
455 |
|
451 | |||
456 | runcommand log |
|
452 | runcommand log | |
457 | changeset: 0:eff892de26ec |
|
453 | changeset: 0:eff892de26ec | |
458 | bookmark: bm1 |
|
454 | bookmark: bm1 | |
459 | bookmark: bm2 |
|
455 | bookmark: bm2 | |
460 | bookmark: bm3 |
|
456 | bookmark: bm3 | |
461 | tag: tip |
|
457 | tag: tip | |
462 | user: test |
|
458 | user: test | |
463 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
459 | date: Thu Jan 01 00:00:00 1970 +0000 | |
464 | summary: 1 |
|
460 | summary: 1 | |
465 |
|
461 | |||
466 |
|
462 | |||
467 | $ cat <<EOF >> .hg/hgrc |
|
463 | $ cat <<EOF >> .hg/hgrc | |
468 | > [extensions] |
|
464 | > [extensions] | |
469 | > mq = |
|
465 | > mq = | |
470 | > EOF |
|
466 | > EOF | |
471 |
|
467 | |||
472 | >>> import os |
|
468 | >>> import os | |
473 | >>> from hgclient import readchannel, runcommand, check |
|
469 | >>> from hgclient import readchannel, runcommand, check | |
474 | >>> @check |
|
470 | >>> @check | |
475 | ... def mqoutsidechanges(server): |
|
471 | ... def mqoutsidechanges(server): | |
476 | ... readchannel(server) |
|
472 | ... readchannel(server) | |
477 | ... |
|
473 | ... | |
478 | ... # load repo.mq |
|
474 | ... # load repo.mq | |
479 | ... runcommand(server, ['qapplied']) |
|
475 | ... runcommand(server, ['qapplied']) | |
480 | ... os.system('hg qnew 0.diff') |
|
476 | ... os.system('hg qnew 0.diff') | |
481 | ... # repo.mq should be invalidated |
|
477 | ... # repo.mq should be invalidated | |
482 | ... runcommand(server, ['qapplied']) |
|
478 | ... runcommand(server, ['qapplied']) | |
483 | ... |
|
479 | ... | |
484 | ... runcommand(server, ['qpop', '--all']) |
|
480 | ... runcommand(server, ['qpop', '--all']) | |
485 | ... os.system('hg qqueue --create foo') |
|
481 | ... os.system('hg qqueue --create foo') | |
486 | ... # repo.mq should be recreated to point to new queue |
|
482 | ... # repo.mq should be recreated to point to new queue | |
487 | ... runcommand(server, ['qqueue', '--active']) |
|
483 | ... runcommand(server, ['qqueue', '--active']) | |
488 | runcommand qapplied |
|
484 | runcommand qapplied | |
489 | runcommand qapplied |
|
485 | runcommand qapplied | |
490 | 0.diff |
|
486 | 0.diff | |
491 | runcommand qpop --all |
|
487 | runcommand qpop --all | |
492 | popping 0.diff |
|
488 | popping 0.diff | |
493 | patch queue now empty |
|
489 | patch queue now empty | |
494 | runcommand qqueue --active |
|
490 | runcommand qqueue --active | |
495 | foo |
|
491 | foo | |
496 |
|
492 | |||
497 | $ cat <<EOF > dbgui.py |
|
493 | $ cat <<EOF > dbgui.py | |
498 | > from mercurial import cmdutil, commands |
|
494 | > from mercurial import cmdutil, commands | |
499 | > cmdtable = {} |
|
495 | > cmdtable = {} | |
500 | > command = cmdutil.command(cmdtable) |
|
496 | > command = cmdutil.command(cmdtable) | |
501 | > @command("debuggetpass", norepo=True) |
|
497 | > @command("debuggetpass", norepo=True) | |
502 | > def debuggetpass(ui): |
|
498 | > def debuggetpass(ui): | |
503 | > ui.write("%s\\n" % ui.getpass()) |
|
499 | > ui.write("%s\\n" % ui.getpass()) | |
504 | > EOF |
|
500 | > EOF | |
505 | $ cat <<EOF >> .hg/hgrc |
|
501 | $ cat <<EOF >> .hg/hgrc | |
506 | > [extensions] |
|
502 | > [extensions] | |
507 | > dbgui = dbgui.py |
|
503 | > dbgui = dbgui.py | |
508 | > EOF |
|
504 | > EOF | |
509 |
|
505 | |||
510 | >>> import cStringIO |
|
506 | >>> import cStringIO | |
511 | >>> from hgclient import readchannel, runcommand, check |
|
507 | >>> from hgclient import readchannel, runcommand, check | |
512 | >>> @check |
|
508 | >>> @check | |
513 | ... def getpass(server): |
|
509 | ... def getpass(server): | |
514 | ... readchannel(server) |
|
510 | ... readchannel(server) | |
515 | ... runcommand(server, ['debuggetpass', '--config', |
|
511 | ... runcommand(server, ['debuggetpass', '--config', | |
516 | ... 'ui.interactive=True'], |
|
512 | ... 'ui.interactive=True'], | |
517 | ... input=cStringIO.StringIO('1234\n')) |
|
513 | ... input=cStringIO.StringIO('1234\n')) | |
518 | runcommand debuggetpass --config ui.interactive=True |
|
514 | runcommand debuggetpass --config ui.interactive=True | |
519 | password: 1234 |
|
515 | password: 1234 | |
520 |
|
516 | |||
521 |
|
517 | |||
522 | start without repository: |
|
518 | start without repository: | |
523 |
|
519 | |||
524 | $ cd .. |
|
520 | $ cd .. | |
525 |
|
521 | |||
526 | >>> import re |
|
|||
527 | >>> from hgclient import readchannel, runcommand, check |
|
522 | >>> from hgclient import readchannel, runcommand, check | |
528 | >>> @check |
|
523 | >>> @check | |
529 | ... def hellomessage(server): |
|
524 | ... def hellomessage(server): | |
530 | ... ch, data = readchannel(server) |
|
525 | ... ch, data = readchannel(server) | |
531 | ... # escaping python tests output not supported |
|
526 | ... print '%c, %r' % (ch, data) | |
532 | ... print '%c, %r' % (ch, re.sub('encoding: [a-zA-Z0-9-]+', |
|
|||
533 | ... 'encoding: ***', data)) |
|
|||
534 | ... |
|
|||
535 | ... # run an arbitrary command to make sure the next thing the server |
|
527 | ... # run an arbitrary command to make sure the next thing the server | |
536 | ... # sends isn't part of the hello message |
|
528 | ... # sends isn't part of the hello message | |
537 | ... runcommand(server, ['id']) |
|
529 | ... runcommand(server, ['id']) | |
538 |
o, 'capabilities: getencoding runcommand\nencoding: * |
|
530 | o, 'capabilities: getencoding runcommand\nencoding: *' (glob) | |
539 | runcommand id |
|
531 | runcommand id | |
540 | abort: there is no Mercurial repository here (.hg not found) |
|
532 | abort: there is no Mercurial repository here (.hg not found) | |
541 | [255] |
|
533 | [255] | |
542 |
|
534 | |||
543 | >>> from hgclient import readchannel, runcommand, check |
|
535 | >>> from hgclient import readchannel, runcommand, check | |
544 | >>> @check |
|
536 | >>> @check | |
545 | ... def startwithoutrepo(server): |
|
537 | ... def startwithoutrepo(server): | |
546 | ... readchannel(server) |
|
538 | ... readchannel(server) | |
547 | ... runcommand(server, ['init', 'repo2']) |
|
539 | ... runcommand(server, ['init', 'repo2']) | |
548 | ... runcommand(server, ['id', '-R', 'repo2']) |
|
540 | ... runcommand(server, ['id', '-R', 'repo2']) | |
549 | runcommand init repo2 |
|
541 | runcommand init repo2 | |
550 | runcommand id -R repo2 |
|
542 | runcommand id -R repo2 | |
551 | 000000000000 tip |
|
543 | 000000000000 tip |
General Comments 0
You need to be logged in to leave comments.
Login now