def main(argv): parser = GetParser() options = parser.parse_args(argv) options.Freeze() local_manifest = ResolveLocalManifestPath(options) if local_manifest: logging.info('Using local_manifest: %s', local_manifest) if options.manifest_url: manifest_url = options.manifest_url elif options.external: manifest_url = config_lib.GetSiteParams().MANIFEST_URL else: manifest_url = config_lib.GetSiteParams().MANIFEST_INT_URL osutils.SafeMakedirs(options.repo_root) repo = repository.RepoRepository( manifest_repo_url=manifest_url, directory=options.repo_root, branch=options.branch, git_cache_dir=options.git_cache_dir, repo_url=options.repo_url, groups=options.groups) if options.copy_repo: repo.PreLoad(options.copy_repo) if repository.IsARepoRoot(options.repo_root): repo.BuildRootGitCleanup(prune_all=True) repo.Sync(local_manifest=local_manifest, detach=True) if options.gerrit_patches: patches = gerrit.GetGerritPatchInfo(options.gerrit_patches) # TODO: Extract patches from manifest synced. helper_pool = patch_series.HelperPool.SimpleCreate( cros_internal=not options.external, cros=True) series = patch_series.PatchSeries( path=options.repo_root, helper_pool=helper_pool, forced_manifest=None) _, failed_tot, failed_inflight = series.Apply(patches) failed = failed_tot + failed_inflight if failed: logging.error('Failed to apply: %s', ', '.join(str(p) for p in failed)) return 1
def PrepareManifestVersions(options): """Select manifest-versions checkout to use, and update it. Looks at command line options to decide which manifest-versions checkout to use, and updates (or creates) it as needed. Args: options: Parsed command line options. Returns: Full path to manifest-versions directory to use for this sync. Raises: AssertionError: If the needed manifest-versions path wasn't con the command line. """ site_params = config_lib.GetSiteParams() if options.external: assert options.manifest_versions_ext, '--manifest-versions-ext required.' manifest_versions_url = site_params.MANIFEST_VERSIONS_GOB_URL manifest_versions_path = options.manifest_versions_ext else: assert options.manifest_versions_int, '--manifest-versions-int required.' manifest_versions_url = site_params.MANIFEST_VERSIONS_INT_GOB_URL manifest_versions_path = options.manifest_versions_int # Resolve buildspecs against a current manifest versions value. manifest_version.RefreshManifestCheckout( manifest_versions_path, manifest_versions_url) return manifest_versions_path
def _UpdateStreakCounter(self, final_status, counter_name, dry_run=False): """Update the given streak counter based on the final status of build. A streak counter counts the number of consecutive passes or failures of a particular builder. Consecutive passes are indicated by a positive value, consecutive failures by a negative value. Args: final_status: String indicating final status of build, constants.BUILDER_STATUS_PASSED indicating success. counter_name: Name of counter to increment, typically the name of the build config. dry_run: Pretend to update counter only. Default: False. Returns: The new value of the streak counter. """ site_params = config_lib.GetSiteParams() gs_ctx = gs.GSContext(dry_run=dry_run) counter_url = os.path.join(site_params.MANIFEST_VERSIONS_GS_URL, constants.STREAK_COUNTERS, counter_name) gs_counter = gs.GSCounter(gs_ctx, counter_url) if final_status == constants.BUILDER_STATUS_PASSED: streak_value = gs_counter.StreakIncrement() else: streak_value = gs_counter.StreakDecrement() return streak_value
def testCrosGerritDeps(self, cros_internal=True): """Test that we can apply changes correctly and respect deps. This tests a simple out-of-order change where change1 depends on change3 but tries to get applied before it. What should happen is that we should notice the dependency and apply change3 first. """ site_params = config_lib.GetSiteParams() helper_pool = self.MakeHelper(cros_internal=cros_internal, cros=True) series = self.GetPatchSeries(helper_pool=helper_pool) patch1 = self.MockPatch(remote=site_params.EXTERNAL_REMOTE) patch2 = self.MockPatch(remote=site_params.INTERNAL_REMOTE) patch3 = self.MockPatch(remote=site_params.EXTERNAL_REMOTE) patches = [patch1, patch2, patch3] if cros_internal: applied_patches = [patch3, patch2, patch1] else: applied_patches = [patch3, patch1] self.SetPatchDeps(patch1, [patch3.id]) self.SetPatchDeps(patch2) self.SetPatchDeps(patch3, cq=[patch2.id]) apply_mocks = [ self.SetPatchApply(patch1), self.SetPatchApply(patch3), ] if cros_internal: apply_mocks.append(self.SetPatchApply(patch2)) self.assertResults(series, patches, applied_patches) self.CheckPatchApply(apply_mocks)
def GetGerritPatchInfoWithPatchQueries(patches): """Query Gerrit server for patch information using PatchQuery objects. Args: patches: A list of PatchQuery objects to query. Returns: A list of GerritPatch objects describing each patch. Only the first instance of a requested patch is returned. Raises: PatchException if a patch can't be found. """ site_params = config_lib.GetSiteParams() seen = set() results = [] order = {k.ToGerritQueryText(): idx for (idx, k) in enumerate(patches)} for remote in site_params.CHANGE_PREFIX.keys(): helper = GetGerritHelper(remote) raw_ids = [ x.ToGerritQueryText() for x in patches if x.remote == remote ] for k, change in helper.QueryMultipleCurrentPatchset(raw_ids): # return a unique list, while maintaining the ordering of the first # seen instance of each patch. Do this to ensure whatever ordering # the user is trying to enforce, we honor; lest it break on # cherry-picking. if change.id not in seen: results.append((order[k], change)) seen.add(change.id) return [change for _idx, change in sorted(results)]
def GetGerrit(opts, cl=None): """Auto pick the right gerrit instance based on the |cl| Args: opts: The general options object. cl: A CL taking one of the forms: 1234 *1234 chromium:1234 Returns: A tuple of a gerrit object and a sanitized CL #. """ gob = opts.gob if cl is not None: if cl.startswith('*') or cl.startswith('chrome-internal:'): gob = config_lib.GetSiteParams().INTERNAL_GOB_INSTANCE if cl.startswith('*'): cl = cl[1:] else: cl = cl[16:] elif ':' in cl: gob, cl = cl.split(':', 1) if not gob in opts.gerrit: opts.gerrit[gob] = gerrit.GetGerritHelper(gob=gob, print_cmd=opts.debug) return (opts.gerrit[gob], cl)
def FromGob(cls, gob, **kwargs): """Return a helper for a GoB instance.""" site_params = config_lib.GetSiteParams() host = constants.GOB_HOST % ('%s-review' % gob) # TODO(phobbs) this will be wrong when "gob" isn't in GOB_REMOTES. # We should get rid of remotes altogether and just use the host. return cls(host, site_params.GOB_REMOTES.get(gob, gob), **kwargs)
def GetBaseUploadURI(config, archive_base=None, bot_id=None): """Get the base URL where artifacts from this builder are uploaded. Each build run stores its artifacts in a subdirectory of the base URI. We also have LATEST files under the base URI which help point to the latest build available for a given builder. Args: config: The build config to examine. archive_base: Optional. The root URL under which objects from all builders are uploaded. If not specified, we use the default archive bucket. bot_id: The bot ID to archive files under. Returns: Google Storage URI (i.e. 'gs://...') under which all archived files should be uploaded. In other words, a path like a directory, even through GS has no real directories. """ if not bot_id: bot_id = config.name if archive_base: gs_base = archive_base elif config.gs_path == config_lib.GS_PATH_DEFAULT: gs_base = config_lib.GetSiteParams().ARCHIVE_URL else: gs_base = config.gs_path return os.path.join(gs_base, bot_id)
def testDefaultGSPath(self): """Test GetBaseUploadURI with default gs_path value in config.""" self.cfg = _ExtendDefaultConfig(gs_path=config_lib.GS_PATH_DEFAULT) # Test without bot_id. expected_result = ( '%s/%s' % (config_lib.GetSiteParams().ARCHIVE_URL, DEFAULT_BOT_NAME)) result = self._GetBaseUploadURI() self.assertEqual(expected_result, result) # Test with bot_id. expected_result = ( '%s/%s' % (config_lib.GetSiteParams().ARCHIVE_URL, self.BOT_ID)) result = self._GetBaseUploadURI(bot_id=self.BOT_ID) self.assertEqual(expected_result, result)
def IsInternalRepoCheckout(root): """Returns whether root houses an internal 'repo' checkout.""" manifest_dir = os.path.join(root, '.repo', 'manifests') manifest_url = git.RunGit(manifest_dir, ['config', 'remote.origin.url']).output.strip() return (os.path.splitext( os.path.basename(manifest_url))[0] == os.path.splitext( os.path.basename(config_lib.GetSiteParams().MANIFEST_INT_URL))[0])
def setUp(self): site_params = config_lib.GetSiteParams() self.repo = repository.RepoRepository(site_params.MANIFEST_URL, self.tempdir, branch='master') self.PatchObject(repository.RepoRepository, 'Initialize') self.PatchObject(repository.RepoRepository, '_EnsureMirroring') self.PatchObject(repository.RepoRepository, 'BuildRootGitCleanup') self.PatchObject(time, 'sleep')
def FromRemote(cls, remote, **kwargs): site_params = config_lib.GetSiteParams() if remote == site_params.INTERNAL_REMOTE: host = site_params.INTERNAL_GERRIT_HOST elif remote == site_params.EXTERNAL_REMOTE: host = site_params.EXTERNAL_GERRIT_HOST else: raise ValueError('Remote %s not supported.' % remote) return cls(host, remote, **kwargs)
def MakeHelper(self, cros_internal=None, cros=None): # pylint: disable=attribute-defined-outside-init site_params = config_lib.GetSiteParams() if cros_internal: cros_internal = mock.create_autospec(gerrit.GerritHelper) cros_internal.version = '2.2' cros_internal.remote = site_params.INTERNAL_REMOTE if cros: cros = mock.create_autospec(gerrit.GerritHelper) cros.remote = site_params.EXTERNAL_REMOTE cros.version = '2.2' return patch_series.HelperPool(cros_internal=cros_internal, cros=cros)
def PopulateAndPublishBuildSpec(rel_build_spec, manifest, manifest_versions_int, manifest_versions_ext=None, dryrun=True): """Create build spec based on current source checkout. This assumes that the current checkout is 100% clean, and that local SHAs exist in GoB. The new buildspec is created in manifest_versions and pushed remotely. The manifest_versions paths do not need to be in a clean state, but should be consistent from build to build for performance reasons. Args: rel_build_spec: Path relative to manifest_verions root for buildspec. manifest: Contents of the manifest to publish as a string. manifest_versions_int: Path to manifest-versions-internal checkout. manifest_versions_ext: Path to manifest-versions checkout (public). dryrun: Git push --dry-run if set to True. """ site_params = config_lib.GetSiteParams() # Create and push internal buildspec. build_spec = _CommitAndPush(manifest_versions_int, site_params.MANIFEST_VERSIONS_INT_GOB_URL, rel_build_spec, manifest, dryrun) if manifest_versions_ext: # Create the external only manifest in a tmp file, read into string. whitelisted_remotes = config_lib.GetSiteParams().EXTERNAL_REMOTES tmp_manifest = FilterManifest(build_spec, whitelisted_remotes=whitelisted_remotes) manifest_ext = osutils.ReadFile(tmp_manifest) _CommitAndPush(manifest_versions_ext, site_params.MANIFEST_VERSIONS_GOB_URL, rel_build_spec, manifest_ext, dryrun)
def GetWorkspaceRepo(self): """Fetch a repo object for the workspace. Returns: repository.RepoRepository instance for the workspace. """ # TODO: Properly select the manifest. Currently hard coded to internal # branch checkouts. manifest_url = config_lib.GetSiteParams().MANIFEST_INT_URL # Workspace repos use the workspace URL / branch. return self.GetRepoRepository(manifest_repo_url=manifest_url, branch=self._run.config.workspace_branch)
def test008Queries(self): """Verify assorted query operations.""" project = self.createProject('test008') clone_path = self.cloneProject(project) gpatch = self.createPatch(clone_path, project) helper = self._GetHelper() # Multi-queries with one valid and one invalid term should raise. invalid_change_id = 'I1234567890123456789012345678901234567890' self.assertRaises(gerrit.GerritException, gerrit.GetGerritPatchInfo, [invalid_change_id, gpatch.change_id]) self.assertRaises(gerrit.GerritException, gerrit.GetGerritPatchInfo, [gpatch.change_id, invalid_change_id]) self.assertRaises(gerrit.GerritException, gerrit.GetGerritPatchInfo, ['9876543', gpatch.gerrit_number]) self.assertRaises(gerrit.GerritException, gerrit.GetGerritPatchInfo, [gpatch.gerrit_number, '9876543']) site_params = config_lib.GetSiteParams() # Simple query by project/changeid/sha1. patch_info = helper.GrabPatchFromGerrit(gpatch.project, gpatch.change_id, gpatch.sha1) self.assertEqual(patch_info.gerrit_number, gpatch.gerrit_number) self.assertEqual(patch_info.remote, site_params.EXTERNAL_REMOTE) # Simple query by gerrit number to external remote. patch_info = gerrit.GetGerritPatchInfo([gpatch.gerrit_number]) self.assertEqual(patch_info[0].gerrit_number, gpatch.gerrit_number) self.assertEqual(patch_info[0].remote, site_params.EXTERNAL_REMOTE) # Simple query by gerrit number to internal remote. patch_info = gerrit.GetGerritPatchInfo(['*' + gpatch.gerrit_number]) self.assertEqual(patch_info[0].gerrit_number, gpatch.gerrit_number) self.assertEqual(patch_info[0].remote, site_params.INTERNAL_REMOTE) # Query to external server by gerrit number and change-id which refer to # the same change should return one result. fq_changeid = '~'.join((gpatch.project, 'master', gpatch.change_id)) patch_info = gerrit.GetGerritPatchInfo( [gpatch.gerrit_number, fq_changeid]) self.assertEqual(len(patch_info), 1) self.assertEqual(patch_info[0].gerrit_number, gpatch.gerrit_number) self.assertEqual(patch_info[0].remote, site_params.EXTERNAL_REMOTE) # Query to internal server by gerrit number and change-id which refer to # the same change should return one result. patch_info = gerrit.GetGerritPatchInfo( ['*' + gpatch.gerrit_number, '*' + fq_changeid]) self.assertEqual(len(patch_info), 1) self.assertEqual(patch_info[0].gerrit_number, gpatch.gerrit_number) self.assertEqual(patch_info[0].remote, site_params.INTERNAL_REMOTE)
def __init__(self, cros_internal=None, cros=None): """Initialize this instance with the given handlers. Most likely you want the classmethod SimpleCreate which takes boolean options. If a given handler is None, then it's disabled; else the passed in object is used. """ site_params = config_lib.GetSiteParams() self.pool = { site_params.EXTERNAL_REMOTE: cros, site_params.INTERNAL_REMOTE: cros_internal }
def CreateFromManifest(self, manifest, retries=manifest_version.NUM_RETRIES, build_id=None): """Sets up an lkgm_manager from the given manifest. This method sets up an LKGM manager and publishes a new manifest to the manifest versions repo based on the passed in manifest but filtering internal repositories and changes out of it. Args: manifest: A manifest that possibly contains private changes/projects. It is named with the given version we want to create a new manifest from i.e R20-1920.0.1-rc7.xml where R20-1920.0.1-rc7 is the version. retries: Number of retries for updating the status. build_id: Optional integer cidb build id of the build publishing the manifest. Returns: Path to the manifest version file to use. Raises: GenerateBuildSpecException in case of failure to check-in the new manifest because of a git error or the manifest is already checked-in. """ last_error = None new_manifest = manifest_version.FilterManifest( manifest, whitelisted_remotes=config_lib.GetSiteParams().EXTERNAL_REMOTES) version_info = self.GetCurrentVersionInfo() for _attempt in range(0, retries + 1): try: self.RefreshManifestCheckout() self.InitializeManifestVariables(version_info) git.CreatePushBranch(manifest_version.PUSH_BRANCH, self.manifest_dir, sync=False) version = os.path.splitext(os.path.basename(manifest))[0] logging.info('Publishing filtered build spec') self.PublishManifest(new_manifest, version, build_id=build_id) self.current_version = version return self.GetLocalManifest(version) except cros_build_lib.RunCommandError as e: err_msg = 'Failed to generate LKGM Candidate. error: %s' % e logging.error(err_msg) last_error = err_msg raise manifest_version.GenerateBuildSpecException(last_error)
def _GetManifestVersionsRepoUrl(self, internal=None, test=False): if internal is None: internal = self._run.config.internal site_params = config_lib.GetSiteParams() if internal: if test: return site_params.MANIFEST_VERSIONS_INT_GOB_URL_TEST else: return site_params.MANIFEST_VERSIONS_INT_GOB_URL else: if test: return site_params.MANIFEST_VERSIONS_GOB_URL_TEST else: return site_params.MANIFEST_VERSIONS_GOB_URL
def testAttributeAccess(self): """Test that dot-accessor works correctly.""" site_params = config_lib.GetSiteParams() # Ensure our test key is not in site_params. self.assertNotIn('foo', site_params) # Test that we raise when accessing a non-existent value. # pylint: disable=pointless-statement with self.assertRaises(AttributeError): site_params.foo # Test the dot-accessor. site_params.update({'foo': 'bar'}) self.assertEqual('bar', site_params.foo)
def _RepairManifestRepositories(self, branches): """Repair all manifests in all manifest repositories on current branch. Args: branches: List of ProjectBranches describing the repairs needed. """ for project_name in config_lib.GetSiteParams().MANIFEST_PROJECTS: manifest_project = self.checkout.manifest.GetUniqueProject( project_name) manifest_repo = ManifestRepository(self.checkout, manifest_project) manifest_repo.RepairManifestsOnDisk(branches) self.checkout.RunGit(manifest_project, [ 'commit', '-a', '-m', 'Manifests point to branch %s.' % self.name ])
def SyncVersion(self, version): """Sync to the given manifest version. Args: version: Version string to sync to. """ logging.notice('Syncing checkout %s to version %s.', self.root, version) site_params = config_lib.GetSiteParams() self._Sync([ '--manifest-versions-int', self.AbsolutePath(site_params.INTERNAL_MANIFEST_VERSIONS_PATH), '--manifest-versions-ext', self.AbsolutePath(site_params.EXTERNAL_MANIFEST_VERSIONS_PATH), '--version', version ])
def testCreateFromManifest(self): """Tests that we can create a new candidate from another manifest.""" # Let's stub out other LKGMManager calls cause they're already # unit tested. version = '2010.0.0-rc7' my_info = lkgm_manager._LKGMCandidateInfo('2010.0.0') new_candidate = lkgm_manager._LKGMCandidateInfo(version) manifest = ('/tmp/manifest-versions-internal/paladin/buildspecs/' '20/%s.xml' % version) new_manifest = '/path/to/tmp/file.xml' build_id = 20162 site_params = config_lib.GetSiteParams() # Patch out our RepoRepository to make sure we don't corrupt real repo. self.PatchObject(self.manager, 'cros_source') filter_mock = self.PatchObject(manifest_version, 'FilterManifest', return_value=new_manifest) # Do manifest refresh work. self.PatchObject(lkgm_manager.LKGMManager, 'GetCurrentVersionInfo', return_value=my_info) self.PatchObject(lkgm_manager.LKGMManager, 'RefreshManifestCheckout') init_mock = self.PatchObject(lkgm_manager.LKGMManager, 'InitializeManifestVariables') # Publish new candidate. publish_mock = self.PatchObject(lkgm_manager.LKGMManager, 'PublishManifest') candidate_path = self.manager.CreateFromManifest(manifest, build_id=build_id) self.assertEqual(candidate_path, self._GetPathToManifest(new_candidate)) self.assertEqual(self.manager.current_version, version) filter_mock.assert_called_once_with( manifest, whitelisted_remotes=site_params.EXTERNAL_REMOTES) publish_mock.assert_called_once_with(new_manifest, version, build_id=build_id) init_mock.assert_called_once_with(my_info) self.push_mock.assert_called_once_with(mock.ANY, mock.ANY, sync=False)
def testManifestFilters(self): """Make sure the manifest filters work""" site_params = config_lib.GetSiteParams() _, _, patch = self._CommonGitSetup() patch.project = constants.CHROMITE_PROJECT self.assertFalse(trybot_patch_pool.ExtManifestFilter(patch)) self.assertFalse(trybot_patch_pool.IntManifestFilter(patch)) self.assertFalse(trybot_patch_pool.ManifestFilter(patch)) patch.project = site_params.MANIFEST_PROJECT self.assertTrue(trybot_patch_pool.ExtManifestFilter(patch)) self.assertFalse(trybot_patch_pool.IntManifestFilter(patch)) self.assertTrue(trybot_patch_pool.ManifestFilter(patch)) patch.project = site_params.MANIFEST_INT_PROJECT self.assertFalse(trybot_patch_pool.ExtManifestFilter(patch)) self.assertTrue(trybot_patch_pool.IntManifestFilter(patch)) self.assertTrue(trybot_patch_pool.ManifestFilter(patch))
def testSha1Deps(self): """Test that we can apply changes correctly and respect sha1 deps. This tests a simple out-of-order change where change1 depends on change2 but tries to get applied before change2. What should happen is that we should notice change2 is a dep of change1 and apply it first. """ site_params = config_lib.GetSiteParams() series = self.GetPatchSeries() patch1, patch2, patch3 = patches = self.GetPatches(3) patch3.remote = site_params.INTERNAL_REMOTE self.SetPatchDeps(patch1, ['chromium:%s' % patch2.sha1]) self.SetPatchDeps(patch2, ['chrome-internal:%s' % patch3.sha1]) self.SetPatchDeps(patch3) apply_mocks = [self.SetPatchApply(x) for x in patches] self.assertResults(series, patches, [patch3, patch2, patch1]) self.CheckPatchApply(apply_mocks)
def PrintCls(opts, cls, lims=None, show_approvals=True): """Print all results based on the requested format.""" if opts.raw: site_params = config_lib.GetSiteParams() pfx = '' # Special case internal Chrome GoB as that is what most devs use. # They can always redirect the list elsewhere via the -g option. if opts.gob == site_params.INTERNAL_GOB_INSTANCE: pfx = site_params.INTERNAL_CHANGE_PREFIX for cl in cls: print('%s%s' % (pfx, cl['number'])) elif opts.json: json.dump(cls, sys.stdout) else: if lims is None: lims = limits(cls) for cl in cls: PrettyPrintCl(opts, cl, lims=lims, show_approvals=show_approvals)
def LocalizeManifest(self, manifest, filter_cros=False): """Remove restricted checkouts from the manifest if needed. Args: manifest: The manifest to localize. filter_cros: If set, then only checkouts with a remote of 'cros' or 'cros-internal' are kept, and the rest are filtered out. """ if filter_cros: with osutils.TempDir() as tempdir: filtered_manifest = os.path.join(tempdir, 'filtered.xml') doc = ElementTree.parse(manifest) root = doc.getroot() for node in root.findall('project'): remote = node.attrib.get('remote') if remote and remote not in config_lib.GetSiteParams().GIT_REMOTES: root.remove(node) doc.write(filtered_manifest) yield filtered_manifest else: yield manifest
def SimpleCreate(cls, cros_internal=True, cros=True): """Classmethod helper for creating a HelperPool from boolean options. Args: cros_internal: If True, allow access to a GerritHelper for internal. cros: If True, allow access to a GerritHelper for external. Returns: An appropriately configured HelperPool instance. """ site_params = config_lib.GetSiteParams() if cros: cros = gerrit.GetGerritHelper(site_params.EXTERNAL_REMOTE) else: cros = None if cros_internal: cros_internal = gerrit.GetGerritHelper(site_params.INTERNAL_REMOTE) else: cros_internal = None return cls(cros_internal=cros_internal, cros=cros)
def PushLocalPatches(local_patches, user_email, dryrun=False): """Push local changes to a remote ref, and generate args to send. Args: local_patches: patch_pool.local_patches from verified patch_pool. user_email: Unique id for user submitting this tryjob. dryrun: Is this a dryrun? If so, don't really push. Returns: List of strings to pass to builder to include these patches. """ manifest = git.ManifestCheckout.Cached(constants.SOURCE_ROOT) current_time = str(int(time.time())) ref_base = os.path.join('refs/tryjobs', user_email, current_time) extra_args = [] for patch in local_patches: # Isolate the name; if it's a tag or a remote, let through. # Else if it's a branch, get the full branch name minus refs/heads. local_branch = git.StripRefsHeads(patch.ref, False) ref_final = os.path.join(ref_base, local_branch, patch.sha1) checkout = patch.GetCheckout(manifest) checkout.AssertPushable() print('Uploading patch %s' % patch) patch.Upload(checkout['push_url'], ref_final, dryrun=dryrun) # TODO(rcui): Pass in the remote instead of tag. https://crbug.com/216095. tag = constants.EXTERNAL_PATCH_TAG if checkout['remote'] == config_lib.GetSiteParams().INTERNAL_REMOTE: tag = constants.INTERNAL_PATCH_TAG extra_args.append('--remote-patches=%s:%s:%s:%s:%s' % (patch.project, local_branch, ref_final, patch.tracking_branch, tag)) return extra_args
def CanBranchProject(project): """Returns true if the project can be branched. The preferred way to specify branchability is by adding a "branch-mode" annotation on the project in the manifest. Of course, only one project in the manifest actually does this. The legacy method is to peek at the project's remote. Args: project: The repo_manifest.Project in question. Returns: True if the project is not pinned or ToT. """ site_params = config_lib.GetSiteParams() remote = project.Remote().GitName() explicit_mode = BranchMode(project) if not explicit_mode: return (remote in site_params.CROS_REMOTES and remote in site_params.BRANCHABLE_PROJECTS and re.match( site_params.BRANCHABLE_PROJECTS[remote], project.name)) return explicit_mode == constants.MANIFEST_ATTR_BRANCHING_CREATE