| 1 |
import os |
| 2 |
from mercurial import ( |
| 3 |
dispatch, |
| 4 |
extensions, |
| 5 |
main_script, |
| 6 |
ui as uimod, |
| 7 |
) |
| 8 |
|
| 9 |
|
| 10 |
def testdispatch(cmd): |
| 11 |
"""Simple wrapper around dispatch.dispatch() |
| 12 |
|
| 13 |
Prints command and result value, but does not handle quoting. |
| 14 |
""" |
| 15 |
ui = uimod.ui.load() |
| 16 |
extensions.populateui(ui) |
| 17 |
ui.statusnoi18n(b"running: %s\n" % cmd) |
| 18 |
req = main_script.request(cmd.split(), ui) |
| 19 |
result = dispatch.dispatch(req) |
| 20 |
ui.statusnoi18n(b"result: %r\n" % result) |
| 21 |
|
| 22 |
|
| 23 |
# create file 'foo', add and commit |
| 24 |
f = open(b'foo', 'wb') |
| 25 |
f.write(b'foo\n') |
| 26 |
f.close() |
| 27 |
testdispatch(b"--debug add foo") |
| 28 |
testdispatch(b"--debug commit -m commit1 -d 2000-01-01 foo") |
| 29 |
|
| 30 |
# append to file 'foo' and commit |
| 31 |
f = open(b'foo', 'ab') |
| 32 |
f.write(b'bar\n') |
| 33 |
f.close() |
| 34 |
# remove blackbox.log directory (proxy for readonly log file) |
| 35 |
os.rmdir(b".hg/blackbox.log") |
| 36 |
# replace it with the real blackbox.log file |
| 37 |
os.rename(b".hg/blackbox.log-", b".hg/blackbox.log") |
| 38 |
testdispatch(b"--debug commit -m commit2 -d 2000-01-02 foo") |
| 39 |
|
| 40 |
# check 88803a69b24 (fancyopts modified command table) |
| 41 |
testdispatch(b"--debug log -r 0") |
| 42 |
testdispatch(b"--debug log -r tip") |