checkout: Add option to disable branch matching

Previously, if on an Android repo tool project, a CL with branch 'foo'
would cause the builder to check if the manifest also had branch 'foo'.
If it did, that branch would be checked out.

Now, make this behavior optional. If match_branch is set, do this,
otherwise just use the default branch of the manifest.

Also, split logic for finding matching branches into a separate
function.

Change-Id: I0cf4a72714d5fe7383b750d9b0b3803f6512014c
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/73380
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index f97dda2..e467a8c 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -168,6 +168,7 @@
         self._submodule_data = {}
         self._equivalent_remotes = {}
         self._force_no_rebase = props.force_no_rebase
+        self._match_branch = props.match_branch
         self.props = props
 
     def initialize(self):
@@ -770,6 +771,70 @@
 
             return status_of_changes
 
+    def _matching_branch(self, changes, remote):
+        """Return if there are manifest branches that match the triggering CLs.
+
+        If the triggering change is on a branch name that is also present in the
+        manifest or superproject remote, use that branch when checking out the
+        project.
+
+        Args:
+            changes (seq of _Change): Triggering changes.
+            remote (str): URL of manifest or superproject.
+
+        Raises:
+            StepFailure if there are multiple matching branches.
+
+        Returns:
+            One matching branch name, or None.
+        """
+        if not self._match_branch:
+            with self.m.step.nest('not matching branch names'):
+                return
+
+        manifest_branch = None
+        branch_names = sorted(
+            set(
+                x.branch
+                for x in changes
+                if x.branch not in ('master', 'main', None)
+            )
+        )
+
+        if not branch_names:
+            with self.m.step.nest('no non-standard branch names'):
+                return
+
+        with self.m.step.nest('branch names') as pres:
+            pres.step_summary_text = str(branch_names)
+
+        matching_branches = self._matching_branches(
+            remote, branch_names, name='manifest has branch'
+        )
+        if not matching_branches:
+            with self.m.step.nest('no branch names match'):
+                return
+
+        if len(matching_branches) > 1:
+            with self.m.step.nest(
+                'too many matching branches ({})'.format(
+                    ', '.join(matching_branches)
+                )
+            ) as pres:
+                pres.step_summary_text = (
+                    "Can't figure out which manifest "
+                    'branch to use. Remove some '
+                    '"Requires:" lines to simplify the '
+                    'checkout.'
+                )
+                raise self.m.step.StepFailure('multiple matching branches')
+
+        manifest_branch = matching_branches.pop()
+        self.m.step(
+            'changing manifest branch to {}'.format(manifest_branch), None,
+        )
+        return manifest_branch
+
     def _repo(self, remote, branch, manifest_file, use_trigger, root, changes):
         """Checkout code from an Android Repo Tool manifest.
 
@@ -797,48 +862,7 @@
         with self.m.context(cwd=root):
             remote = remote.rstrip('/')
 
-            # If the triggering change is on a branch name that is also present
-            # in the manifest branch, use that manifest branch when checking
-            # out the manifest.
-            manifest_branch = branch
-            branch_names = sorted(
-                set(
-                    x.branch
-                    for x in changes
-                    if x.branch not in ('master', 'main', None)
-                )
-            )
-
-            if branch_names:
-                with self.m.step.nest('branch names') as pres:
-                    pres.step_summary_text = str(branch_names)
-                if changes:
-                    matching_branches = self._matching_branches(
-                        remote, branch_names, name='manifest has branch'
-                    )
-                    if matching_branches:
-                        if len(matching_branches) > 1:
-                            with self.m.step.nest(
-                                'too many matching branches ({})'.format(
-                                    ', '.join(matching_branches)
-                                )
-                            ) as pres:
-                                pres.step_summary_text = (
-                                    "Can't figure out which manifest branch to "
-                                    'use. Remove some "Requires:" lines to '
-                                    'simplify the checkout.'
-                                )
-                                raise self.m.step.StepFailure(
-                                    'too many matching branches'
-                                )
-                        else:
-                            manifest_branch = matching_branches.pop()
-                            self.m.step(
-                                'changing manifest branch to {}'.format(
-                                    manifest_branch
-                                ),
-                                None,
-                            )
+            manifest_branch = self._matching_branch(changes, remote) or branch
 
             with self.m.context(infra_steps=True):
                 kwargs = {}
diff --git a/recipe_modules/checkout/properties.proto b/recipe_modules/checkout/properties.proto
index 82e2e1c..3122f18 100644
--- a/recipe_modules/checkout/properties.proto
+++ b/recipe_modules/checkout/properties.proto
@@ -69,4 +69,9 @@
   // In try builds CLs are rebased by default. In ci builds they are not. This
   // option prevents rebasing on try builds.
   bool force_no_rebase = 9;
+
+  // If a tryjob is triggered by a CL on branch 'foo', try to use branch 'foo'
+  // of any superprojects or manifests containing the CL's repo as a submodule
+  // or project. (Note: branch matching is not yet implemented for submodules.)
+  bool match_branch = 10;
 }
diff --git a/recipe_modules/checkout/test_api.py b/recipe_modules/checkout/test_api.py
index 2438a36..78c73ae 100644
--- a/recipe_modules/checkout/test_api.py
+++ b/recipe_modules/checkout/test_api.py
@@ -105,6 +105,7 @@
             remote_group.remotes.extend(remotes)
             props.equivalent_remotes.extend([remote_group])
         props.force_no_rebase = kwargs.pop('force_no_rebase', False)
+        props.match_branch = kwargs.pop('match_branch', True)
         assert not kwargs
         return {'$pigweed/checkout': props}
 
diff --git a/recipe_modules/checkout/tests/repo.expected/ci.json b/recipe_modules/checkout/tests/repo.expected/ci.json
index 5e1efad..d4b642a 100644
--- a/recipe_modules/checkout/tests/repo.expected/ci.json
+++ b/recipe_modules/checkout/tests/repo.expected/ci.json
@@ -174,6 +174,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_matches.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_matches.json
index 3aece31..ecc189f 100644
--- a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_matches.json
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_multiple_matches.json
@@ -572,7 +572,7 @@
   {
     "failure": {
       "failure": {},
-      "humanReason": "too many matching branches"
+      "humanReason": "multiple matching branches"
     },
     "name": "$result"
   }
diff --git a/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
new file mode 100644
index 0000000..4e3cf02
--- /dev/null
+++ b/recipe_modules/checkout/tests/repo.expected/feature_branches_try_no_matching.json
@@ -0,0 +1,1809 @@
+[
+  {
+    "cmd": [],
+    "name": "checkout pigweed",
+    "~followup_annotations": [
+      "@@@STEP_LINK@applied pigweed:1234@https://pigweed-review.googlesource.com/c/1234@@@",
+      "@@@STEP_LINK@applied default:2345@https://default-review.googlesource.com/c/2345@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.0",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.0.ensure gerrit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "RECIPE_MODULE[fuchsia::gerrit]/resources/tool_manifest.json",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.0.ensure gerrit.read manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@",
+      "@@@STEP_LOG_LINE@tool_manifest.json@{@@@",
+      "@@@STEP_LOG_LINE@tool_manifest.json@  \"path\": \"path/to/gerrit\",@@@",
+      "@@@STEP_LOG_LINE@tool_manifest.json@  \"version\": \"version:pinned-version\"@@@",
+      "@@@STEP_LOG_LINE@tool_manifest.json@}@@@",
+      "@@@STEP_LOG_END@tool_manifest.json@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.0.ensure gerrit.install path/to/gerrit",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@5@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.0.ensure gerrit.install path/to/gerrit.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version",
+      "-ensure-file",
+      "path/to/gerrit version:pinned-version",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.0.ensure gerrit.install path/to/gerrit.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@6@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"result\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@      {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"instance_id\": \"resolved-instance_id-of-version:pinned-v\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"path/to/gerrit\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version/gerrit",
+      "change-detail",
+      "-host",
+      "https://pigweed-review.googlesource.com",
+      "-input",
+      "{\"change_id\": \"1234\"}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.0.details",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"branch\": \"feature1\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"change_id\": \"1234\"@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@",
+      "@@@STEP_LINK@gerrit link@https://pigweed-review.googlesource.com/q/1234@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.1",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version/gerrit",
+      "change-detail",
+      "-host",
+      "https://default-review.googlesource.com",
+      "-input",
+      "{\"change_id\": \"2345\"}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.1.details",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"branch\": \"feature2\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"change_id\": \"2345\"@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@",
+      "@@@STEP_LINK@gerrit link@https://default-review.googlesource.com/q/2345@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version/gerrit",
+      "change-detail",
+      "-host",
+      "https://default-review.googlesource.com",
+      "-input",
+      "{\"change_id\": \"2345\", \"params\": {\"o\": [\"CURRENT_COMMIT\", \"CURRENT_REVISION\"]}}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.details default:2345",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"current_revision\": \"HASH\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"project\": \"project\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"revisions\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"HASH\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@      \"_number\": 1, @@@",
+      "@@@STEP_LOG_LINE@json.output@      \"commit\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"message\": \"\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"parents\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@          {@@@",
+      "@@@STEP_LOG_LINE@json.output@            \"commit\": \"PARENT\"@@@",
+      "@@@STEP_LOG_LINE@json.output@          }@@@",
+      "@@@STEP_LOG_LINE@json.output@        ]@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    }@@@",
+      "@@@STEP_LOG_LINE@json.output@  }, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"status\": \"NEW\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"change_id\": \"2345\", @@@",
+      "@@@STEP_LOG_LINE@json.input@  \"params\": {@@@",
+      "@@@STEP_LOG_LINE@json.input@    \"o\": [@@@",
+      "@@@STEP_LOG_LINE@json.input@      \"CURRENT_COMMIT\", @@@",
+      "@@@STEP_LOG_LINE@json.input@      \"CURRENT_REVISION\"@@@",
+      "@@@STEP_LOG_LINE@json.input@    ]@@@",
+      "@@@STEP_LOG_LINE@json.input@  }@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@",
+      "@@@STEP_LINK@gerrit link@https://default-review.googlesource.com/q/2345@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version/gerrit",
+      "change-query",
+      "-host",
+      "https://default-review.googlesource.com",
+      "-input",
+      "{\"params\": {\"q\": \"commit:PARENT\"}}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.number PARENT",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_LOG_LINE@json.output@[@@@",
+      "@@@STEP_LOG_LINE@json.output@  {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"_number\": 458@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@]@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"params\": {@@@",
+      "@@@STEP_LOG_LINE@json.input@    \"q\": \"commit:PARENT\"@@@",
+      "@@@STEP_LOG_LINE@json.input@  }@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/path/to/gerrit/version%3Apinned-version/gerrit",
+      "change-detail",
+      "-host",
+      "https://default-review.googlesource.com",
+      "-input",
+      "{\"change_id\": \"458\", \"params\": {\"o\": [\"CURRENT_COMMIT\", \"CURRENT_REVISION\"]}}",
+      "-output",
+      "/path/to/tmp/json"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.details default:458",
+    "timeout": 30,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_LOG_LINE@json.output@{@@@",
+      "@@@STEP_LOG_LINE@json.output@  \"current_revision\": \"HASH\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"project\": \"project\", @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"revisions\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@    \"HASH\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@      \"_number\": 1, @@@",
+      "@@@STEP_LOG_LINE@json.output@      \"commit\": {@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"message\": \"\", @@@",
+      "@@@STEP_LOG_LINE@json.output@        \"parents\": [@@@",
+      "@@@STEP_LOG_LINE@json.output@          {@@@",
+      "@@@STEP_LOG_LINE@json.output@            \"commit\": \"PARENT\"@@@",
+      "@@@STEP_LOG_LINE@json.output@          }@@@",
+      "@@@STEP_LOG_LINE@json.output@        ]@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    }@@@",
+      "@@@STEP_LOG_LINE@json.output@  }, @@@",
+      "@@@STEP_LOG_LINE@json.output@  \"status\": \"SUBMITTED\"@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@",
+      "@@@STEP_LOG_LINE@json.input@{@@@",
+      "@@@STEP_LOG_LINE@json.input@  \"change_id\": \"458\", @@@",
+      "@@@STEP_LOG_LINE@json.input@  \"params\": {@@@",
+      "@@@STEP_LOG_LINE@json.input@    \"o\": [@@@",
+      "@@@STEP_LOG_LINE@json.input@      \"CURRENT_COMMIT\", @@@",
+      "@@@STEP_LOG_LINE@json.input@      \"CURRENT_REVISION\"@@@",
+      "@@@STEP_LOG_LINE@json.input@    ]@@@",
+      "@@@STEP_LOG_LINE@json.input@  }@@@",
+      "@@@STEP_LOG_LINE@json.input@}@@@",
+      "@@@STEP_LOG_END@json.input@@@",
+      "@@@STEP_LINK@gerrit link@https://default-review.googlesource.com/q/458@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.parents default:2345",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_SUMMARY_TEXT@all parents already submitted@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.resolve deps for default:2345",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@",
+      "@@@STEP_SUMMARY_TEXT@no dependencies@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.process gerrit changes.resolve CL deps.pass",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@4@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes.pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_SUMMARY_TEXT@_Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='refs/changes/34/1234/1', rebase=True, branch='feature1', gerrit_name='pigweed', submitted=False, base=None, base_type=None)@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.change data.changes.default:2345",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@3@@@",
+      "@@@STEP_SUMMARY_TEXT@_Change(number=2345, remote='https://default.googlesource.com/default_name', ref='refs/changes/45/2345/1', rebase=True, branch='feature2', gerrit_name='default', submitted=False, base=None, base_type=None)@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/checkout"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir checkout",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.not matching branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "init",
+      "--manifest-url",
+      "https://pigweed.googlesource.com/pigweed/manifest",
+      "--groups",
+      "all",
+      "--manifest-branch",
+      "main",
+      "--manifest-name",
+      "default.xml"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo init",
+    "timeout": 20,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "find",
+      ".repo/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear repo locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "forall",
+      "--ignore-missing",
+      "-j",
+      "32",
+      "-c",
+      "find",
+      ".git/",
+      "-type",
+      "f",
+      "-name",
+      "*.lock",
+      "-print",
+      "-delete"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.clear git locks",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.read manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@raw@<manifest>@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <remote@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <default@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@raw@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@raw@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@@@@",
+      "@@@STEP_LOG_LINE@raw@  <project@@@",
+      "@@@STEP_LOG_LINE@raw@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@raw@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@raw@    />@@@",
+      "@@@STEP_LOG_LINE@raw@</manifest>@@@",
+      "@@@STEP_LOG_END@raw@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "[START_DIR]/checkout/.repo/manifests/default.xml",
+      "/path/to/tmp/"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.read file",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@default.xml@<?xml version=\"1.0\" encoding=\"UTF-8\"?>@@@",
+      "@@@STEP_LOG_LINE@default.xml@<manifest>@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"sso://default\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"..\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://pigweed-internal.googlesource.com\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <remote@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    fetch=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    review=\"https://foo.googlesource.com/prefix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <default@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"default_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"default_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"default_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pigweed-internal_name\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pigweed-internal_path\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed-internal_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"pinned\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"pigweed_remote\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    revision=\"0123456789012345678901234567890123456789\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    upstream=\"main\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@@@@",
+      "@@@STEP_LOG_LINE@default.xml@  <project@@@",
+      "@@@STEP_LOG_LINE@default.xml@    name=\"suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    path=\"prefix/suffix\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    remote=\"prefixed\"@@@",
+      "@@@STEP_LOG_LINE@default.xml@    />@@@",
+      "@@@STEP_LOG_LINE@default.xml@</manifest>@@@",
+      "@@@STEP_LOG_END@default.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}",
+      "[START_DIR]/manifest.json"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.read manifest.manifest json",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_LOG_LINE@manifest.json@{\"projects\": [{\"name\": \"default_name\", \"path\": \"default_path\", \"remote\": \"default_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://default.googlesource.com/default_name\"}, {\"name\": \"pigweed_name\", \"path\": \"pigweed_path\", \"remote\": \"pigweed_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pigweed_name\"}, {\"name\": \"pigweed-internal_name\", \"path\": \"pigweed-internal_path\", \"remote\": \"pigweed-internal_remote\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://pigweed-internal.googlesource.com/pigweed-internal_name\"}, {\"name\": \"pinned\", \"path\": \"pinned\", \"remote\": \"pigweed_remote\", \"revision\": \"0123456789012345678901234567890123456789\", \"upstream\": \"main\", \"url\": \"https://pigweed.googlesource.com/pinned\"}, {\"name\": \"suffix\", \"path\": \"prefix/suffix\", \"remote\": \"prefixed\", \"revision\": \"main\", \"upstream\": \"main\", \"url\": \"https://foo.googlesource.com/prefix/suffix\"}], \"remotes\": {\"default_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://default.googlesource.com\", \"url\": \"sso://default\"}, \"name\": \"default_remote\", \"review\": null, \"revision\": null}, \"pigweed-internal_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed-internal.googlesource.com\", \"url\": \"https://pigweed-internal.googlesource.com\"}, \"name\": \"pigweed-internal_remote\", \"review\": \"https://pigweed-internal.googlesource.com\", \"revision\": \"main\"}, \"pigweed_remote\": {\"alias\": null, \"fetch\": {\"https\": \"https://pigweed.googlesource.com\", \"url\": \"https://pigweed.googlesource.com\"}, \"name\": \"pigweed_remote\", \"review\": \"https://pigweed.googlesource.com\", \"revision\": \"main\"}, \"prefixed\": {\"alias\": null, \"fetch\": {\"https\": \"https://foo.googlesource.com/prefix\", \"url\": \"https://foo.googlesource.com/prefix\"}, \"name\": \"prefixed\", \"review\": \"https://foo.googlesource.com/prefix\", \"revision\": null}}}@@@",
+      "@@@STEP_LOG_END@manifest.json@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "config",
+      "--global",
+      "--add",
+      "url.https://default.googlesource.com/a.insteadof",
+      "sso://default"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.git insteadof sso://default",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "sync",
+      "--force-sync",
+      "--current-branch",
+      "--jobs",
+      "2"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo sync",
+    "timeout": 120,
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "start",
+      "base",
+      "--all"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo start",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LINK@gerrit@https://pigweed-review.googlesource.com/c/1234@@@",
+      "@@@STEP_LINK@gitiles@https://pigweed.googlesource.com/pigweed_name/+/refs/changes/34/1234/1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https://pigweed.googlesource.com/pigweed_name",
+      "refs/changes/34/1234/1",
+      "--no-recurse-submodules"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch patch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--force",
+      "-b",
+      "working",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git checkout patch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "https://pigweed.googlesource.com/pigweed_name"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git remote add",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.pre-rebase log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___pigweed_googlesource_com_pigweed_name",
+      "refs/heads/feature1"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git fetch branch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___pigweed_googlesource_com_pigweed_name/feature1"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git set upstream",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rebase",
+      "https___pigweed_googlesource_com_pigweed_name/feature1"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git rebase",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "https___pigweed_googlesource_com_pigweed_name/feature1"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git rev-parse",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/checkout/pigweed_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply pigweed:1234.git submodule update",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply pigweed:1234.compare branch name",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@CL branch: feature1\nupstream branch: main@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply default:2345",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LINK@gerrit@https://default-review.googlesource.com/c/2345@@@",
+      "@@@STEP_LINK@gitiles@https://default.googlesource.com/default_name/+/refs/changes/45/2345/1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https://default.googlesource.com/default_name",
+      "refs/changes/45/2345/1",
+      "--no-recurse-submodules"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git fetch patch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "checkout",
+      "--force",
+      "-b",
+      "working",
+      "FETCH_HEAD"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git checkout patch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "remote",
+      "add",
+      "https___default_googlesource_com_default_name",
+      "https://default.googlesource.com/default_name"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git remote add",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.pre-rebase log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "fetch",
+      "https___default_googlesource_com_default_name",
+      "refs/heads/feature2"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git fetch branch",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "branch",
+      "--set-upstream-to=https___default_googlesource_com_default_name/feature2"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git set upstream",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rebase",
+      "https___default_googlesource_com_default_name/feature2"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git rebase",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "rev-parse",
+      "https___default_googlesource_com_default_name/feature2"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git rev-parse",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "update",
+      "--init",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/checkout/default_path",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.apply default:2345.git submodule update",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.apply default:2345.compare branch name",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@STEP_SUMMARY_TEXT@CL branch: feature2\nupstream branch: main@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.status",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@applied [_Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='refs/changes/34/1234/1', rebase=True, branch='feature1', gerrit_name='pigweed', submitted=False, base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip'), _Change(number=2345, remote='https://default.googlesource.com/default_name', ref='refs/changes/45/2345/1', rebase=True, branch='feature2', gerrit_name='default', submitted=False, base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip')]\nnot applied []@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "checkout pigweed.root",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@root=[START_DIR]/checkout\nself._root=[START_DIR]/checkout\n@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "listdir",
+      "[START_DIR]/checkout"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.ls",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@listdir@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "RECIPE_MODULE[pigweed::repo]/resources/repo",
+      "manifest",
+      "-r"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.repo manifest",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@raw_io.output_text@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@raw_io.output_text@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "submodule",
+      "status",
+      "--recursive"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.submodule-status",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "submodule status filler text",
+      "[START_DIR]/snapshot/submodules.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write submodule snapshot",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@submodules.log@submodule status filler text@@@",
+      "@@@STEP_LOG_END@submodules.log@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "checkout pigweed.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "root",
+    "~followup_annotations": [
+      "@@@STEP_SUMMARY_TEXT@[START_DIR]/checkout@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "repo_top",
+    "~followup_annotations": [
+      "@@@STEP_SUMMARY_TEXT@[START_DIR]/checkout@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "use_repo",
+    "~followup_annotations": [
+      "@@@STEP_SUMMARY_TEXT@True@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "changes"
+  },
+  {
+    "cmd": [],
+    "name": "changes.0",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@_Change(number=1234, remote='https://pigweed.googlesource.com/pigweed_name', ref='refs/changes/34/1234/1', rebase=True, branch='feature1', gerrit_name='pigweed', submitted=False, base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip')@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "changes.1",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_SUMMARY_TEXT@_Change(number=2345, remote='https://default.googlesource.com/default_name', ref='refs/changes/45/2345/1', rebase=True, branch='feature2', gerrit_name='default', submitted=False, base='REMOTE_BRANCH_REMOTE_BRANCH_REMOTE_BRANCH_', base_type='remote_branch_tip')@@@"
+    ]
+  },
+  {
+    "cmd": [],
+    "name": "snapshot_to_dir"
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/snapshot"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.mkdir",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "<manifest></manifest>",
+      "[START_DIR]/snapshot/manifest.xml"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write manifest.xml",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@manifest.xml@<manifest></manifest>@@@",
+      "@@@STEP_LOG_END@manifest.xml@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "submodule status filler text",
+      "[START_DIR]/snapshot/submodules.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write submodule snapshot",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_LINE@submodules.log@submodule status filler text@@@",
+      "@@@STEP_LOG_END@submodules.log@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "git",
+      "log",
+      "--oneline",
+      "-n",
+      "10"
+    ],
+    "cwd": "[START_DIR]/checkout",
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "copy",
+      "",
+      "[START_DIR]/snapshot/git.log"
+    ],
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "project:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "snapshot_to_dir.write git log",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@",
+      "@@@STEP_LOG_END@git.log@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipe_modules/checkout/tests/repo.expected/no_trigger.json b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
index 8b22ce0..de2bbb6 100644
--- a/recipe_modules/checkout/tests/repo.expected/no_trigger.json
+++ b/recipe_modules/checkout/tests/repo.expected/no_trigger.json
@@ -174,6 +174,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/prefix.json b/recipe_modules/checkout/tests/repo.expected/prefix.json
index 580526a..26d2522 100644
--- a/recipe_modules/checkout/tests/repo.expected/prefix.json
+++ b/recipe_modules/checkout/tests/repo.expected/prefix.json
@@ -423,6 +423,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
index 2793d73..a4053ff 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-cqdeps.json
@@ -650,6 +650,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
index fd81590..d5a4598 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple-onenotapplied.json
@@ -532,6 +532,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try-multiple.json b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
index 66ecfc3..df4eea7 100644
--- a/recipe_modules/checkout/tests/repo.expected/try-multiple.json
+++ b/recipe_modules/checkout/tests/repo.expected/try-multiple.json
@@ -477,6 +477,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try.json b/recipe_modules/checkout/tests/repo.expected/try.json
index b9095d9..e21971f 100644
--- a/recipe_modules/checkout/tests/repo.expected/try.json
+++ b/recipe_modules/checkout/tests/repo.expected/try.json
@@ -423,6 +423,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
index cb815c5..eecade3 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_manifest.json
@@ -473,6 +473,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no branch names match",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
index b451223..5d745e1 100644
--- a/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
+++ b/recipe_modules/checkout/tests/repo.expected/try_repo_not_in_manifest.json
@@ -423,6 +423,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",
diff --git a/recipe_modules/checkout/tests/repo.py b/recipe_modules/checkout/tests/repo.py
index 474af70..165a7ee 100644
--- a/recipe_modules/checkout/tests/repo.py
+++ b/recipe_modules/checkout/tests/repo.py
@@ -13,6 +13,8 @@
 # the License.
 """Full test of repo functionality in checkout module."""
 
+from recipe_engine import post_process
+
 DEPS = [
     'fuchsia/status_check',
     'pigweed/checkout',
@@ -72,6 +74,10 @@
         + api.checkout.manifest_test_data()
         + api.checkout.root_files('foo', '.repo')
         + api.checkout.all_changes_applied()
+        + api.post_process(
+            post_process.MustRun,
+            'checkout pigweed.no non-standard branch names',
+        )
     )
 
     yield (
@@ -175,6 +181,14 @@
         + api.checkout.manifest_has_matching_branch('feature1')
         + api.checkout.manifest_test_data()
         + api.checkout.all_changes_applied()
+        + api.post_process(
+            post_process.DoesNotRun,
+            'checkout pigweed.no non-standard branch names',
+        )
+        + api.post_process(
+            post_process.DoesNotRun,
+            'checkout pigweed.not matching branch names',
+        )
     )
 
     yield (
@@ -193,6 +207,28 @@
         + api.checkout.manifest_has_matching_branch('feature1')
         + api.checkout.manifest_has_matching_branch('feature2')
         + api.checkout.all_changes_applied()
+        + api.post_process(
+            post_process.DoesNotRun,
+            'checkout pigweed.not matching branch names',
+        )
+    )
+
+    yield (
+        api.status_check.test('feature_branches_try_no_matching')
+        + api.properties(**api.checkout.repo_properties(match_branch=False))
+        + api.checkout.try_test_data(
+            gerrit_changes=[
+                cl('pigweed_name', 1234),
+                cl('default_name', 2345, name='default'),
+            ]
+        )
+        + api.checkout.cl_branch('feature1', index=0)
+        + api.checkout.cl_branch('feature2', index=1)
+        + api.checkout.manifest_test_data()
+        + api.checkout.all_changes_applied()
+        + api.post_process(
+            post_process.MustRun, 'checkout pigweed.not matching branch names',
+        )
     )
 
     yield (
diff --git a/recipes/target_to_cipd.expected/success.json b/recipes/target_to_cipd.expected/success.json
index c5e0bd8..7b4e8e9 100644
--- a/recipes/target_to_cipd.expected/success.json
+++ b/recipes/target_to_cipd.expected/success.json
@@ -228,6 +228,13 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "checkout pigweed.no non-standard branch names",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
       "RECIPE_MODULE[pigweed::repo]/resources/repo",
       "init",