Example #1
0
def comment(repo_dir, report):
    good = [] # All commits on all branches
    bad = [] # No commits
    ugly = [] # Partial uplift
    good, bad, ugly = classify_gbu(report)
    failed_bugs = []

    def x(bug_id):
        del report[bug_id]
        util.write_json(uplift.uplift_report_file, report)

    for i, j in (good, good_bug_comment), (bad, bad_bug_comment), (ugly, ugly_bug_comment):
        for bug_id in i:
            print "Commenting on bug %s" % bug_id
            try:
                j(repo_dir, bug_id, report[bug_id])
                x(bug_id)
            except FailedToComment:
                failed_bugs.append(bug_id)
                
    if len(failed_bugs) > 0:
        filename = os.path.abspath('failed_comments_%s.json' % util.time_str())
        print "The following bugs had commenting failures"
        print util.e_join(failed_bugs)
        print "Creating a file to use with the 'uplift comments' file to try just these."
        print "Fix the issue then run: uplift comments %s" % filename
        util.write_json(filename, report)
Example #2
0
def uplift(repo_dir, gaia_url, requirements):
    # Setup stuff
    t=util.time_start()
    print "Updating Gaia"
    git.create_gaia(repo_dir, gaia_url) # This is sadly broken
    print "Created Gaia in %0.2f seconds" % util.time_end(t)

    # Determining what needs to be uplifted
    with_commits = {}
    for bug_id in requirements.keys():
        if requirements[bug_id].has_key('commits'):
            with_commits[bug_id] = requirements[bug_id]

    ordered_commits = order_commits(repo_dir, with_commits)

    uplift = dict([(x, {}) for x in ordered_commits])

    # Uplifting
    for commit in ordered_commits:
        needed_on = []
        for bug_id in with_commits.keys():
            if commit in with_commits[bug_id]['commits']:
                for i in with_commits[bug_id]['needed_on']:
                    if not i in needed_on:
                        needed_on.append(i)
        print "\n", "="*80
        print "Attempting to uplift %s commit to %s" % (commit, util.e_join(needed_on))
        uplift[commit]['needed_on'] = needed_on
        result = uplift_commit(repo_dir, commit, needed_on)
        print "Sucess on %s" % util.e_join(result['success'].keys())
        print "Failure on %s" % util.e_join(result['failure'])
        uplift[commit]['uplift_status'] = result

    uplift_report = copy.deepcopy(with_commits)

    # Determinging which commits belong to which bugs
    for bug_id in uplift_report.keys():
        successful_branches = []
        failed_branches = []
        for commit in git.sort_commits(repo_dir, uplift_report[bug_id]['commits'], 'master'):
            if commit in uplift.keys():
                if not uplift_report[bug_id].has_key('uplift_status'):
                    uplift_report[bug_id]['uplift_status'] = {}
                u = uplift_report[bug_id]['uplift_status']
                u[commit] = copy.deepcopy(uplift[commit]['uplift_status'])
                failed_branches.extend([x for x in u[commit]['failure'] if x not in failed_branches])
                successful_branches.extend([x for x in u[commit]['success'].keys() if x not in successful_branches])
        # Because we might have multiple commits, we want to make sure that the list of successful branches
        # includes only those with *no* failing uplifts
        for i in range(len(successful_branches) - 1, -1, -1):
            if successful_branches[i] in failed_branches:
                del successful_branches[i]
        uplift_report[bug_id]['flags_to_set'] = branch_logic.flags_to_set(successful_branches)

    util.write_json(uplift_dated_file, uplift_report)
    util.write_json(uplift_report_file, uplift_report)
    return uplift_report
Example #3
0
def generate_ugly_bug_msg(bug):
    comment = ['This bug was partially uplifted.  This might not be valid']
    comment.append(generate_good_bug_msg(bug))
    comment.append('The following commits did not uplift:')
    for commit in bug['commits']:
        comment.append("  * %s failed on %s" % (commit, util.e_join(bug['uplift_status'][commit]['failure'])))
    
    return '\n'.join(comment)
Example #4
0
def generate_bad_bug_msg(repo_dir, bug):
    comment = [
        "I was not able to uplift this bug to %s.  " % util.e_join(bug['needed_on']),
        " If this bug has dependencies which are not marked in this bug ",
        "please comment on this bug.  If this bug depends on patches that ",
        "aren't approved for %s, " % util.e_join(bug['needed_on']),
        "we need to re-evaluate the approval.  ",
        "Otherwise, if this is just a merge conflict, ",
        "you might be able to resolve it with:"
    ]

    comment = textwrap.wrap(''.join(comment), 75)
    for commit in git.sort_commits(repo_dir, bug['commits'], 'master'):
        comment.append(merge_script(repo_dir, commit, bug['uplift_status'][commit]['failure']))


    return '\n'.join(comment)
Example #5
0
def push(repo_dir):
    branches = c.read_value('repository.enabled_branches')
    preview_push_info = git.push(repo_dir, remote="origin", branches=branches, dry_run=True)
    print "If you push, you'd be pushing: "
    _display_push_info(preview_push_info)
    if not util.ask_yn('Do you wish to push?'):
        return None
    for i in range(5):
        try:
            rv = git.push(repo_dir, remote="origin", branches=branches, dry_run=False)
            util.write_json(push_info_file, rv)
            print "Push attempt %d worked" % int(i+1)
            return rv
        except:
            print "Push attempt %d failed" % int(i+1)
    raise git.PushFailure("remote %s branches %s" % (remote, util.e_join(branches)))
Example #6
0
        for i in range(0, len(keys)):
            print "  * guess-%d: %s" % (i+1, keys[i])
            print "    BECAUSE:"
            for reason in guesses[keys[i]]:
                for line in reason.split('\n'):
                    print "        ", "\n        ".join(textwrap.wrap(line))

    def _open_browser():
        open_bug_in_browser(bug_id)


    _open_browser()

    prompt = "%s\nBug %s's %%d commits:\n%%s\nEnter command: " % ('-' * 80, bug_id)
    print "=" * 80
    print "Needed on: %s" % util.e_join(branch_logic.needed_on_branches(bug_data))
    print "Fixed on: %s" % util.e_join(branch_logic.fixed_on_branches(bug_data))
    print "Type one of"
    if len(guesses) > 0:
        print "  * guess-all: add all guesses listed below"
        _show_guesses()
    print "  * sha1 commit: add a raw commit number"
    print "  * skip: add a bug to the list of permanently skipped bugs"
    print "  * delete-all: remove all commits from this bug"
    print "  * delete-N: delete entered commit"
    print "  * browser: (re)open the bug in a browser"

    user_input = raw_input(prompt % (len(commits), _list_commits())).strip()

    guess_re = re.compile('^guess-(?P<guess>\d+)$')
    delete_re = re.compile('^delete-(?P<delete>\d+)$')