Report better errors when a project revision is invalid

If a manifest specifies an invalid revision property, give the
user a better error message detaling the problem, instead of an
ugly Python traceback with a strange Git error message.

Bug: REPO-2
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/project.py b/project.py
index 4780316..8cdb8b1 100644
--- a/project.py
+++ b/project.py
@@ -25,6 +25,7 @@
 from git_command import GitCommand
 from git_config import GitConfig, IsId
 from error import GitError, ImportError, UploadError
+from error import ManifestInvalidRevisionError
 from remote import Remote
 
 HEAD    = 'HEAD'
@@ -582,6 +583,12 @@
 
     rem = self.GetRemote(self.remote.name)
     rev = rem.ToLocal(self.revision)
+    try:
+      self.bare_git.rev_parse('--verify', '%s^0' % rev)
+    except GitError:
+      raise ManifestInvalidRevisionError(
+        'revision %s in %s not found' % (self.revision, self.name))
+
     branch = self.CurrentBranch
 
     if branch is None: