Commit ac0ba33c authored by brettw@chromium.org's avatar brettw@chromium.org

Add the ability to set the upstream branch

I can never remember the syntax (and always forget I have to specify the branch to set the upstream branch on) when using "git branch".

This patch just allows git-cl upstream to set the branch if an argument is provided. With no arg it prints the current one as it does today.

Review URL: https://chromiumcodereview.appspot.com/10825285

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@150945 0039d316-1c4b-4281-b951-d872f2087c98
parent 2cc66429
......@@ -1514,13 +1514,22 @@ def CMDtree(parser, args):
return 0
@usage('[new upstream branch]')
def CMDupstream(parser, args):
"""print the name of the upstream branch, if any"""
"""prints or sets the name of the upstream branch, if any"""
_, args = parser.parse_args(args)
if args:
if len(args) > 1:
parser.error('Unrecognized args: %s' % ' '.join(args))
return 0
cl = Changelist()
print cl.GetUpstreamBranch()
if args:
# One arg means set upstream branch.
RunGit(['branch', '--set-upstream', cl.GetBranch(), args[0]])
cl = Changelist()
print "Upstream branch set to " + cl.GetUpstreamBranch()
else:
print cl.GetUpstreamBranch()
return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment