#!/usr/bin/env python3

import sys
from git_utils import get_branch_name_for_different_version, \
        get_checked_out_branch_name
import subprocess


def print_usage():
    print("""
    %s FROM_VERSION
""") % sys.argv[0]


if len(sys.argv) == 2 and (
        sys.argv[1] == "-h" or
        sys.argv[1] == "help"):
    print_usage()
    sys.exit(0)

if len(sys.argv) <= 1:
    print_usage()
    sys.exit(1)

from_version = sys.argv[1]

current_branch = get_checked_out_branch_name()
other_branch = get_branch_name_for_different_version(current_branch, from_version)

print("git cherry-pick %s" % other_branch)
subprocess.check_call(["git", "cherry-pick", other_branch])
