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

Unified Diff: git_nav_downstream.py

Issue 225433003: Add a basic tutorial for the tools in depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@git_map
Patch Set: pylint Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_nav_downstream.py
diff --git a/git_nav_downstream.py b/git_nav_downstream.py
index 4d8b823cb7e2c4cf1e50025ac3b92fd68ec6c16c..bce850e4163e05652b68faf83a392bccc62bf249 100755
--- a/git_nav_downstream.py
+++ b/git_nav_downstream.py
@@ -9,13 +9,20 @@ is more than one downstream branch, then this script will prompt you to select
which branch.
"""
+import argparse
import sys
-from git_common import current_branch, branches, upstream, run, hash_one
+from git_common import current_branch, branches, upstream, run_stream, hash_one
-def main(argv):
- assert len(argv) == 1, "No arguments expected"
+def main(args):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--pick',
+ help=(
+ 'The number to pick if this command would '
+ 'prompt'))
+ opts = parser.parse_args(args)
+
upfn = upstream
cur = current_branch()
if cur == 'HEAD':
@@ -29,21 +36,26 @@ def main(argv):
if not downstreams:
return "No downstream branches"
elif len(downstreams) == 1:
- run('checkout', downstreams[0])
+ run_stream('checkout', downstreams[0], stdout=sys.stdout, stderr=sys.stderr)
else:
high = len(downstreams) - 1
- print
while True:
print "Please select a downstream branch"
for i, b in enumerate(downstreams):
print " %d. %s" % (i, b)
- r = raw_input("Selection (0-%d)[0]: " % high).strip() or '0'
+ prompt = "Selection (0-%d)[0]: " % high
+ r = opts.pick
+ if r:
+ print prompt + r
+ else:
+ r = raw_input(prompt).strip() or '0'
if not r.isdigit() or (0 > int(r) > high):
print "Invalid choice."
else:
- run('checkout', downstreams[int(r)])
+ run_stream('checkout', downstreams[int(r)], stdout=sys.stdout,
+ stderr=sys.stderr)
break
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main(sys.argv[1:]))
« no previous file with comments | « git_common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698