def _push_new_status_branch(gitContext, review_branch, status, revision_id):
    clone = gitContext.clone
    remote = gitContext.remote

    if revision_id is None:
        revision_id = "none"
    else:
        revision_id = str(revision_id)

    working_branch_name = abdt_naming.makeWorkingBranchName(
        status,
        review_branch.description,
        review_branch.base,
        revision_id)

    working_branch = abdt_naming.makeWorkingBranchFromName(
        working_branch_name)

    working_branch = abdt_gittypes.makeGitWorkingBranch(
        working_branch, gitContext.remote)

    phlgit_push.push_asymmetrical_force(
        clone,
        phlgitu_ref.make_remote(review_branch.branch, remote),
        phlgitu_ref.make_local(working_branch_name),
        remote)

    return working_branch
def createDifferentialReview(
        conduit, user, parsed, gitContext, review_branch, rawDiff):
    clone = gitContext.clone
    phlgit_checkout.new_branch_force_based_on(
        clone, review_branch.branch, review_branch.remote_branch)

    with phlsys_conduit.act_as_user_context(conduit, user):
        print "- creating diff"
        diffid = phlcon_differential.create_raw_diff(conduit, rawDiff).id

        print "- creating revision"
        review = phlcon_differential.create_revision(
            conduit, diffid, parsed.fields)
        print "- created " + str(review.revisionid)

        workingBranch = abdt_naming.makeWorkingBranchName(
            abdt_naming.WB_STATUS_OK,
            review_branch.description,
            review_branch.base,
            review.revisionid)

        print "- pushing working branch: " + workingBranch
        phlgit_push.push_asymmetrical(
            clone, review_branch.branch, workingBranch, gitContext.remote)

    print "- commenting on " + str(review.revisionid)
    commenter = abdcmnt_commenter.Commenter(conduit, review.revisionid)
    commenter.createdReview(review_branch.branch, review_branch.base)

    return review.revisionid
def pushBadPreReview(gitContext, review_branch):
    working_branch_name = abdt_naming.makeWorkingBranchName(
        abdt_naming.WB_STATUS_BAD_PREREVIEW,
        review_branch.description, review_branch.base, "none")
    phlgit_push.push_asymmetrical(
        gitContext.clone,
        phlgitu_ref.make_remote(
            review_branch.branch, gitContext.remote),
        phlgitu_ref.make_local(working_branch_name),
        gitContext.remote)
def makeGitWorkingBranchFromParts(
        status, description, base, review_id, remote):
    """Return a GitReviewBranch based on the supplied parts."""
    working_branch = abdt_naming.makeWorkingBranchName(
        base=base,
        status=status,
        description=description,
        review_id=review_id)
    working_branch = abdt_naming.makeWorkingBranchFromName(working_branch)
    working_branch = makeGitWorkingBranch(working_branch, remote)
    return working_branch
def makeWorkingBranchWithStatus(working_branch, status):
    """Return an abdcmd_default__GitWorkingBranch based on branch and status.

    :working_branch: an abdcmd_default__GitWorkingBranch to base on
    :status: the new string status
    :returns: an abdcmd_default__GitWorkingBranch

    """
    remote = working_branch.remote
    working_branch = abdt_naming.makeWorkingBranchName(
        base=working_branch.base,
        status=status,
        description=working_branch.description,
        review_id=working_branch.id)
    working_branch = abdt_naming.makeWorkingBranchFromName(working_branch)
    working_branch = makeGitWorkingBranch(working_branch, remote)
    return working_branch