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