summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorDan Sandler <dsandler@android.com>2014-03-09 13:20:02 -0400
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2014-03-11 05:33:43 +0000
commit53e902a19b0b80e07ac55966d13c5c84c5b0e8ce (patch)
treee804b3826be8d5bb6153f2f9f4e482191e8b8642 /main.py
parent093fdb6587bba081c4d34eb9ea500149b1090280 (diff)
downloadgit-repo-53e902a19b0b80e07ac55966d13c5c84c5b0e8ce.tar.gz
More verbose errors for NoManifestExceptions.
The old "manifest required for this command -- please run init" is replaced by a more helpful message that lists the command repo was trying to execute (with arguments) as well as the str() of the NoManifestException. For example: > error: in `sync`: [Errno 2] No such file or directory: > 'path/to/.repo/manifests/.git/HEAD' > error: manifest missing or unreadable -- please run init Other failure points in basic command parsing and dispatch are more clearly explained in the same fashion. Change-Id: I6212e5c648bc5d57e27145d55a5391ca565e4149
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/main.py b/main.py
index 36617762..72fb39b0 100755
--- a/main.py
+++ b/main.py
@@ -129,8 +129,15 @@ class _Repo(object):
129 file=sys.stderr) 129 file=sys.stderr)
130 return 1 130 return 1
131 131
132 copts, cargs = cmd.OptionParser.parse_args(argv) 132 try:
133 copts = cmd.ReadEnvironmentOptions(copts) 133 copts, cargs = cmd.OptionParser.parse_args(argv)
134 copts = cmd.ReadEnvironmentOptions(copts)
135 except NoManifestException as e:
136 print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
137 file=sys.stderr)
138 print('error: manifest missing or unreadable -- please run init',
139 file=sys.stderr)
140 return 1
134 141
135 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand): 142 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
136 config = cmd.manifest.globalConfig 143 config = cmd.manifest.globalConfig
@@ -146,15 +153,13 @@ class _Repo(object):
146 start = time.time() 153 start = time.time()
147 try: 154 try:
148 result = cmd.Execute(copts, cargs) 155 result = cmd.Execute(copts, cargs)
149 except DownloadError as e: 156 except (DownloadError, ManifestInvalidRevisionError,
150 print('error: %s' % str(e), file=sys.stderr) 157 NoManifestException) as e:
151 result = 1 158 print('error: in `%s`: %s' % (' '.join([name] + argv), str(e)),
152 except ManifestInvalidRevisionError as e: 159 file=sys.stderr)
153 print('error: %s' % str(e), file=sys.stderr) 160 if isinstance(e, NoManifestException):
154 result = 1 161 print('error: manifest missing or unreadable -- please run init',
155 except NoManifestException as e: 162 file=sys.stderr)
156 print('error: manifest required for this command -- please run init',
157 file=sys.stderr)
158 result = 1 163 result = 1
159 except NoSuchProjectError as e: 164 except NoSuchProjectError as e:
160 if e.name: 165 if e.name: