Commit 152cf833 authored by sheyang@chromium.org's avatar sheyang@chromium.org

Upload project option in 'gcl' and 'git cl' uploading commands.



BUG=374398

Review URL: https://codereview.chromium.org/298703003

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@276491 0039d316-1c4b-4281-b951-d872f2087c98
parent 565b1780
......@@ -911,6 +911,10 @@ def CMDupload(change_info, args):
if GetCodeReviewSetting("PRIVATE") == "True":
upload_arg.append("--private")
project = GetCodeReviewSetting("PROJECT")
if project:
upload_arg.append("--project=%s" % project)
# If we have a lot of files with long paths, then we won't be able to fit
# the command to "svn diff". Instead, we generate the diff manually for
# each file and concatenate them before passing it to upload.py.
......
......@@ -281,6 +281,7 @@ class Settings(object):
self.updated = False
self.is_gerrit = None
self.git_editor = None
self.project = None
def LazyUpdateIfNeeded(self):
"""Updates the settings from a codereview.settings file, if available."""
......@@ -442,6 +443,11 @@ class Settings(object):
return (self._GetRietveldConfig('cpplint-ignore-regex', error_ok=True) or
DEFAULT_LINT_IGNORE_REGEX)
def GetProject(self):
if not self.project:
self.project = self._GetRietveldConfig('project', error_ok=True)
return self.project
def _GetRietveldConfig(self, param, **kwargs):
return self._GetConfig('rietveld.' + param, **kwargs)
......@@ -1067,6 +1073,7 @@ def LoadCodereviewSettingsFromFile(fileobj):
SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True)
SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True)
SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True)
SetProperty('project', 'PROJECT', unset_error_ok=True)
if 'GERRIT_HOST' in keyvals:
RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']])
......@@ -1619,6 +1626,10 @@ def RietveldUpload(options, args, cl):
if remote_url:
upload_args.extend(['--base_url', remote_url])
project = settings.GetProject()
if project:
upload_args.extend(['--project', project])
try:
upload_args = ['upload'] + upload_args + args
logging.info('upload.RealMain(%s)', upload_args)
......
......@@ -367,6 +367,7 @@ class CMDuploadUnittest(GclTestsBase):
gcl.os.close(42)
gcl.GetCodeReviewSetting('CC_LIST')
gcl.GetCodeReviewSetting('PRIVATE')
gcl.GetCodeReviewSetting('PROJECT')
gcl.os.getcwd().AndReturn('somewhere')
gcl.os.chdir(change_info.GetLocalRoot())
gcl.GenerateDiff(change_info.GetFileNames())
......@@ -409,6 +410,7 @@ class CMDuploadUnittest(GclTestsBase):
gcl.os.close(42)
gcl.GetCodeReviewSetting('CC_LIST')
gcl.GetCodeReviewSetting('PRIVATE')
gcl.GetCodeReviewSetting('PROJECT')
gcl.os.getcwd().AndReturn('somewhere')
gcl.os.chdir(change_info.GetLocalRoot())
gcl.GenerateDiff(change_info.GetFileNames())
......
......@@ -210,6 +210,7 @@ class TestGitCl(TestCase):
(('', None), 0)),
((['git', 'rev-parse', '--show-cdup'],), ''),
((['git', 'svn', 'info'],), ''),
((['git', 'config', 'rietveld.project'],), ''),
((['git',
'config', 'branch.master.rietveldissue', '1'],), ''),
((['git', 'config', 'branch.master.rietveldserver',
......@@ -686,6 +687,8 @@ class TestGitCl(TestCase):
'rietveld.cpplint-regex'],), ''),
((['git', 'config', '--unset-all',
'rietveld.cpplint-ignore-regex'],), ''),
((['git', 'config', '--unset-all',
'rietveld.project'],), ''),
((['git', 'config', 'gerrit.host',
'gerrit.chromium.org'],), ''),
# DownloadHooks(False)
......
......@@ -629,6 +629,8 @@ group.add_option("-j", "--number-parallel-uploads",
group = parser.add_option_group("Issue options")
group.add_option("-t", "--title", action="store", dest="title",
help="New issue subject or new patch set title")
group.add_option("--project", action="store", dest="project",
help="The project the issue belongs to")
group.add_option("-m", "--message", action="store", dest="message",
default=None,
help="New issue description or new patch set message")
......@@ -2596,6 +2598,8 @@ def RealMain(argv, data=None):
for cc in options.cc.split(','):
CheckReviewer(cc)
form_fields.append(("cc", options.cc))
if options.project:
form_fields.append(("project", options.project))
# Process --message, --title and --file.
message = options.message or ""
......
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