<commit_before>#!/usr/bin/env python

# Copyright (c) 2013 Intel Corporation. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""This script will do:
  1. Setup src's git initialization.
  2. Place .gclient file outside of src.
  3. Call gclient sync outside of src.
"""

import optparse
import os
import pprint
import re
import sys

from utils import TryAddDepotToolsToPythonPath

try:
  import gclient_utils
except ImportError:
  TryAddDepotToolsToPythonPath()

try:
  import gclient_utils
  import gclient_scm
  import subprocess2
  from third_party.repo.progress import Progress
except ImportError:
  sys.stderr.write("Can't find gclient_utils, please add your depot_tools "\
                   "to PATH or PYTHONPATH\n")

percent_re = re.compile('.* ([0-9]{1,2})% .*')
def _GitFilter(line):
  # git uses an escape sequence to clear the line; elide it.
  esc = line.find(unichr(033))
  if esc > -1:
    line = line[:esc]
  match = percent_re.match(line)
  if not match or not int(match.group(1)) % 10:
    print '%s' % line

class FetchingError(Exception):
  pass

class FolderExistGitWrapper(gclient_scm.GitWrapper):
  """Handle the case that we need to initial git environment
    when the folder is already there.
    We need to do:
      1. git init
      2. git remote add
      3. git fetch
      4. git checkout
    Then we can let gclient sync to handle the rest of its life.
  """
  def __init__(self, url=None, root_dir=None, relpath=None):
    gclient_scm.GitWrapper.__init__(self, url, root_dir, relpath)
    self._split_url = gclient_utils.SplitUrlRevision(self.url)

  def _Fetch(self, remote, options):
    fetch_cmd = ['fetch', remote, '--progress']
    if options.verbose:
      fetch_cmd.append('--verbose')

    for _ in range(3):
      try:
        # git fetch for chromium will take a looooong time for the
        # first time, so set timeout for 30 minutes
        self._Run(fetch_cmd, options, cwd=self.checkout_path,
                  git_filter=True, nag_timer=30, nag_max=60)<commit_msg>fetch_deps: Remove dead code after bac2d56.<commit_after>#!/usr/bin/env python

# Copyright (c) 2013 Intel Corporation. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""This script will do:
  1. Setup src's git initialization.
  2. Place .gclient file outside of src.
  3. Call gclient sync outside of src.
"""

import optparse
import os
import pprint
import sys

from utils import TryAddDepotToolsToPythonPath

try:
  import gclient_utils
except ImportError:
  TryAddDepotToolsToPythonPath()

try:
  import gclient_utils
  import gclient_scm
  import subprocess2
  from third_party.repo.progress import Progress
except ImportError:
  sys.stderr.write("Can't find gclient_utils, please add your depot_tools "\
                   "to PATH or PYTHONPATH\n")

class FetchingError(Exception):
  pass

class FolderExistGitWrapper(gclient_scm.GitWrapper):
  """Handle the case that we need to initial git environment
    when the folder is already there.
    We need to do:
      1. git init
      2. git remote add
      3. git fetch
      4. git checkout
    Then we can let gclient sync to handle the rest of its life.
  """
  def __init__(self, url=None, root_dir=None, relpath=None):
    gclient_scm.GitWrapper.__init__(self, url, root_dir, relpath)
    self._split_url = gclient_utils.SplitUrlRevision(self.url)

  def _Fetch(self, remote, options):
    fetch_cmd = ['fetch', remote, '--progress']
    if options.verbose:
      fetch_cmd.append('--verbose')

    for _ in range(3):
      try:
        # git fetch for chromium will take a looooong time for the
        # first time, so set timeout for 30 minutes
        self._Run(fetch_cmd, options, cwd=self.checkout_path,
                  git_filter=True, nag_timer=30, nag_max=60)
{'fraction_non_alphanumeric': 0.08525345622119816, 'fraction_numerical': 0.013312852022529442, 'mean_word_length': 3.288693743139407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1262748', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1215, 'n_words': 433}