Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 import sys | |
| 3 | |
| 4 from git_common import upstream, current_branch, run | |
| 5 from git_common import get_or_create_merge_base_tag | |
| 6 | |
| 7 def main(argv): | |
| 8 # TODO(iannucci): Add --verbose | |
|
Ryan Tseng
2014/02/28 21:22:05
Add --help. "reparent branch" also isn't self evi
| |
| 9 | |
| 10 assert len(argv) == 2, "Must supply new parent" | |
| 11 branch = current_branch() | |
| 12 new_parent = argv[1] | |
| 13 cur_parent = upstream(branch) | |
| 14 assert branch != 'HEAD', 'Must be on the branch you want to reparent' | |
|
agable
2014/02/28 20:14:16
Could let them specify the branch they want to rep
iannucci
2014/03/20 10:59:37
added TODO
| |
| 15 assert cur_parent != new_parent | |
| 16 | |
| 17 get_or_create_merge_base_tag(branch, cur_parent) | |
| 18 | |
| 19 print "Reparenting %s to track %s (was %s)" % (branch, new_parent, cur_parent) | |
| 20 run('branch', '--set-upstream-to', new_parent, branch) | |
| 21 try: | |
| 22 cmd = ['reup'] #+ (['--verbose'] if VERBOSE else []) | |
| 23 run(*cmd, stdout=None, stderr=None) | |
| 24 except: | |
| 25 print "Resetting parent back to %s" % (cur_parent) | |
| 26 run('branch', '--set-upstream-to', cur_parent, branch) | |
| 27 raise | |
| 28 | |
| 29 return 0 | |
| 30 | |
| 31 | |
| 32 if __name__ == '__main__': | |
| 33 sys.exit(main(sys.argv)) | |
| 34 | |
| 35 | |
| OLD | NEW |