OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 import sys |
| 3 |
| 4 from git_common import current_branch, branches, upstream, run, hash_one |
| 5 |
| 6 |
| 7 def main(argv): |
| 8 assert len(argv) == 1, "No arguments expected" |
| 9 upfn = upstream |
| 10 cur = current_branch() |
| 11 if cur == 'HEAD': |
| 12 upfn = lambda b: hash_one(upstream(b)) |
| 13 cur = hash_one(cur) |
| 14 downstreams = [b for b in branches() if upfn(b) == cur] |
| 15 if not downstreams: |
| 16 return "No downstream branches" |
| 17 elif len(downstreams) == 1: |
| 18 run('checkout', downstreams[0]) |
| 19 else: |
| 20 high = len(downstreams) - 1 |
| 21 print |
| 22 while True: |
| 23 print "Please select a downstream branch" |
| 24 for i, b in enumerate(downstreams): |
| 25 print " %d. %s" % (i, b) |
| 26 r = raw_input("Selection (0-%d)[0]: " % high).strip() or '0' |
| 27 if not r.isdigit() or (0 > int(r) > high): |
| 28 print "Invalid choice." |
| 29 else: |
| 30 run('checkout', downstreams[int(r)]) |
| 31 break |
| 32 |
| 33 |
| 34 if __name__ == '__main__': |
| 35 sys.exit(main(sys.argv)) |
OLD | NEW |