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