Exemple #1
0
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
        ErrorExit("You need to install trychange.py to use the try server.")

    if change_info:
        trychange_args = ['--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)])
        trychange_args.extend(args)
        trychange.TryChange(trychange_args,
                            file_list=change_info.GetFileNames(),
                            swallow_exception=swallow_exception,
                            prog='gcl try')
    else:
        trychange.TryChange(args,
                            file_list=None,
                            swallow_exception=swallow_exception,
                            prog='gcl try')
Exemple #2
0
def TryChange(change_info, args, swallow_exception=False, patchset=None):
    """Create a diff file of change_info and send it to the try server."""
    try:
        import trychange
    except ImportError:
        if swallow_exception:
            return
        ErrorExit("You need to install trychange.py to use the try server.")

    if change_info:
        trychange.TryChange(args, change_info.name, change_info.FileList(),
                            swallow_exception, patchset)
    else:
        trychange.TryChange(args)
Exemple #3
0
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)])
    trychange_args.extend(args)
    file_list = change_info.GetFileNames()
  else:
    trychange_args.extend(args)
    file_list = None
  return trychange.TryChange(
      trychange_args,
      file_list=file_list,
      swallow_exception=swallow_exception,
      prog='gcl try',
      extra_epilog='\n'
          'When called from gcl, use the format gcl try <change_name>.\n')
Exemple #4
0
def main(args):
    patchset = GetRietveldPatchsetNumber()
    if patchset:
        args.extend([
            '--issue',
            GetRietveldIssueNumber(),
            '--patchset',
            patchset,
        ])
    else:
        rietveld_url = GetRietveldServerUrl()
        if rietveld_url:
            args.extend(['--rietveld_url', GetRietveldServerUrl()])
    try:
        cl = git_cl.Changelist()
        change = cl.GetChange(cl.GetUpstreamBranch(), None)
        # Hack around a limitation in logging.
        logging.getLogger().handlers = []
        sys.exit(
            trychange.TryChange(
                args,
                change,
                swallow_exception=False,
                prog='git try',
                extra_epilog='\n'
                'git try will diff against your tracked branch and will '
                'detect your rietveld\n'
                'code review if you are using git-cl\n'))
    except third_party.upload.ClientLoginError, e:
        print('Got an exception while trying to log in to Rietveld.')
        print(str(e))
Exemple #5
0
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')
Exemple #6
0
def TryChange(change_info, args):
    """Create a diff file of change_info and send it to the try server."""
    try:
        import trychange
    except ImportError:
        ErrorExit("You need to install trychange.py to use the try server.")

    trychange.TryChange(args, change_info.name, change_info.FileList())
Exemple #7
0
def main(argv):
  chromium_src_root = chromiumSrcRoot()
  os.chdir(chromium_src_root)
  argv = argv[1:]
  addLayoutBotsIfNeeded(argv)

  with ScopedTemporaryFile() as diff_file:
    generateDiff(diff_file, chromium_src_root)
    args = [
        '--sub_rep', 'third_party/WebKit',
        '--root', 'src',
        '--rietveld_url', 'https://codereview.chromium.org',
        '--diff', diff_file,
    ]
    args.extend(argv)
    cl = git_cl.Changelist()
    change = cl.GetChange(cl.GetUpstreamBranch(), None)
    logging.getLogger().handlers = []
    return trychange.TryChange(args, change,
        swallow_exception=False, prog='git wktry')
Exemple #8
0
 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))
Exemple #9
0
    patchset = GetRietveldPatchsetNumber()
    if patchset:
        args.extend([
            '--issue',
            GetRietveldIssueNumber(),
            '--patchset',
            patchset,
        ])
    else:
        rietveld_url = GetRietveldServerUrl()
        if rietveld_url:
            args.extend(['--rietveld_url', GetRietveldServerUrl()])
    try:
        cl = git_cl.Changelist()
        change = cl.GetChange(cl.GetUpstreamBranch(), None)
        # Hack around a limitation in logging.
        logging.getLogger().handlers = []
        sys.exit(
            trychange.TryChange(
                args,
                change,
                swallow_exception=False,
                prog='git try',
                extra_epilog='\n'
                'git try will diff against your tracked branch and will '
                'detect your rietveld\n'
                'code review if you are using git-cl\n'))
    except third_party.upload.ClientLoginError, e:
        print('Got an exception while trying to log in to Rietveld.')
        print(str(e))