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
experimental/szager/collated-output
brettw@chromium.org 13 years ago
parent 2cc664298b
commit ac0ba33c80

@ -1514,12 +1514,21 @@ 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()
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

Loading…
Cancel
Save