コード例 #1
0
ファイル: gcl.py プロジェクト: miaosf/depot_tools
def TryChange(change_info, args, swallow_exception):
  """Create a diff file of change_info and send it to the try server."""
  try:
    import trychange
  except ImportError:
    if swallow_exception:
      return 1
    ErrorExit("You need to install trychange.py to use the try server.")

  trychange_args = []
  if change_info:
    trychange_args.extend(['--name', change_info.name])
    if change_info.issue:
      trychange_args.extend(["--issue", str(change_info.issue)])
    if change_info.patchset:
      trychange_args.extend(["--patchset", str(change_info.patchset)])
    change = presubmit_support.SvnChange(change_info.name,
                                         change_info.description,
                                         change_info.GetLocalRoot(),
                                         change_info.GetFiles(),
                                         change_info.issue,
                                         change_info.patchset,
                                         None)
  else:
    change = None

  trychange_args.extend(args)
  return trychange.TryChange(
      trychange_args,
      change=change,
      swallow_exception=swallow_exception,
      prog='gcl try',
      extra_epilog='\n'
          'When called from gcl, use the format gcl try <change_name>.\n')
コード例 #2
0
ファイル: gcl.py プロジェクト: BGCX067/fajr-git
def DoPresubmitChecks(change_info, committing, may_prompt):
  """Imports presubmit, then calls presubmit.DoPresubmitChecks."""
  # Need to import here to avoid circular dependency.
  import presubmit_support
  root_presubmit = GetCachedFile('PRESUBMIT.py', use_root=True)
  change = presubmit_support.SvnChange(change_info.name,
                                       change_info.description,
                                       change_info.GetLocalRoot(),
                                       change_info.GetFiles(),
                                       change_info.issue,
                                       change_info.patchset)
  result = presubmit_support.DoPresubmitChecks(change=change,
                                               committing=committing,
                                               verbose=False,
                                               output_stream=sys.stdout,
                                               input_stream=sys.stdin,
                                               default_presubmit=root_presubmit,
                                               may_prompt=may_prompt)
  if not result and may_prompt:
    print "\nPresubmit errors, can't continue (use --no_presubmit to bypass)"
  return result
コード例 #3
0
ファイル: try_server.py プロジェクト: kusoof/wprof
 def _send_job(self, pending, revision, clobber, builders_and_tests,
               job_name):
     """Sends a try job."""
     assert revision
     cmd = [
         '--no_search', '--revision',
         '%s@%s' % (self.solution, revision), '--name', job_name, '--user',
         self.commit_user.split('@', 1)[0], '--email', self.commit_user,
         '--rietveld_url',
         self._patch_url(pending), '--issue',
         str(pending.issue), '--patchset',
         str(pending.patchset)
     ]
     cmd.extend(self.extra_flags)
     for builder in sorted(builders_and_tests):
         cmd.append('--bot')
         tests = builders_and_tests[builder]
         if tests:
             cmd.append('%s:%s' % (builder, ','.join(tests)))
         else:
             cmd.append(builder)
     if clobber:
         cmd.append('--clobber')
     # TODO(maruel): use GitChange when relevant.
     change = presubmit_support.SvnChange(
         job_name, pending.description, self.context.checkout.project_path,
         [('M', f) for f in pending.files], pending.issue, pending.patchset,
         pending.owner)
     prev_dir = os.getcwd()
     try:
         os.chdir(self.context.checkout.project_path)
         trychange.TryChange(cmd, change, swallow_exception=True)
     except SystemExit, e:
         logging.error('_send_job(%s, %s, %s, %s, %s) failed!' %
                       (pending.pending_name(), revision, clobber,
                        builders_and_tests, job_name))
         raise base.DiscardPending(
             pending, 'Failed to send try job %s: %s' % (job_name, e))
コード例 #4
0
ファイル: gcl.py プロジェクト: miaosf/depot_tools
def DoPresubmitChecks(change_info, committing, may_prompt):
  """Imports presubmit, then calls presubmit.DoPresubmitChecks."""
  root_presubmit = GetCachedFile('PRESUBMIT.py', use_root=True)
  change = presubmit_support.SvnChange(change_info.name,
                                       change_info.description,
                                       change_info.GetLocalRoot(),
                                       change_info.GetFiles(),
                                       change_info.issue,
                                       change_info.patchset,
                                       None)
  output = presubmit_support.DoPresubmitChecks(
      change=change,
      committing=committing,
      verbose=False,
      output_stream=sys.stdout,
      input_stream=sys.stdin,
      default_presubmit=root_presubmit,
      may_prompt=may_prompt,
      rietveld_obj=change_info.RpcServer())
  if not output.should_continue() and may_prompt:
    # TODO(dpranke): move into DoPresubmitChecks(), unify cmd line args.
    print "\nPresubmit errors, can't continue (use --no_presubmit to bypass)"

  return output