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