def commit(root): """commit local modifications to remote remository""" cmd = "svn commit" code = common.command_free(cmd, root) if code != 0: sys.stderr.write("Failed: " + cmd) sys.exit(2)
def create_tag_core(root, url_from, revision_from, url_to): """core function of create tag""" cmd = "svn copy " + url_from + "@" + revision_from + " " + url_to code = common.command_free(cmd, root) if code != 0: sys.stderr.write("Failed: " + cmd) sys.exit(2)
def switch(root, url, revision): """Call `svn switch' to switch/update workspace to url -r revision""" cmd = "svn switch " + url if revision != "": cmd = cmd + " -r " + revision code = common.command_free(cmd, root) if code != 0: sys.stderr.write("Failed: " + cmd) sys.exit(2) print("Success to update/switch the working tree.")
def cleanup_working_tree(root): """Check and then clean up the working tree of the container / a component.""" cmd = "git status" (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) sys.exit(2) match = re.search(r"nothing to commit \(working directory clean\)", out) if match != None: return print("You should cleanup working tree "\ + "(via git reset/add/commit etc.) "\ + "before git checkout/merge/rebase/push:\n" + out\ + "(Hint: you may want to add them to .gitignore?)") match = re.search(r"# Not currently on any branch.", out) if match == None: print("1: add and commit all\n2: clean and reset all\n" \ + "3: handled clean up manually, pls continue\n4: quit") while True: choice = input("? ") if choice == '4': sys.exit(2) elif choice == '3': break elif choice == '2': cmd = "git clean -f ." (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) continue cmd = "git reset --hard HEAD" (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) continue break elif choice == '1': if common.cfgs['addnewfile']: cmd = "git add ." (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) continue cmd = "git commit -a" common.command_free(cmd, root) break else: print("1: clean and reset all\n2: handled clean up manually, "\ + "pls continue\n3: quit") while True: choice = input("? ") if choice == '3': sys.exit(2) elif choice == '2': break elif choice == '1': cmd = "git clean -d -f ." (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) continue cmd = "git reset --hard HEAD" (out, err, code) = common.command(cmd, root) if err: sys.stderr.write("Failed: " + cmd + "\n" + err) continue break