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.

Change-Id: Iba97413c476544223ffe518198c900c2193a00ed
Reviewed-by: LaMont Jones <>
Reviewed-by: Mike Frysinger <>
Tested-by: Mike Frysinger <>
diff --git a/subcmds/ b/subcmds/
index aa998d2..f0ce97c 100644
--- a/subcmds/
+++ b/subcmds/
@@ -24,6 +24,7 @@
 from color import Coloring
 from command import DEFAULT_LOCAL_JOBS, Command, MirrorSafeCommand, WORKER_BATCH_SIZE
+from error import ManifestInvalidRevisionError
@@ -252,7 +253,7 @@
       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),
       rc = rc or getattr(e, 'errno', 1)
@@ -295,7 +296,13 @@
   setenv('REPO_PATH', project.relpath)
-  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)