Mercurial > hg
annotate tests/test-dispatch.py @ 7958:73fa2be69ea9
Fix how setup.py identifies the Mercurial version.
There is a problem with setup.py where it will not identify the Mercurial
version properly when not being ran in within a repository even if
mercurial/__version__.py exists.
To fix, use mercurial.__version__.version when available before defaulting
to "unknown". (Using mercurial.util.version() is not an option due to a
dependency issue where osutil can be referenced before it is built.)
author | Jeremy Whitlock <jcscoobyrs@gmail.com> |
---|---|
date | Thu, 02 Apr 2009 18:18:43 -0600 |
parents | 18a9fbb5cd78 |
children | 3b76321aa0de |
rev | line source |
---|---|
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
1 import os |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
2 from mercurial import dispatch |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
3 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
4 def testdispatch(cmd): |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
5 """Simple wrapper around dispatch.dispatch() |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
6 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
7 Prints command and result value, but does not handle quoting. |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
8 """ |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
9 print "running: %s" % (cmd,) |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
10 result = dispatch.dispatch(cmd.split()) |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
11 print "result: %r" % (result,) |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
12 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
13 |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
14 testdispatch("init test1") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
15 os.chdir('test1') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
16 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
17 # create file 'foo', add and commit |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
18 f = file('foo', 'wb') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
19 f.write('foo\n') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
20 f.close() |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
21 testdispatch("add foo") |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
22 testdispatch("commit -m commit1 -d 2000-01-01 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
23 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
24 # append to file 'foo' and commit |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
25 f = file('foo', 'ab') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
26 f.write('bar\n') |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
27 f.close() |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
28 testdispatch("commit -m commit2 -d 2000-01-02 foo") |
5095
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
29 |
f3f033def181
Added test for commands.dispatch (especially 88803a69b24)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff
changeset
|
30 # check 88803a69b24 (fancyopts modified command table) |
5178
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
31 testdispatch("log -r 0") |
18a9fbb5cd78
dispatch: move command dispatching into its own module
Matt Mackall <mpm@selenic.com>
parents:
5095
diff
changeset
|
32 testdispatch("log -r tip") |