Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: gcl.py

Issue 6673104: Fix gcl to pass in the suggested owners properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """\ 6 """\
7 Wrapper script around Rietveld's upload.py that simplifies working with groups 7 Wrapper script around Rietveld's upload.py that simplifies working with groups
8 of files. 8 of files.
9 """ 9 """
10 10
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 parsed_lines = [] 317 parsed_lines = []
318 reviewers_re = re.compile(REVIEWERS_REGEX) 318 reviewers_re = re.compile(REVIEWERS_REGEX)
319 reviewers = '' 319 reviewers = ''
320 subject = '' 320 subject = ''
321 for l in description.splitlines(): 321 for l in description.splitlines():
322 if not subject: 322 if not subject:
323 subject = l 323 subject = l
324 matched_reviewers = reviewers_re.match(l) 324 matched_reviewers = reviewers_re.match(l)
325 if matched_reviewers: 325 if matched_reviewers:
326 reviewers = matched_reviewers.group(1) 326 reviewers = matched_reviewers.group(1).split(',')
327 parsed_lines.append(l) 327 parsed_lines.append(l)
328 328
329 if len(subject) > 100: 329 if len(subject) > 100:
330 subject = subject[:97] + '...' 330 subject = subject[:97] + '...'
331 331
332 self._subject = subject 332 self._subject = subject
333 self._reviewers = reviewers 333 self._reviewers = reviewers
334 self._description = '\n'.join(parsed_lines) 334 self._description = '\n'.join(parsed_lines)
335 335
336 description = property(_get_description, _set_description) 336 description = property(_get_description, _set_description)
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 759
760 def OptionallyDoPresubmitChecks(change_info, committing, args): 760 def OptionallyDoPresubmitChecks(change_info, committing, args):
761 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"): 761 if FilterFlag(args, "--no_presubmit") or FilterFlag(args, "--force"):
762 return presubmit_support.PresubmitOutput() 762 return presubmit_support.PresubmitOutput()
763 return DoPresubmitChecks(change_info, committing, True) 763 return DoPresubmitChecks(change_info, committing, True)
764 764
765 765
766 def suggest_reviewers(change_info, affected_files): 766 def suggest_reviewers(change_info, affected_files):
767 owners_db = owners.Database(change_info.GetLocalRoot(), fopen=file, 767 owners_db = owners.Database(change_info.GetLocalRoot(), fopen=file,
768 os_path=os.path) 768 os_path=os.path)
769 return owners_db.reviewers_for(affected_files) 769 return owners_db.reviewers_for([f[1] for f in affected_files])
770 770
771 771
772 def defer_attributes(a, b): 772 def defer_attributes(a, b):
773 """Copy attributes from an object (like a function) to another.""" 773 """Copy attributes from an object (like a function) to another."""
774 for x in dir(a): 774 for x in dir(a):
775 if not getattr(b, x, None): 775 if not getattr(b, x, None):
776 setattr(b, x, getattr(a, x)) 776 setattr(b, x, getattr(a, x))
777 777
778 778
779 def need_change(function): 779 def need_change(function):
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 description = change_info.description 1089 description = change_info.description
1090 1090
1091 other_files = GetFilesNotInCL() 1091 other_files = GetFilesNotInCL()
1092 1092
1093 # Edited files (as opposed to files with only changed properties) will have 1093 # Edited files (as opposed to files with only changed properties) will have
1094 # a letter for the first character in the status string. 1094 # a letter for the first character in the status string.
1095 file_re = re.compile(r"^[a-z].+\Z", re.IGNORECASE) 1095 file_re = re.compile(r"^[a-z].+\Z", re.IGNORECASE)
1096 affected_files = [x for x in other_files if file_re.match(x[0])] 1096 affected_files = [x for x in other_files if file_re.match(x[0])]
1097 unaffected_files = [x for x in other_files if not file_re.match(x[0])] 1097 unaffected_files = [x for x in other_files if not file_re.match(x[0])]
1098 1098
1099 suggested_reviewers = suggest_reviewers(change_info, affected_files) 1099 if not change_info.reviewers:
1100 if suggested_reviewers: 1100 suggested_reviewers = suggest_reviewers(change_info, affected_files)
1101 reviewers_re = re.compile(REVIEWERS_REGEX) 1101 if suggested_reviewers:
1102 if not any( 1102 reviewers_re = re.compile(REVIEWERS_REGEX)
1103 reviewers_re.match(l) for l in description.splitlines()): 1103 if not any(
1104 description += '\nR=' + ','.join(suggested_reviewers) + '\n' 1104 reviewers_re.match(l) for l in description.splitlines()):
1105 description += '\nR=' + ','.join(suggested_reviewers) + '\n'
1105 1106
1106 separator1 = ("\n---All lines above this line become the description.\n" 1107 separator1 = ("\n---All lines above this line become the description.\n"
1107 "---Repository Root: " + change_info.GetLocalRoot() + "\n" 1108 "---Repository Root: " + change_info.GetLocalRoot() + "\n"
1108 "---Paths in this changelist (" + change_info.name + "):\n") 1109 "---Paths in this changelist (" + change_info.name + "):\n")
1109 separator2 = "\n\n---Paths modified but not in any changelist:\n\n" 1110 separator2 = "\n\n---Paths modified but not in any changelist:\n\n"
1110 text = (description + separator1 + '\n' + 1111 text = (description + separator1 + '\n' +
1111 '\n'.join([f[0] + f[1] for f in change_info.GetFiles()])) 1112 '\n'.join([f[0] + f[1] for f in change_info.GetFiles()]))
1112 1113
1113 if change_info.Exists(): 1114 if change_info.Exists():
1114 text += (separator2 + 1115 text += (separator2 +
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 if e.code != 500: 1462 if e.code != 500:
1462 raise 1463 raise
1463 print >> sys.stderr, ( 1464 print >> sys.stderr, (
1464 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 1465 'AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
1465 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) 1466 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))
1466 return 1 1467 return 1
1467 1468
1468 1469
1469 if __name__ == "__main__": 1470 if __name__ == "__main__":
1470 sys.exit(main(sys.argv[1:])) 1471 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698