@staticmethod
def FetchUpstreamTuple(branch):
    "Returns a tuple containing remote and remote ref,\n       e.g. 'origin', 'refs/heads/master'\n    "
    remote = '.'
    upstream_branch = RunGit(['config', ('branch.%s.merge' % branch)], error_ok=True).strip()
    if upstream_branch:
        remote = RunGit(['config', ('branch.%s.remote' % branch)]).strip()
    else:
        upstream_branch = RunGit(['config', 'rietveld.upstream-branch'], error_ok=True).strip()
        if upstream_branch:
            remote = RunGit(['config', 'rietveld.upstream-remote']).strip()
        elif settings.GetIsGitSvn():
            upstream_branch = settings.GetSVNBranch()
        else:
            remote_branches = RunGit(['branch', '-r']).split()
            if ('origin/master' in remote_branches):
                remote = 'origin'
                upstream_branch = 'refs/heads/master'
            elif ('origin/trunk' in remote_branches):
                remote = 'origin'
                upstream_branch = 'refs/heads/trunk'
            else:
                DieWithError('Unable to determine default branch to diff against.\nEither pass complete "git diff"-style arguments, like\n  git cl upload origin/master\nor verify this branch is set up to track another \n(via the --track argument to "git checkout -b ...").')
    return (remote, upstream_branch)
Returns a tuple containing remote and remote ref,
e.g. 'origin', 'refs/heads/master'
@staticmethod
def FetchUpstreamTuple(branch):
    "Returns a tuple containing remote and remote ref,\n       e.g. 'origin', 'refs/heads/master'\n    "
    remote = '.'
    upstream_branch = RunGit(['config', ('branch.%s.merge' % branch)], error_ok=True).strip()
    if upstream_branch:
        remote = RunGit(['config', ('branch.%s.remote' % branch)]).strip()
    else:
        upstream_branch = RunGit(['config', 'rietveld.upstream-branch'], error_ok=True).strip()
        if upstream_branch:
            remote = RunGit(['config', 'rietveld.upstream-remote']).strip()
        elif settings.GetIsGitSvn():
            upstream_branch = settings.GetSVNBranch()
        else:
            remote_branches = RunGit(['branch', '-r']).split()
            if ('origin/master' in remote_branches):
                remote = 'origin'
                upstream_branch = 'refs/heads/master'
            elif ('origin/trunk' in remote_branches):
                remote = 'origin'
                upstream_branch = 'refs/heads/trunk'
            else:
                DieWithError('Unable to determine default branch to diff against.\nEither pass complete "git diff"-style arguments, like\n  git cl upload origin/master\nor verify this branch is set up to track another \n(via the --track argument to "git checkout -b ...").')
    return (remote, upstream_branch)