def cmd_harvest(args):

    from_branch = fuzzy_match_branch(args.get(0))
    to_branch = fuzzy_match_branch(args.get(1))

    if not from_branch:
        print('Please specify a branch to harvest commits from:')
        display_available_branches()
        sys.exit()

    if to_branch:
        original_branch = get_current_branch_name()
        is_external = True
    else:
        is_external = False

    branch_names = get_branch_names(local=True, remote_branches=False)

    if from_branch not in branch_names:
        print("{0} isn't an available branch. Use a branch that is.".format(
            colored.yellow(from_branch)))
        sys.exit(1)

    if is_external:
        switch_to(to_branch)

    if repo.is_dirty():
        status_log(stash_it, 'Saving local changes.')

    status_log(smart_merge, 'Grafting commits from {0}.'.format(
        colored.yellow(from_branch)), from_branch, allow_rebase=False)

    if is_external:
        switch_to(original_branch)

    if unstash_index():
        status_log(unstash_it, 'Restoring local changes.')


#
Syncs a branch with given branch. Defaults to current.
dataset/ETHPy150Open kennethreitz/legit/legit/cli.py/cmd_harvest