Exemplo n.º 1
0
def do_rebranch_abort(args):
    git = Git()
    state = RebranchState(git.rootdir)

    if not state.in_progress():
        error("There is no rebranch in progress")
        sys.exit(1)

    # Abort an eventual rebase
    if git.rebase_in_progress():
        (rc, stdout, stderr) = git.rebase_abort()
        sys.stdout.write(stdout)
        sys.stderr.write(stderr)
        if rc != 0:
            error("Failed rebase --abort")

    # Just to be sure; check if the repo is clean
    if git.isdirty:
        error("Working copy is not clean")
        sys.exit(1)

    # Reset rebased branches to their original revisions
    (curbranch, orig_branches, _) = state.load()
    for (branch, sha1) in orig_branches.items():
        info("Resetting {0} to {1}", branch, sha1)
        git.checkout(branch)
        git.reset_hard(sha1)

    # Checkout the original branch
    git.checkout(curbranch)

    state.clear()
Exemplo n.º 2
0
def do_rebranch_continue(args):
    git = Git()
    state = RebranchState(git.rootdir)

    if not state.in_progress():
        error("There is no rebranch in progress")
        sys.exit(1)

    # Continue the interrupted rebase
    if git.rebase_in_progress():
        info("Continue rebasing")
        (rc, stdout, stderr) = git.rebase_continue()
        sys.stdout.write(stdout)
        sys.stderr.write(stderr)
        if rc != 0:
            error('Resolve the conflicts and run "git rebranch --continue"')
            error('To stop, run "git rebranch --abort"')
            sys.exit(1)

    # Continue rebasing
    try:
        (curbranch, orig_branches, plan) = state.load()
        _rebranch(git, curbranch, orig_branches, plan, args.dry_run)
    except GitError as e:
        error(e)
        sys.exit(1)

    # Checkout the original branch
    git.checkout(curbranch)