From 75ee0570da09abb1d2bbefe0d25f0560727e6b71 Mon Sep 17 00:00:00 2001 From: Conley Owens Date: Thu, 15 Nov 2012 17:33:11 -0800 Subject: Raise a NoManifestException when the manifest DNE When a command (eg, `repo forall`) expects the manifest project to exist, but there is no manifest, an IOException gets raised. This change defines a new Exception type to be raised in these cases and raises it when project.py fails to read the manifest. Change-Id: Iac576c293a37f7d8f60cd4f6aa95b2c97f9e7957 --- project.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'project.py') diff --git a/project.py b/project.py index 75c5e5e8..08b27710 100644 --- a/project.py +++ b/project.py @@ -30,6 +30,7 @@ from git_command import GitCommand, git_require from git_config import GitConfig, IsId, GetSchemeFromUrl, ID_RE from error import GitError, HookError, UploadError from error import ManifestInvalidRevisionError +from error import NoManifestException from trace import IsTrace, Trace from git_refs import GitRefs, HEAD, R_HEADS, R_TAGS, R_PUB, R_M @@ -1894,7 +1895,10 @@ class Project(object): path = os.path.join(self._project.gitdir, HEAD) else: path = os.path.join(self._project.worktree, '.git', HEAD) - fd = open(path, 'rb') + try: + fd = open(path, 'rb') + except IOError: + raise NoManifestException(path) try: line = fd.read() finally: -- cgit v1.2.3-54-g00ecf