[PATCH 3 of 6] test for int 0 as rev argument

Simon Heimberg simohe at besonet.ch
Sun Sep 11 10:46:23 CDT 2011


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1315412550 -7200
# Node ID aa38d95881065c24eb4a8bc441cb2514c166c32e
# Parent  d6e84a781824ee3cce1571bda167a18a6d8f042f
test for int 0 as rev argument

tests issue2992

diff -r d6e84a781824 -r aa38d9588106 tests/test-status-inprocess.py
--- a/tests/test-status-inprocess.py	Mit Sep 07 22:21:40 2011 +0200
+++ b/tests/test-status-inprocess.py	Mit Sep 07 18:22:30 2011 +0200
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 from mercurial.ui import ui
 from mercurial.localrepo import localrepository
-from mercurial.commands import add, commit, status
+from mercurial.commands import add, commit, status, identify
 
 u = ui()
 
@@ -29,3 +29,48 @@
 
 # this would return clean instead of changed before the fix
 status(u, repo, clean=True, modified=True)
+
+f = open('test2', 'w')
+try:
+    f.write('test\n')
+finally:
+    f.close
+add(u, repo, 'test2')
+commit(u, repo, 'test2', message='#2')
+
+# test singlerev
+print '% status and identify'
+identify(u, repo, num=True, tags=True)
+
+# "" means working directory
+status(u, repo, rev="")
+identify(u, repo, rev="", num=True, tags=True)
+
+# "." means parent
+status(u, repo, rev=".")
+identify(u, repo, rev=".", num=True, tags=True)
+
+print " % rev 0"
+
+# "0" means revision 0
+status(u, repo, rev="0")
+identify(u, repo, rev="0", num=True, tags=True)
+
+# create comparision data
+e1 = None
+u.pushbuffer() # no output
+try:
+    status(u, repo, rev=1)
+except Exception, e:
+    e1 = e
+u.popbuffer()
+
+# rev 0 (numeric) means revision 0, #2992
+try:
+    status(u, repo, rev=0)
+except Exception, e:
+    if repr(e) == repr(e1):
+        print "valid Exception"
+    else:
+        print "invalid Exception", repr(e), "instead of", repr(e1)
+identify(u, repo, rev=0, num=True, tags=True)
diff -r d6e84a781824 -r aa38d9588106 tests/test-status-inprocess.py.out
--- a/tests/test-status-inprocess.py.out	Mit Sep 07 22:21:40 2011 +0200
+++ b/tests/test-status-inprocess.py.out	Mit Sep 07 18:22:30 2011 +0200
@@ -3,3 +3,15 @@
 C test.py
 % change
 M test.py
+% status and identify
+1+ tip
+M test.py
+1+ tip
+M test.py
+1 tip
+ % rev 0
+M test.py
+A test2
+0
+valid Exception
+0


More information about the Mercurial-devel mailing list