in contrib/client-side/svn-merge-vendor.py [0:0]
def main():
tag = None
message = None
interactive = 1
revision_to_parse = None
merged_vendor = None
wc_dir = None
# Initializing logger
global logger
logger = logging.getLogger('svn-merge-vendor')
hdlr = logging.StreamHandler(sys.stderr)
formatter = logging.Formatter('%(levelname)-8s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], "ht:m:vr:c:w:",
["help", "tag", "message", "non-interactive", "verbose", "revision", "merged-vendor", "current-wc"])
except getopt.GetoptError:
# print help information and exit:
usage()
for o, a in opts:
if o in ("-h", "--help"):
usage()
if o in ("-t", "--tag"):
tag = a
if o in ("-m", "--message"):
message = a
if o in ("--non-interactive"):
interactive = 0
if o in ("-v", "--verbose"):
logger.setLevel(logging.DEBUG)
if o in ("-r", "--revision"):
revision_to_parse = a
if o in ("-c", "--merged-vendor"):
merged_vendor = a
if o in ("-w", "--current-wc"):
wc_dir = a
if len(args) != 3:
usage()
repo_url, current_path, orig_repo_url = args[0:3]
if (not revision_to_parse):
usage("the revision numbers are mendatory")
global r_from, r_to
r_from, r_to = re.match("(\d+):(\d+)", revision_to_parse).groups()
if not r_from or not r_to:
usage("the revision numbers are mendatory")
try:
r_from_int = int(r_from)
r_to_int = int(r_to)
except ValueError:
usage("the revision parameter is not a number")
if r_from_int >= r_to_int:
usage("the 'from revision' must be inferior to the 'to revision'")
if not merged_vendor:
if orig_repo_url.startswith("http://"):
wc_dir_orig = checkout(orig_repo_url, r_from)
check_exit(wc_dir_orig, "Error during checkout")
check_exit(merge(wc_dir_orig, r_from, r_to), "Error during merge")
else:
usage("ORIGINAL_REPO_URL must start with 'http://'")
else:
wc_dir_orig = merged_vendor
if not wc_dir:
wc_dir = checkout(repo_url+"/"+current_path)
check_exit(wc_dir, "Error during checkout")
check_exit(treat_status(wc_dir_orig, wc_dir), "Error during resolving")
if (interactive):
fine_tune(wc_dir)
if not message:
message = "New vendor version, upgrading from revision %s to revision %s" % (r_from, r_to)
alert(["No message was specified to commit, the program will use that default one : '%s'" % (message),
"Press Enter to commit, or Ctrl-C to abort."])
check_exit(commit(wc_dir, message), "Error during commit")
if tag:
if not message:
message = "Tag %s, when upgrading the vendor branch from revision %s to revision %s" % (tag, r_from, r_to)
alert(["No message was specified to tag, the program will use that default one : '%s'" % (message),
"Press Enter to tag, or Ctrl-C to abort."])
check_exit(tag_wc(repo_url, current_path, tag, message), "Error during tag")
logger.info("Vendor branch merged, passed from %s to %s !" % (r_from, r_to))