

def push(project, local_ref, remote_branch, bypass_review=False, dry_run=False, reviewers=None, topic=None, draft=False):
    ' Push the changes for review.\n\n    Unless review is False, in this case, simply update\n    the remote gerrit branch\n\n    :param reviewers: A list of reviewers to invite to review\n\n    '
    git = qisrc.git.Git(project.path)
    review_remote = project.review_remote
    args = list()
    if dry_run:
        args.append('--dry-run')
    args.append(review_remote.url)
    if bypass_review:
        args.append(('%s:%s' % (local_ref, remote_branch)))
    else:
        ui.info('Pushing code to', review_remote.name, 'for review.')
        if draft:
            remote_ref = ('refs/drafts/%s' % remote_branch)
        else:
            remote_ref = ('refs/for/%s' % remote_branch)
        if topic:
            remote_ref = ('%s/%s' % (remote_ref, topic))
        args.append(('%s:%s' % (local_ref, remote_ref)))
    if (reviewers and (not dry_run)):
        remote = project.review_remote
        remote.parse_url()
        server = remote.server
        username = remote.username
        ssh_port = remote.port
        ui.info('Fetching', remote.name)
        git.fetch(remote.name, '--quiet')
        commits_pushed = git.get_log(('%s/%s' % (remote.name, remote_branch)), 'HEAD')
        sha1s = [commit['sha1'] for commit in commits_pushed]
    ui.info('Publishing changes')
    git.push(*args)
    if (reviewers and (not dry_run)):
        ui.info('Adding reviewers...', (('(' + ', '.join(reviewers)) + ')'))
        try:
            set_reviewers(sha1s, reviewers, username, server, ssh_port)
        except qisys.command.CommandFailedException as e:
            ui.warning("Couldn't set reviewers")
            ui.warning(e)
        else:
            ui.info('Done!')

dataset/ETHPy150Open aldebaran/qibuild/python/qisrc/review.py push/original