def CMDUploadChange(self, options, args, change):
    'Upload the patch to Rietveld.'
    upload_args = ['--assume_yes']
    upload_args.extend(['--server', self.GetCodereviewServer()])
    upload_args.extend(auth.auth_config_to_command_options(self._auth_config))
    if options.emulate_svn_auto_props:
        upload_args.append('--emulate_svn_auto_props')
    change_desc = None
    if (options.email is not None):
        upload_args.extend(['--email', options.email])
    if self.GetIssue():
        if options.title:
            upload_args.extend(['--title', options.title])
        if options.message:
            upload_args.extend(['--message', options.message])
        upload_args.extend(['--issue', str(self.GetIssue())])
        print(('This branch is associated with issue %s. Adding patch to that issue.' % self.GetIssue()))
    else:
        if options.title:
            upload_args.extend(['--title', options.title])
        message = (options.title or options.message or CreateDescriptionFromLog(args))
        change_desc = ChangeDescription(message)
        if (options.reviewers or options.tbr_owners):
            change_desc.update_reviewers(options.reviewers, options.tbr_owners, change)
        if (not options.force):
            change_desc.prompt()
        if (not change_desc.description):
            print('Description is empty; aborting.')
            return 1
        upload_args.extend(['--message', change_desc.description])
        if change_desc.get_reviewers():
            upload_args.append(('--reviewers=%s' % ','.join(change_desc.get_reviewers())))
        if options.send_mail:
            if (not change_desc.get_reviewers()):
                DieWithError('Must specify reviewers to send email.')
            upload_args.append('--send_mail')
        if options.private:
            logging.warn('rietveld.cc is ignored since private flag is specified.  You need to review and add them manually if necessary.')
            cc = self.GetCCListWithoutDefault()
        else:
            cc = self.GetCCList()
        cc = ','.join(filter(None, (cc, ','.join(options.cc))))
        if cc:
            upload_args.extend(['--cc', cc])
    if (options.private or (settings.GetDefaultPrivateFlag() == 'True')):
        upload_args.append('--private')
    upload_args.extend(['--git_similarity', str(options.similarity)])
    if (not options.find_copies):
        upload_args.extend(['--git_no_find_copies'])
    remote_url = self.GetGitBaseUrlFromConfig()
    if (not remote_url):
        if settings.GetIsGitSvn():
            remote_url = self.GetGitSvnRemoteUrl()
        elif (self.GetRemoteUrl() and ('/' in self.GetUpstreamBranch())):
            remote_url = ('%s@%s' % (self.GetRemoteUrl(), self.GetUpstreamBranch().split('/')[(- 1)]))
    if remote_url:
        upload_args.extend(['--base_url', remote_url])
        (remote, remote_branch) = self.GetRemoteBranch()
        target_ref = GetTargetRef(remote, remote_branch, options.target_branch, settings.GetPendingRefPrefix())
        if target_ref:
            upload_args.extend(['--target_ref', target_ref])
        (remote, upstream_branch) = self.FetchUpstreamTuple(self.GetBranch())
        upstream_branch = ShortBranchName(upstream_branch)
        if (remote is '.'):
            local_branch = upstream_branch
            if settings.GetIsSkipDependencyUpload(local_branch):
                print()
                print(('Skipping dependency patchset upload because git config branch.%s.skip-deps-uploads is set to True.' % local_branch))
                print()
            else:
                auth_config = auth.extract_auth_config_from_options(options)
                branch_cl = Changelist(branchref=('refs/heads/' + local_branch), auth_config=auth_config)
                branch_cl_issue_url = branch_cl.GetIssueURL()
                branch_cl_issue = branch_cl.GetIssue()
                branch_cl_patchset = branch_cl.GetPatchset()
                if (branch_cl_issue_url and branch_cl_issue and branch_cl_patchset):
                    upload_args.extend(['--depends_on_patchset', ('%s:%s' % (branch_cl_issue, branch_cl_patchset))])
                    print(('\nThe current branch (%s) is tracking a local branch (%s) with an associated CL.\nAdding %s/#ps%s as a dependency patchset.\n\n' % (self.GetBranch(), local_branch, branch_cl_issue_url, branch_cl_patchset)))
    project = settings.GetProject()
    if project:
        upload_args.extend(['--project', project])
    if options.cq_dry_run:
        upload_args.extend(['--cq_dry_run'])
    try:
        upload_args = ((['upload'] + upload_args) + args)
        logging.info('upload.RealMain(%s)', upload_args)
        (issue, patchset) = upload.RealMain(upload_args)
        issue = int(issue)
        patchset = int(patchset)
    except KeyboardInterrupt:
        sys.exit(1)
    except:
        if change_desc:
            backup_path = os.path.expanduser(DESCRIPTION_BACKUP_FILE)
            print(('\nGot exception while uploading -- saving description to %s\n' % backup_path))
            backup_file = open(backup_path, 'w')
            backup_file.write(change_desc.description)
            backup_file.close()
        raise
    if (not self.GetIssue()):
        self.SetIssue(issue)
    self.SetPatchset(patchset)
    if options.use_commit_queue:
        self.SetCQState(_CQState.COMMIT)
    return 0
Upload the patch to Rietveld.
def CMDUploadChange(self, options, args, change):
    
    upload_args = ['--assume_yes']
    upload_args.extend(['--server', self.GetCodereviewServer()])
    upload_args.extend(auth.auth_config_to_command_options(self._auth_config))
    if options.emulate_svn_auto_props:
        upload_args.append('--emulate_svn_auto_props')
    change_desc = None
    if (options.email is not None):
        upload_args.extend(['--email', options.email])
    if self.GetIssue():
        if options.title:
            upload_args.extend(['--title', options.title])
        if options.message:
            upload_args.extend(['--message', options.message])
        upload_args.extend(['--issue', str(self.GetIssue())])
        print(('This branch is associated with issue %s. Adding patch to that issue.' % self.GetIssue()))
    else:
        if options.title:
            upload_args.extend(['--title', options.title])
        message = (options.title or options.message or CreateDescriptionFromLog(args))
        change_desc = ChangeDescription(message)
        if (options.reviewers or options.tbr_owners):
            change_desc.update_reviewers(options.reviewers, options.tbr_owners, change)
        if (not options.force):
            change_desc.prompt()
        if (not change_desc.description):
            print('Description is empty; aborting.')
            return 1
        upload_args.extend(['--message', change_desc.description])
        if change_desc.get_reviewers():
            upload_args.append(('--reviewers=%s' % ','.join(change_desc.get_reviewers())))
        if options.send_mail:
            if (not change_desc.get_reviewers()):
                DieWithError('Must specify reviewers to send email.')
            upload_args.append('--send_mail')
        if options.private:
            logging.warn('rietveld.cc is ignored since private flag is specified.  You need to review and add them manually if necessary.')
            cc = self.GetCCListWithoutDefault()
        else:
            cc = self.GetCCList()
        cc = ','.join(filter(None, (cc, ','.join(options.cc))))
        if cc:
            upload_args.extend(['--cc', cc])
    if (options.private or (settings.GetDefaultPrivateFlag() == 'True')):
        upload_args.append('--private')
    upload_args.extend(['--git_similarity', str(options.similarity)])
    if (not options.find_copies):
        upload_args.extend(['--git_no_find_copies'])
    remote_url = self.GetGitBaseUrlFromConfig()
    if (not remote_url):
        if settings.GetIsGitSvn():
            remote_url = self.GetGitSvnRemoteUrl()
        elif (self.GetRemoteUrl() and ('/' in self.GetUpstreamBranch())):
            remote_url = ('%s@%s' % (self.GetRemoteUrl(), self.GetUpstreamBranch().split('/')[(- 1)]))
    if remote_url:
        upload_args.extend(['--base_url', remote_url])
        (remote, remote_branch) = self.GetRemoteBranch()
        target_ref = GetTargetRef(remote, remote_branch, options.target_branch, settings.GetPendingRefPrefix())
        if target_ref:
            upload_args.extend(['--target_ref', target_ref])
        (remote, upstream_branch) = self.FetchUpstreamTuple(self.GetBranch())
        upstream_branch = ShortBranchName(upstream_branch)
        if (remote is '.'):
            local_branch = upstream_branch
            if settings.GetIsSkipDependencyUpload(local_branch):
                print()
                print(('Skipping dependency patchset upload because git config branch.%s.skip-deps-uploads is set to True.' % local_branch))
                print()
            else:
                auth_config = auth.extract_auth_config_from_options(options)
                branch_cl = Changelist(branchref=('refs/heads/' + local_branch), auth_config=auth_config)
                branch_cl_issue_url = branch_cl.GetIssueURL()
                branch_cl_issue = branch_cl.GetIssue()
                branch_cl_patchset = branch_cl.GetPatchset()
                if (branch_cl_issue_url and branch_cl_issue and branch_cl_patchset):
                    upload_args.extend(['--depends_on_patchset', ('%s:%s' % (branch_cl_issue, branch_cl_patchset))])
                    print(('\nThe current branch (%s) is tracking a local branch (%s) with an associated CL.\nAdding %s/#ps%s as a dependency patchset.\n\n' % (self.GetBranch(), local_branch, branch_cl_issue_url, branch_cl_patchset)))
    project = settings.GetProject()
    if project:
        upload_args.extend(['--project', project])
    if options.cq_dry_run:
        upload_args.extend(['--cq_dry_run'])
    try:
        upload_args = ((['upload'] + upload_args) + args)
        logging.info('upload.RealMain(%s)', upload_args)
        (issue, patchset) = upload.RealMain(upload_args)
        issue = int(issue)
        patchset = int(patchset)
    except KeyboardInterrupt:
        sys.exit(1)
    except:
        if change_desc:
            backup_path = os.path.expanduser(DESCRIPTION_BACKUP_FILE)
            print(('\nGot exception while uploading -- saving description to %s\n' % backup_path))
            backup_file = open(backup_path, 'w')
            backup_file.write(change_desc.description)
            backup_file.close()
        raise
    if (not self.GetIssue()):
        self.SetIssue(issue)
    self.SetPatchset(patchset)
    if options.use_commit_queue:
        self.SetCQState(_CQState.COMMIT)
    return 0