bisect-kit: argtype_intra_rev should accept major version number as well

local build bisectors 'switch' command should accept not only intra
versions but also major versions.

This CL also add unittests for codechange module.

BUG=None
TEST=unittest

Change-Id: I93c24fe047e3fd554a038b9502ac1785b8c37dee
Reviewed-on: https://chromium-review.googlesource.com/1423941
Commit-Ready: Kuang-che Wu <kcwu@chromium.org>
Tested-by: Kuang-che Wu <kcwu@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index 15685ee..96db566 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -86,6 +86,12 @@
   """
 
   def argtype_function(s):
+    examples = []
+    try:
+      return argtype(s)
+    except cli.ArgTypeError as e:
+      examples += e.example
+
     m = re.match(_re_intra_rev, s)
     if m:
       try:
@@ -93,12 +99,12 @@
         argtype(m.group(2))
         return s
       except cli.ArgTypeError as e:
-        examples = []
         for example in e.example:
           examples.append(make_intra_rev(example, example, 10))
         raise cli.ArgTypeError('Invalid intra rev', examples)
-    raise cli.ArgTypeError('Invalid intra rev',
-                           [make_intra_rev('<rev1>', '<rev2>', 10)])
+
+    examples.append(make_intra_rev('<rev1>', '<rev2>', 10))
+    raise cli.ArgTypeError('Invalid rev', examples)
 
   return argtype_function