summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-03-02 12:56:08 -0800
committerShawn O. Pearce <sop@google.com>2009-03-02 12:56:08 -0800
commit559b846b17a5b720c1247d07e292150466f27f96 (patch)
tree1b0c5ed818859db0ef13b943dc005af4fbdd3289
parent7c6c64d463d3baa361ef7bef8ff3149134819c96 (diff)
downloadgit-repo-559b846b17a5b720c1247d07e292150466f27f96.tar.gz
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>
-rw-r--r--error.py4
-rwxr-xr-xmain.py4
-rw-r--r--project.py7
3 files changed, 15 insertions, 0 deletions
diff --git a/error.py b/error.py
index 029e1227..6b9dff44 100644
--- a/error.py
+++ b/error.py
@@ -17,6 +17,10 @@ class ManifestParseError(Exception):
17 """Failed to parse the manifest file. 17 """Failed to parse the manifest file.
18 """ 18 """
19 19
20class ManifestInvalidRevisionError(Exception):
21 """The revision value in a project is incorrect.
22 """
23
20class EditorError(Exception): 24class EditorError(Exception):
21 """Unspecified error from the user's text editor. 25 """Unspecified error from the user's text editor.
22 """ 26 """
diff --git a/main.py b/main.py
index be8da017..f8fcfe2d 100755
--- a/main.py
+++ b/main.py
@@ -29,6 +29,7 @@ import sys
29 29
30from command import InteractiveCommand, PagedCommand 30from command import InteractiveCommand, PagedCommand
31from editor import Editor 31from editor import Editor
32from error import ManifestInvalidRevisionError
32from error import NoSuchProjectError 33from error import NoSuchProjectError
33from error import RepoChangedException 34from error import RepoChangedException
34from manifest import Manifest 35from manifest import Manifest
@@ -94,6 +95,9 @@ class _Repo(object):
94 copts, cargs = cmd.OptionParser.parse_args(argv) 95 copts, cargs = cmd.OptionParser.parse_args(argv)
95 try: 96 try:
96 cmd.Execute(copts, cargs) 97 cmd.Execute(copts, cargs)
98 except ManifestInvalidRevisionError, e:
99 print >>sys.stderr, 'error: %s' % str(e)
100 sys.exit(1)
97 except NoSuchProjectError, e: 101 except NoSuchProjectError, e:
98 if e.name: 102 if e.name:
99 print >>sys.stderr, 'error: project %s not found' % e.name 103 print >>sys.stderr, 'error: project %s not found' % e.name
diff --git a/project.py b/project.py
index 4780316c..8cdb8b19 100644
--- a/project.py
+++ b/project.py
@@ -25,6 +25,7 @@ from color import Coloring
25from git_command import GitCommand 25from git_command import GitCommand
26from git_config import GitConfig, IsId 26from git_config import GitConfig, IsId
27from error import GitError, ImportError, UploadError 27from error import GitError, ImportError, UploadError
28from error import ManifestInvalidRevisionError
28from remote import Remote 29from remote import Remote
29 30
30HEAD = 'HEAD' 31HEAD = 'HEAD'
@@ -582,6 +583,12 @@ class Project(object):
582 583
583 rem = self.GetRemote(self.remote.name) 584 rem = self.GetRemote(self.remote.name)
584 rev = rem.ToLocal(self.revision) 585 rev = rem.ToLocal(self.revision)
586 try:
587 self.bare_git.rev_parse('--verify', '%s^0' % rev)
588 except GitError:
589 raise ManifestInvalidRevisionError(
590 'revision %s in %s not found' % (self.revision, self.name))
591
585 branch = self.CurrentBranch 592 branch = self.CurrentBranch
586 593
587 if branch is None: 594 if branch is None: