From ddab0604eee41e26572f0cf9f3fd5ff7a0637594 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 25 Mar 2021 01:58:20 -0400 Subject: [PATCH] forall: handle missing project refs better If the project exists, but the ref the manifest wants doesn't exist, don't throw an error (and abort the process in general). This can come up with a partially synced tree: the manifest is up-to-date, but not all the projects have yet been synced. Bug: https://crbug.com/gerrit/14289 Change-Id: Iba97413c476544223ffe518198c900c2193a00ed Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/301262 Reviewed-by: LaMont Jones Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- subcmds/forall.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/subcmds/forall.py b/subcmds/forall.py index aa998d20..f0ce97cb 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -24,6 +24,7 @@ import subprocess from color import Coloring from command import DEFAULT_LOCAL_JOBS, Command, MirrorSafeCommand, WORKER_BATCH_SIZE +from error import ManifestInvalidRevisionError _CAN_COLOR = [ 'branch', @@ -252,7 +253,7 @@ without iterating through the remaining projects. rc = rc or errno.EINTR except Exception as e: # Catch any other exceptions raised - print('Got an error, terminating the pool: %s: %s' % + print('forall: unhandled error, terminating the pool: %s: %s' % (type(e).__name__, e), file=sys.stderr) rc = rc or getattr(e, 'errno', 1) @@ -295,7 +296,13 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): setenv('REPO_PROJECT', project.name) setenv('REPO_PATH', project.relpath) setenv('REPO_REMOTE', project.remote.name) - setenv('REPO_LREV', '' if mirror else project.GetRevisionId()) + try: + # If we aren't in a fully synced state and we don't have the ref the manifest + # wants, then this will fail. Ignore it for the purposes of this code. + lrev = '' if mirror else project.GetRevisionId() + except ManifestInvalidRevisionError: + lrev = '' + setenv('REPO_LREV', lrev) setenv('REPO_RREV', project.revisionExpr) setenv('REPO_UPSTREAM', project.upstream) setenv('REPO_DEST_BRANCH', project.dest_branch)