mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Merge "Simplify error handling in subcommand execution"
This commit is contained in:
commit
e66291f6d0
31
main.py
31
main.py
@ -131,32 +131,31 @@ class _Repo(object):
|
|||||||
if use_pager:
|
if use_pager:
|
||||||
RunPager(config)
|
RunPager(config)
|
||||||
|
|
||||||
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
start = time.time()
|
result = cmd.Execute(copts, cargs)
|
||||||
try:
|
|
||||||
result = cmd.Execute(copts, cargs)
|
|
||||||
finally:
|
|
||||||
elapsed = time.time() - start
|
|
||||||
hours, remainder = divmod(elapsed, 3600)
|
|
||||||
minutes, seconds = divmod(remainder, 60)
|
|
||||||
if gopts.time:
|
|
||||||
if hours == 0:
|
|
||||||
print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr)
|
|
||||||
else:
|
|
||||||
print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
|
|
||||||
file=sys.stderr)
|
|
||||||
except DownloadError as e:
|
except DownloadError as e:
|
||||||
print('error: %s' % str(e), file=sys.stderr)
|
print('error: %s' % str(e), file=sys.stderr)
|
||||||
return 1
|
result = 1
|
||||||
except ManifestInvalidRevisionError as e:
|
except ManifestInvalidRevisionError as e:
|
||||||
print('error: %s' % str(e), file=sys.stderr)
|
print('error: %s' % str(e), file=sys.stderr)
|
||||||
return 1
|
result = 1
|
||||||
except NoSuchProjectError as e:
|
except NoSuchProjectError as e:
|
||||||
if e.name:
|
if e.name:
|
||||||
print('error: project %s not found' % e.name, file=sys.stderr)
|
print('error: project %s not found' % e.name, file=sys.stderr)
|
||||||
else:
|
else:
|
||||||
print('error: no project in current directory', file=sys.stderr)
|
print('error: no project in current directory', file=sys.stderr)
|
||||||
return 1
|
result = 1
|
||||||
|
finally:
|
||||||
|
elapsed = time.time() - start
|
||||||
|
hours, remainder = divmod(elapsed, 3600)
|
||||||
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
if gopts.time:
|
||||||
|
if hours == 0:
|
||||||
|
print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr)
|
||||||
|
else:
|
||||||
|
print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
|
||||||
|
file=sys.stderr)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user