Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: git_nav_downstream.py

Issue 184113002: Add git-map and git-short-map to depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@new_branch
Patch Set: Make it work on windows Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « git_map_branches.py ('k') | git_number.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 """
3 Checks out a downstream branch from the currently checked out branch. If there
4 is more than one downstream branch, then this script will prompt you to select
5 which branch.
6 """
7 import sys
8
9 from git_common import current_branch, branches, upstream, run, hash_one
10
11
12 def main(argv):
13 assert len(argv) == 1, "No arguments expected"
14 upfn = upstream
15 cur = current_branch()
16 if cur == 'HEAD':
17 upfn = lambda b: hash_one(upstream(b))
18 cur = hash_one(cur)
19 downstreams = [b for b in branches() if upfn(b) == cur]
20 if not downstreams:
21 return "No downstream branches"
22 elif len(downstreams) == 1:
23 run('checkout', downstreams[0])
24 else:
25 high = len(downstreams) - 1
26 print
27 while True:
28 print "Please select a downstream branch"
29 for i, b in enumerate(downstreams):
30 print " %d. %s" % (i, b)
31 r = raw_input("Selection (0-%d)[0]: " % high).strip() or '0'
32 if not r.isdigit() or (0 > int(r) > high):
33 print "Invalid choice."
34 else:
35 run('checkout', downstreams[int(r)])
36 break
37
38
39 if __name__ == '__main__':
40 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « git_map_branches.py ('k') | git_number.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698