1 from __future__ import absolute_import, print_function |
1 from __future__ import absolute_import, print_function |
2 import os |
2 import os |
3 import sys |
3 import sys |
4 from mercurial import ( |
4 from mercurial import dispatch |
5 dispatch, |
5 |
6 ) |
|
7 |
6 |
8 def printb(data, end=b'\n'): |
7 def printb(data, end=b'\n'): |
9 out = getattr(sys.stdout, 'buffer', sys.stdout) |
8 out = getattr(sys.stdout, 'buffer', sys.stdout) |
10 out.write(data + end) |
9 out.write(data + end) |
11 out.flush() |
10 out.flush() |
|
11 |
12 |
12 |
13 def testdispatch(cmd): |
13 def testdispatch(cmd): |
14 """Simple wrapper around dispatch.dispatch() |
14 """Simple wrapper around dispatch.dispatch() |
15 |
15 |
16 Prints command and result value, but does not handle quoting. |
16 Prints command and result value, but does not handle quoting. |
17 """ |
17 """ |
18 printb(b"running: %s" % (cmd,)) |
18 printb(b"running: %s" % (cmd,)) |
19 req = dispatch.request(cmd.split()) |
19 req = dispatch.request(cmd.split()) |
20 result = dispatch.dispatch(req) |
20 result = dispatch.dispatch(req) |
21 printb(b"result: %r" % (result,)) |
21 printb(b"result: %r" % (result,)) |
|
22 |
22 |
23 |
23 testdispatch(b"init test1") |
24 testdispatch(b"init test1") |
24 os.chdir('test1') |
25 os.chdir('test1') |
25 |
26 |
26 # create file 'foo', add and commit |
27 # create file 'foo', add and commit |