Commit 6493ed19 authored by maruel@chromium.org's avatar maruel@chromium.org

Fix rietveld_url parameter, remove default argument and realign code.

TBR=dpranke@chromium.org
BUG=
TEST=

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81579 0039d316-1c4b-4281-b951-d872f2087c98
parent 58407af8
......@@ -283,7 +283,7 @@ class ChangeInfo(object):
_SEPARATOR = "\n-----\n"
def __init__(self, name, issue, patchset, description, files, local_root,
rietveld_url, needs_upload=False):
rietveld_url, needs_upload):
self.name = name
self.issue = int(issue)
self.patchset = int(patchset)
......@@ -533,9 +533,7 @@ class ChangeInfo(object):
if not os.path.exists(info_file):
if fail_on_not_found:
ErrorExit("Changelist " + changename + " not found.")
return ChangeInfo(
changename, 0, 0, '', None, local_root, rietveld_url=None,
needs_upload=False)
return ChangeInfo(changename, 0, 0, '', None, local_root, None, False)
content = gclient_utils.FileRead(info_file, 'r')
save = False
try:
......@@ -563,9 +561,14 @@ class ChangeInfo(object):
if status != item[0]:
save = True
files[files.index(item)] = (status, item[1])
change_info = ChangeInfo(changename, values['issue'], values['patchset'],
values['description'], files,
local_root, values.get('rietveld'),
change_info = ChangeInfo(
changename,
values['issue'],
values['patchset'],
values['description'],
files,
local_root,
values.get('rietveld'),
values['needs_upload'])
if save:
change_info.Save()
......@@ -625,13 +628,11 @@ def LoadChangelistInfoForMultiple(changenames, local_root, fail_on_not_found,
This is mainly usefull to concatenate many changes into one for a 'gcl try'.
"""
changes = changenames.split(',')
aggregate_change_info = ChangeInfo(changenames, 0, 0, '', None, local_root,
rietveld=None, needs_upload=False)
aggregate_change_info = ChangeInfo(
changenames, 0, 0, '', None, local_root, None, False)
for change in changes:
aggregate_change_info._files += ChangeInfo.Load(change,
local_root,
fail_on_not_found,
update_status).GetFiles()
aggregate_change_info._files += ChangeInfo.Load(
change, local_root, fail_on_not_found, update_status).GetFiles()
return aggregate_change_info
......
......@@ -187,14 +187,21 @@ class ChangeInfoUnittest(GclTestsBase):
]
# If this test fails, you should add the relevant test.
self.compareMembers(
gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo'),
gcl.ChangeInfo('', 0, 0, '', None, self.fake_root_dir, 'foo', False),
members)
def testChangeInfoBase(self):
files = [('M', 'foo'), ('A', 'bar')]
self.mox.ReplayAll()
o = gcl.ChangeInfo('name2', '42', '53', 'description2', files,
self.fake_root_dir, 'foo')
o = gcl.ChangeInfo(
'name2',
'42',
'53',
'description2',
files,
self.fake_root_dir,
'foo',
False)
self.assertEquals(o.name, 'name2')
self.assertEquals(o.issue, 42)
self.assertEquals(o.patchset, 53)
......@@ -253,7 +260,8 @@ class ChangeInfoUnittest(GclTestsBase):
'foo', gcl.json.dumps(values, sort_keys=True, indent=2))
self.mox.ReplayAll()
change_info = gcl.ChangeInfo('', 1, 2, '', None, self.fake_root_dir, 'foo')
change_info = gcl.ChangeInfo(
'', 1, 2, '', None, self.fake_root_dir, 'foo', False)
change_info.Save()
def testSaveDirty(self):
......@@ -323,9 +331,15 @@ class CMDuploadUnittest(GclTestsBase):
'*** Upload does not submit a try; use gcl try to submit a try. ***\n')
def testServerOverride(self):
change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
change_info = gcl.ChangeInfo(
'naame',
0,
0,
'deescription',
[('A', 'aa'), ('M', 'bb')],
self.fake_root_dir, 'my_server')
self.fake_root_dir,
'my_server',
False)
self.mox.StubOutWithMock(change_info, 'Save')
change_info.Save()
output = presubmit_support.PresubmitOutput()
......@@ -358,9 +372,15 @@ class CMDuploadUnittest(GclTestsBase):
'*** Upload does not submit a try; use gcl try to submit a try. ***\n')
def testNormal(self):
change_info = gcl.ChangeInfo('naame', 0, 0, 'deescription',
change_info = gcl.ChangeInfo(
'naame',
0,
0,
'deescription',
[('A', 'aa'), ('M', 'bb')],
self.fake_root_dir, 'my_server')
self.fake_root_dir,
'my_server',
False)
self.mox.StubOutWithMock(change_info, 'Save')
change_info.Save()
output = presubmit_support.PresubmitOutput()
......
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