Ejemplo n.º 1
0
def main():
    parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
    parser.add_option('-v',
                      '--verbose',
                      action='count',
                      default=0,
                      help='Prints debugging infos')
    parser.add_option('-i',
                      '--issue',
                      type='int',
                      help='Rietveld issue number')
    parser.add_option('-p',
                      '--patchset',
                      type='int',
                      help='Rietveld issue\'s patchset number')
    parser.add_option('-r',
                      '--root_dir',
                      default=os.getcwd(),
                      help='Root directory to apply the patch')
    parser.add_option('-s',
                      '--server',
                      default='http://codereview.chromium.org',
                      help='Rietveld server')
    options, args = parser.parse_args()
    logging.basicConfig(
        format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s',
        level=[logging.WARNING, logging.INFO,
               logging.DEBUG][min(2, options.verbose)])
    if args:
        parser.error('Extra argument(s) "%s" not understood' % ' '.join(args))
    if not options.issue:
        parser.error('Require --issue')

    obj = rietveld.Rietveld(options.server, None, None)

    if not options.patchset:
        options.patchset = obj.get_issue_properties(options.issue,
                                                    False)['patchsets'][-1]
        logging.info('Using patchset %d' % options.patchset)
    # Download the patch.
    patchset = obj.get_patch(options.issue, options.patchset)
    for patch in patchset.patches:
        logging.info(patch)
    scm_type = scm.determine_scm(options.root_dir)
    if scm_type == 'svn':
        scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None,
                                       None)
    elif scm_type == 'git':
        scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None)
    elif scm_type == None:
        scm_obj = checkout.RawCheckout(options.root_dir, None)
    else:
        parser.error('Couldn\'t determine the scm')

    # Apply the patch.
    scm_obj.apply_patch(patchset)
    return 0
Ejemplo n.º 2
0
    print('Downloading the patch.')
    try:
        patchset = obj.get_patch(options.issue, options.patchset)
    except urllib2.HTTPError, e:
        print('Failed to fetch the patch for issue %d, patchset %d.\n'
              'Try visiting %s/%d') % (options.issue, options.patchset,
                                       options.server, options.issue)
        return 1
    for patch in patchset.patches:
        print(patch)
    full_dir = os.path.abspath(options.root_dir)
    scm_type = scm.determine_scm(full_dir)
    if scm_type == 'svn':
        scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
    elif scm_type == 'git':
        scm_obj = checkout.GitCheckoutBase(full_dir, None, None)
    elif scm_type == None:
        scm_obj = checkout.RawCheckout(full_dir, None, None)
    else:
        parser.error('Couldn\'t determine the scm')

    # TODO(maruel): HACK, remove me.
    # When run a build slave, make sure buildbot knows that the checkout was
    # modified.
    if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
        # See sourcedirIsPatched() in:
        # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
        #    chromium_commands.py?view=markup
        open('.buildbot-patched', 'w').close()

    print('\nApplying the patch.')
Ejemplo n.º 3
0
    try:
        patchset = obj.get_patch(options.issue, options.patchset)
    except urllib2.HTTPError, e:
        print >> sys.stderr, (
            'Failed to fetch the patch for issue %d, patchset %d.\n'
            'Try visiting %s/%d') % (options.issue, options.patchset,
                                     options.server, options.issue)
        return 1
    for patch in patchset.patches:
        print(patch)
    scm_type = scm.determine_scm(options.root_dir)
    if scm_type == 'svn':
        scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None,
                                       None)
    elif scm_type == 'git':
        scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None)
    elif scm_type == None:
        scm_obj = checkout.RawCheckout(options.root_dir, None, None)
    else:
        parser.error('Couldn\'t determine the scm')

    # TODO(maruel): HACK, remove me.
    # When run a build slave, make sure buildbot knows that the checkout was
    # modified.
    if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
        # See sourcedirIsPatched() in:
        # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
        #    chromium_commands.py?view=markup
        open('.buildbot-patched', 'w').close()

    # Apply the patch.