Melting pot of changes.

Fix GclChangeInfo.__getattr__ to only accept uppercase tags.
Rename illnamed GclChangeInfo.Change() to GclChangeInfo.Name().
Fix random comments.

TEST=unit test
BUG=none

Review URL: http://codereview.chromium.org/122016

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@18138 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 16 years ago
parent 196f8cbabb
commit 92022ec600

@ -529,7 +529,7 @@ class GclChange(object):
for info in change_info.files for info in change_info.files
] ]
def Change(self): def Name(self):
"""Returns the change name.""" """Returns the change name."""
return self._name return self._name
@ -547,15 +547,15 @@ class GclChange(object):
return self._full_description return self._full_description
def RepositoryRoot(self): def RepositoryRoot(self):
"""Returns the repository root for this change, as an absolute path.""" """Returns the repository (checkout) root directory for this change,
as an absolute path.
"""
return self._repository_root return self._repository_root
def __getattr__(self, attr): def __getattr__(self, attr):
"""Return keys directly as attributes on the object. """Return tags directly as attributes on the object."""
if not re.match(r"^[A-Z_]*$", attr):
You may use a friendly name (from SPECIAL_KEYS) or the actual name of raise AttributeError(self, attr)
the key.
"""
return self.tags.get(attr) return self.tags.get(attr)
def AffectedFiles(self, include_dirs=False, include_deletes=True): def AffectedFiles(self, include_dirs=False, include_deletes=True):

@ -210,7 +210,7 @@ class PresubmitUnittest(PresubmitTestsBase):
files=files) files=files)
change = presubmit.GclChange(ci) change = presubmit.GclChange(ci)
self.failUnless(change.Change() == 'mychange') self.failUnless(change.Name() == 'mychange')
self.failUnless(change.DescriptionText() == self.failUnless(change.DescriptionText() ==
'Hello there\nthis is a change\nand some more regular text') 'Hello there\nthis is a change\nand some more regular text')
self.failUnless(change.FullDescriptionText() == self.failUnless(change.FullDescriptionText() ==
@ -489,6 +489,13 @@ def CheckChangeOnUpload(input_api, output_api):
return [output_api.PresubmitError('Tag parsing failed. 6')] return [output_api.PresubmitError('Tag parsing failed. 6')]
if input_api.change.STORY != 'http://tracker.com/42': if input_api.change.STORY != 'http://tracker.com/42':
return [output_api.PresubmitError('Tag parsing failed. 7')] return [output_api.PresubmitError('Tag parsing failed. 7')]
try:
y = False
x = input_api.change.invalid
except AttributeError:
y = True
if not y:
return [output_api.PresubmitError('Tag parsing failed. 8')]
if 'TEST' in input_api.change.tags: if 'TEST' in input_api.change.tags:
return [output_api.PresubmitError('Tag parsing failed. 3')] return [output_api.PresubmitError('Tag parsing failed. 3')]
if input_api.change.DescriptionText() != 'Blah Blah': if input_api.change.DescriptionText() != 'Blah Blah':
@ -907,8 +914,8 @@ class GclChangeUnittest(PresubmitTestsBase):
def testMembersChanged(self): def testMembersChanged(self):
self.mox.ReplayAll() self.mox.ReplayAll()
members = [ members = [
'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedTextFiles', 'Change', 'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedTextFiles',
'DescriptionText', 'FullDescriptionText', 'LocalPaths', 'DescriptionText', 'FullDescriptionText', 'LocalPaths', 'Name',
'RepositoryRoot', 'RightHandSideLines', 'ServerPaths', 'RepositoryRoot', 'RightHandSideLines', 'ServerPaths',
'issue', 'patchset', 'tags', 'issue', 'patchset', 'tags',
] ]

Loading…
Cancel
Save