Do not fetch the CL description when using git cl status --fast.
This causes a network I/O, which is not fast. Also this is a non-starter in the
case of no network connectivity, causing a crash instead of completing
successfully. Until Air Canada provides on-flight internet, this is a
non-starter. #firstworldproblem.
Also fix git cl presubmit in case of lack of network connectivity.
R=stip@chromium.org
BUG=
Review URL: https://codereview.chromium.org/418293004
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@285911 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 7383709..ecadcfe 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -696,7 +696,7 @@
issue = self.GetIssue()
try:
self.description = self.RpcServer().get_description(issue).strip()
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
if e.code == 404:
DieWithError(
('\nWhile fetching the description for issue %d, received a '
@@ -710,6 +710,12 @@
else:
DieWithError(
'\nFailed to fetch issue description. HTTP error %d' % e.code)
+ except urllib2.URLError as e:
+ print >> sys.stderr, (
+ 'Warning: Failed to retrieve CL description due to network '
+ 'failure.')
+ self.description = ''
+
self.has_description = True
if pretty:
wrapper = textwrap.TextWrapper()
@@ -1314,8 +1320,9 @@
return 0
print cl.GetBranch()
print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL())
- print 'Issue description:'
- print cl.GetDescription(pretty=True)
+ if not options.fast:
+ print 'Issue description:'
+ print cl.GetDescription(pretty=True)
return 0