cbuildbot: move AcquirePoolFromOptions into TrybotPatchPool
This helper better fits with the existing trybot_patch_pool module, and
allows us to split apart cbuildbot in follow up commits and not duplicate
this logic.
BUG=brillo:134, chromium:299943
TEST=`./cbuildbot/run_tests` passes
TEST=precq doesn't blow up
Change-Id: I6c6cc538cc98681218ee05c701c7b61e869c4326
Reviewed-on: https://chromium-review.googlesource.com/246352
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 71a96dc..3aac2e4 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -54,11 +54,9 @@
from chromite.lib import cleanup
from chromite.lib import commandline
from chromite.lib import cros_build_lib
-from chromite.lib import gerrit
from chromite.lib import git
from chromite.lib import gob_util
from chromite.lib import osutils
-from chromite.lib import patch as cros_patch
from chromite.lib import parallel
from chromite.lib import retry_stats
from chromite.lib import sudo
@@ -108,42 +106,6 @@
return cbuildbot_config.config[config_name]
-def AcquirePoolFromOptions(options):
- """Generate patch objects from passed in options.
-
- Args:
- options: The options object generated by optparse.
-
- Returns:
- trybot_patch_pool.TrybotPatchPool object.
-
- Raises:
- gerrit.GerritException, cros_patch.PatchException
- """
- gerrit_patches = []
- local_patches = []
- remote_patches = []
-
- if options.gerrit_patches:
- gerrit_patches = gerrit.GetGerritPatchInfo(
- options.gerrit_patches)
- for patch in gerrit_patches:
- if patch.IsAlreadyMerged():
- cros_build_lib.Warning('Patch %s has already been merged.' % str(patch))
-
- if options.local_patches:
- manifest = git.ManifestCheckout.Cached(options.sourceroot)
- local_patches = cros_patch.PrepareLocalPatches(manifest,
- options.local_patches)
-
- if options.remote_patches:
- remote_patches = cros_patch.PrepareRemotePatches(
- options.remote_patches)
-
- return trybot_patch_pool.TrybotPatchPool(gerrit_patches, local_patches,
- remote_patches)
-
-
class Builder(object):
"""Parent class for all builder types.
@@ -344,7 +306,12 @@
changes_stage = sync_stages.PatchChangesStage.StageNamePrefix()
check_func = results_lib.Results.PreviouslyCompletedRecord
if not check_func(changes_stage) or self._run.options.bootstrap:
- self.patch_pool = AcquirePoolFromOptions(self._run.options)
+ options = self._run.options
+ self.patch_pool = trybot_patch_pool.TrybotPatchPool.FromOptions(
+ gerrit_patches=options.gerrit_patches,
+ local_patches=options.local_patches,
+ sourceroot=options.sourceroot,
+ remote_patches=options.remote_patches)
def _GetBootstrapStage(self):
"""Constructs and returns the BootStrapStage object.
@@ -1751,7 +1718,11 @@
# Verify gerrit patches are valid.
print('Verifying patches...')
- patch_pool = AcquirePoolFromOptions(options)
+ patch_pool = trybot_patch_pool.TrybotPatchPool.FromOptions(
+ gerrit_patches=options.gerrit_patches,
+ local_patches=options.local_patches,
+ sourceroot=options.sourceroot,
+ remote_patches=options.remote_patches)
# --debug need to be explicitly passed through for remote invocations.
if options.buildbot and '--debug' not in options.pass_through_args: