Remove SPECIAL_KEYS and GclChange.Changelist() to simplify the code.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@16983 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 17 years ago
parent f3eee5692c
commit e1a524ff00

@ -8,7 +8,7 @@
def CheckChangeHasTestField(input_api, output_api):
"""Requires that the changelist have a TEST= field."""
if input_api.change.Test:
if input_api.change.TEST:
return []
else:
return [output_api.PresubmitNotifyResult(
@ -17,7 +17,7 @@ def CheckChangeHasTestField(input_api, output_api):
def CheckChangeHasBugField(input_api, output_api):
"""Requires that the changelist have a BUG= field."""
if input_api.change.BugIDs:
if input_api.change.BUG:
return []
else:
return [output_api.PresubmitNotifyResult(
@ -26,7 +26,7 @@ def CheckChangeHasBugField(input_api, output_api):
def CheckChangeHasTestedField(input_api, output_api):
"""Requires that the changelist have a TESTED= field."""
if input_api.change.Tested:
if input_api.change.TESTED:
return []
else:
return [output_api.PresubmitError("Changelist must have a TESTED= field.")]

@ -41,21 +41,6 @@ _tag_line_re = re.compile(
'^\s*(?P<key>[A-Z][A-Z_0-9]*)\s*=\s*(?P<value>.*?)\s*$')
# Friendly names may be used for certain keys. All values for key-value pairs
# in change descriptions (like BUG=123) can be retrieved from a change object
# directly as if they were attributes, e.g. change.R (or equivalently because
# we have a friendly name for it, change.Reviewers), change.BUG (or
# change.BugIDs) and so forth.
#
# Add to this mapping as needed/desired.
SPECIAL_KEYS = {
'Reviewers' : 'R',
'BugIDs' : 'BUG',
'Tested': 'TESTED',
'Test': 'TEST'
}
class NotImplementedException(Exception):
"""We're leaving placeholders in a bunch of places to remind us of the
design of the API, but we have not implemented all of it yet. Implement as
@ -459,10 +444,6 @@ class GclChange(object):
"""Returns the change name."""
return self.name
def Changelist(self):
"""Synonym for Change()."""
return self.Change()
def DescriptionText(self):
"""Returns the user-entered changelist description, minus tags.
@ -486,12 +467,7 @@ class GclChange(object):
You may use a friendly name (from SPECIAL_KEYS) or the actual name of
the key.
"""
if attr in SPECIAL_KEYS:
key = SPECIAL_KEYS[attr]
if key in self.tags:
return self.tags[key]
if attr in self.tags:
return self.tags[attr]
return self.tags.get(attr)
def AffectedFiles(self, include_dirs=False, include_deletes=True):
"""Returns a list of AffectedFile instances for all files in the change.

@ -116,7 +116,7 @@ class PresubmitUnittest(PresubmitTestsBase):
members = [
'AffectedFile', 'DoPresubmitChecks', 'GclChange', 'InputApi',
'ListRelevantPresubmitFiles', 'Main', 'NotImplementedException',
'OutputApi', 'ParseFiles', 'PresubmitExecuter', 'SPECIAL_KEYS',
'OutputApi', 'ParseFiles', 'PresubmitExecuter',
'ScanSubDirs', 'SvnAffectedFile', 'cPickle', 'cStringIO', 'exceptions',
'fnmatch', 'gcl', 'gclient', 'glob', 'marshal', 'normpath', 'optparse',
'os', 'pickle', 'presubmit_canned_checks', 're', 'subprocess', 'sys',
@ -162,13 +162,11 @@ class PresubmitUnittest(PresubmitTestsBase):
change = presubmit.GclChange(ci)
self.failUnless(change.Change() == 'mychange')
self.failUnless(change.Changelist() == 'mychange')
self.failUnless(change.DescriptionText() ==
'Hello there\nthis is a change\nand some more regular text')
self.failUnless(change.FullDescriptionText() ==
'\n'.join(description_lines))
self.failUnless(change.BugIDs == '123')
self.failUnless(change.BUG == '123')
self.failUnless(change.STORY == 'http://foo/')

Loading…
Cancel
Save