<commit_before># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


"""Recipe module to ensure a checkout is consistant on a bot."""

from recipe_engine import recipe_api


# This is just for testing, to indicate if a master is using a Git scheduler
# or not.
SVN_MASTERS = (
    'experimental.svn',
)


class BotUpdateApi(recipe_api.RecipeApi):

  def __init__(self, mastername, buildername, slavename, issue, patchset,
               patch_url, repository, gerrit_ref, rietveld, revision,
               parent_got_revision, deps_revision_overrides, fail_patch,
               *args, **kwargs):
    self._mastername = mastername
    self._buildername = buildername
    self._slavename = slavename
    self._issue = issue
    self._patchset = patchset
    self._patch_url = patch_url
    self._repository = repository
    self._gerrit_ref = gerrit_ref
    self._rietveld = rietveld
    self._revision = revision
    self._parent_got_revision = parent_got_revision
    self._deps_revision_overrides = deps_revision_overrides
    self._fail_patch = fail_patch

    self._last_returned_properties = {}
    super(BotUpdateApi, self).__init__(*args, **kwargs)

  def __call__(self, name, cmd, **kwargs):
    """Wrapper for easy calling of bot_update."""
    assert isinstance(cmd, (list, tuple))
    bot_update_path = self.resource('bot_update.py')
    kwargs.setdefault('infra_step', True)
    kwargs.setdefault('env', {})
    kwargs['env'].setdefault('PATH', '%(PATH)s')
    kwargs['env']['PATH'] = self.m.path.pathsep.join([
        kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)])
    return self.m.python(name, bot_update_path, cmd, **kwargs)

  @property
  def last_returned_properties(self):
      return self._last_returned_properties

  def ensure_checkout(self, gclient_config=None, suffix=None,
                      patch=True, update_presentation=True,
                      force=False, patch_root=None, no_shallow=False,
                      with_branch_heads=False, refs=None,
                      patch_oauth2=False, use_site_config_creds=True,
                      output_manifest=True, clobber=False,
                      root_solution_revision=None, rietveld=None, issue=None,
                      patchset=None, gerrit_no_reset=False, **kwargs):
    """
    Args:
      use_site_config_creds: If the oauth2 credentials are in the buildbot
        site_config. See crbug.com/624212 for more information.
      gclient_config: The gclient configuration to use when running bot_update.
        If omitted, the current gclient configuration is used.
      rietveld: The rietveld server to use. If omitted, will infer from
        the 'rietveld' property.
      issue: The rietveld issue number to use. If omitted, will infer from
        the 'issue' property.
      patchset: The rietveld issue patchset to use. If omitted, will infer from
        the 'patchset' property.
    """
    refs = refs or []
    # We can re-use the gclient spec from the gclient module, since all the
    # data bot_update needs is already configured into the gclient spec.
    cfg = gclient_config or self.m.gclient.c

    # Used by bot_update to determine if we want to run or not.
    master = self._mastername
    builder = self._buildername
    slave = self._slavename

    # Construct our bot_update command.  This basically be inclusive of
    # everything required for bot_update to know:<commit_msg>bot_update: improve UX when gclient is not configured.<commit_after># Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


"""Recipe module to ensure a checkout is consistant on a bot."""

from recipe_engine import recipe_api


# This is just for testing, to indicate if a master is using a Git scheduler
# or not.
SVN_MASTERS = (
    'experimental.svn',
)


class BotUpdateApi(recipe_api.RecipeApi):

  def __init__(self, mastername, buildername, slavename, issue, patchset,
               patch_url, repository, gerrit_ref, rietveld, revision,
               parent_got_revision, deps_revision_overrides, fail_patch,
               *args, **kwargs):
    self._mastername = mastername
    self._buildername = buildername
    self._slavename = slavename
    self._issue = issue
    self._patchset = patchset
    self._patch_url = patch_url
    self._repository = repository
    self._gerrit_ref = gerrit_ref
    self._rietveld = rietveld
    self._revision = revision
    self._parent_got_revision = parent_got_revision
    self._deps_revision_overrides = deps_revision_overrides
    self._fail_patch = fail_patch

    self._last_returned_properties = {}
    super(BotUpdateApi, self).__init__(*args, **kwargs)

  def __call__(self, name, cmd, **kwargs):
    """Wrapper for easy calling of bot_update."""
    assert isinstance(cmd, (list, tuple))
    bot_update_path = self.resource('bot_update.py')
    kwargs.setdefault('infra_step', True)
    kwargs.setdefault('env', {})
    kwargs['env'].setdefault('PATH', '%(PATH)s')
    kwargs['env']['PATH'] = self.m.path.pathsep.join([
        kwargs['env']['PATH'], str(self._module.PACKAGE_REPO_ROOT)])
    return self.m.python(name, bot_update_path, cmd, **kwargs)

  @property
  def last_returned_properties(self):
      return self._last_returned_properties

  def ensure_checkout(self, gclient_config=None, suffix=None,
                      patch=True, update_presentation=True,
                      force=False, patch_root=None, no_shallow=False,
                      with_branch_heads=False, refs=None,
                      patch_oauth2=False, use_site_config_creds=True,
                      output_manifest=True, clobber=False,
                      root_solution_revision=None, rietveld=None, issue=None,
                      patchset=None, gerrit_no_reset=False, **kwargs):
    """
    Args:
      use_site_config_creds: If the oauth2 credentials are in the buildbot
        site_config. See crbug.com/624212 for more information.
      gclient_config: The gclient configuration to use when running bot_update.
        If omitted, the current gclient configuration is used.
      rietveld: The rietveld server to use. If omitted, will infer from
        the 'rietveld' property.
      issue: The rietveld issue number to use. If omitted, will infer from
        the 'issue' property.
      patchset: The rietveld issue patchset to use. If omitted, will infer from
        the 'patchset' property.
    """
    refs = refs or []
    # We can re-use the gclient spec from the gclient module, since all the
    # data bot_update needs is already configured into the gclient spec.
    cfg = gclient_config or self.m.gclient.c
    assert cfg is not None, (
        'missing gclient_config or forgot api.gclient.set_config(...) before?')

    # Used by bot_update to determine if we want to run or not.
    master = self._mastername
    builder = self._buildername
    slave = self._slavename

    # Construct our bot_update command.  This basically be inclusive of
    # everything required for bot_update to know:
{'fraction_non_alphanumeric': 0.08369188063844553, 'fraction_numerical': 0.0033310201249132547, 'mean_word_length': 3.0943181818181817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7128037', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2101, 'n_words': 633}