summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-05-20 01:48:17 -0400
committerMike Frysinger <vapier@google.com>2021-05-20 06:15:38 +0000
commitb16b9d26bd2d05d704da3e38f3eee743f2b110c6 (patch)
treefba30d471d916a98592f3170dba8b4138fb28424 /project.py
parent993af5e136030ba9822f9a19e338e35ecc9581c7 (diff)
downloadgit-repo-b16b9d26bd2d05d704da3e38f3eee743f2b110c6.tar.gz
project: fix error display when output_redir is disabledv2.15.2
We always pass in output_redir when syncing, but that's the common case: there are a few situations (like `repo init`) where we don't pass in a buffer, and if any errors show up in that case, we'd crash. Rely on the print function to handle this logic for us. Bug: https://crbug.com/gerrit/14568 Change-Id: I8cd47e82329797ffc42534418a3dfbd8429205be Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/307222 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/project.py b/project.py
index 2f83d796..2ab0b389 100644
--- a/project.py
+++ b/project.py
@@ -2197,7 +2197,7 @@ class Project(object):
2197 ret = prunecmd.Wait() 2197 ret = prunecmd.Wait()
2198 if ret: 2198 if ret:
2199 break 2199 break
2200 output_redir.write('retrying fetch after pruning remote branches') 2200 print('retrying fetch after pruning remote branches', file=output_redir)
2201 # Continue right away so we don't sleep as we shouldn't need to. 2201 # Continue right away so we don't sleep as we shouldn't need to.
2202 continue 2202 continue
2203 elif current_branch_only and is_sha1 and ret == 128: 2203 elif current_branch_only and is_sha1 and ret == 128:
@@ -2210,10 +2210,11 @@ class Project(object):
2210 break 2210 break
2211 2211
2212 # Figure out how long to sleep before the next attempt, if there is one. 2212 # Figure out how long to sleep before the next attempt, if there is one.
2213 if not verbose: 2213 if not verbose and gitcmd.stdout:
2214 output_redir.write('\n%s:\n%s' % (self.name, gitcmd.stdout)) 2214 print('\n%s:\n%s' % (self.name, gitcmd.stdout), end='', file=output_redir)
2215 if try_n < retry_fetches - 1: 2215 if try_n < retry_fetches - 1:
2216 output_redir.write('sleeping %s seconds before retrying' % retry_cur_sleep) 2216 print('%s: sleeping %s seconds before retrying' % (self.name, retry_cur_sleep),
2217 file=output_redir)
2217 time.sleep(retry_cur_sleep) 2218 time.sleep(retry_cur_sleep)
2218 retry_cur_sleep = min(retry_exp_factor * retry_cur_sleep, 2219 retry_cur_sleep = min(retry_exp_factor * retry_cur_sleep,
2219 MAXIMUM_RETRY_SLEEP_SEC) 2220 MAXIMUM_RETRY_SLEEP_SEC)