tests/test-dispatch.py
changeset 5185 18a9fbb5cd78
parent 5147 f3f033def181
equal deleted inserted replaced
5184:92236732d5a1 5185:18a9fbb5cd78
     1 import os
     1 import os
     2 from mercurial import commands
     2 from mercurial import dispatch
     3 
     3 
     4 def dispatch(cmd):
     4 def testdispatch(cmd):
     5     """Simple wrapper around commands.dispatch()
     5     """Simple wrapper around dispatch.dispatch()
     6 
     6 
     7     Prints command and result value, but does not handle quoting.
     7     Prints command and result value, but does not handle quoting.
     8     """
     8     """
     9     print "running: %s" % (cmd,)
     9     print "running: %s" % (cmd,)
    10     result = commands.dispatch(cmd.split())
    10     result = dispatch.dispatch(cmd.split())
    11     print "result: %r" % (result,)
    11     print "result: %r" % (result,)
    12 
    12 
    13 
    13 
    14 dispatch("init test1")
    14 testdispatch("init test1")
    15 os.chdir('test1')
    15 os.chdir('test1')
    16 
    16 
    17 # create file 'foo', add and commit
    17 # create file 'foo', add and commit
    18 f = file('foo', 'wb')
    18 f = file('foo', 'wb')
    19 f.write('foo\n')
    19 f.write('foo\n')
    20 f.close()
    20 f.close()
    21 dispatch("add foo")
    21 testdispatch("add foo")
    22 dispatch("commit -m commit1 -d 2000-01-01 foo")
    22 testdispatch("commit -m commit1 -d 2000-01-01 foo")
    23 
    23 
    24 # append to file 'foo' and commit
    24 # append to file 'foo' and commit
    25 f = file('foo', 'ab')
    25 f = file('foo', 'ab')
    26 f.write('bar\n')
    26 f.write('bar\n')
    27 f.close()
    27 f.close()
    28 dispatch("commit -m commit2 -d 2000-01-02 foo")
    28 testdispatch("commit -m commit2 -d 2000-01-02 foo")
    29 
    29 
    30 # check 88803a69b24 (fancyopts modified command table)
    30 # check 88803a69b24 (fancyopts modified command table)
    31 dispatch("log -r 0")
    31 testdispatch("log -r 0")
    32 dispatch("log -r tip")
    32 testdispatch("log -r tip")