| OLD | NEW | 
|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 278   """ | 278   """ | 
| 279   # Kept for unit test support. This is for the old format, it's deprecated. | 279   # Kept for unit test support. This is for the old format, it's deprecated. | 
| 280   SEPARATOR = "\n-----\n" | 280   SEPARATOR = "\n-----\n" | 
| 281 | 281 | 
| 282   def __init__(self, name, issue, patchset, description, files, local_root, | 282   def __init__(self, name, issue, patchset, description, files, local_root, | 
| 283                rietveld_url, needs_upload): | 283                rietveld_url, needs_upload): | 
| 284     self.name = name | 284     self.name = name | 
| 285     self.issue = int(issue) | 285     self.issue = int(issue) | 
| 286     self.patchset = int(patchset) | 286     self.patchset = int(patchset) | 
| 287     self._description = None | 287     self._description = None | 
|  | 288     self._subject = None | 
| 288     self._reviewers = None | 289     self._reviewers = None | 
| 289     self._set_description(description) | 290     self._set_description(description) | 
| 290     if files is None: | 291     if files is None: | 
| 291       files = [] | 292       files = [] | 
| 292     self._files = files | 293     self._files = files | 
| 293     self.patch = None | 294     self.patch = None | 
| 294     self._local_root = local_root | 295     self._local_root = local_root | 
| 295     self.needs_upload = needs_upload | 296     self.needs_upload = needs_upload | 
| 296     self.rietveld = gclient_utils.UpgradeToHttps( | 297     self.rietveld = gclient_utils.UpgradeToHttps( | 
| 297         rietveld_url or GetCodeReviewSetting('CODE_REVIEW_SERVER')) | 298         rietveld_url or GetCodeReviewSetting('CODE_REVIEW_SERVER')) | 
| 298     self._rpc_server = None | 299     self._rpc_server = None | 
| 299 | 300 | 
| 300   def _get_description(self): | 301   def _get_description(self): | 
| 301     return self._description | 302     return self._description | 
| 302 | 303 | 
| 303   def _set_description(self, description): | 304   def _set_description(self, description): | 
| 304     # TODO(dpranke): Cloned from git_cl.py. These should be shared. | 305     # TODO(dpranke): Cloned from git_cl.py. These should be shared. | 
| 305     if not description: | 306     if not description: | 
| 306       self._description = description | 307       self._description = description | 
| 307       return | 308       return | 
| 308 | 309 | 
| 309     parsed_lines = [] | 310     parsed_lines = [] | 
| 310     reviewers_re = re.compile(REVIEWERS_REGEX) | 311     reviewers_re = re.compile(REVIEWERS_REGEX) | 
| 311     reviewers = '' | 312     reviewers = '' | 
|  | 313     subject = '' | 
| 312     for l in description.splitlines(): | 314     for l in description.splitlines(): | 
|  | 315       if not subject: | 
|  | 316         subject = l | 
| 313       matched_reviewers = reviewers_re.match(l) | 317       matched_reviewers = reviewers_re.match(l) | 
| 314       if matched_reviewers: | 318       if matched_reviewers: | 
| 315         reviewers = matched_reviewers.group(1).split(',') | 319         reviewers = matched_reviewers.group(1).split(',') | 
| 316       parsed_lines.append(l) | 320       parsed_lines.append(l) | 
|  | 321 | 
|  | 322     if len(subject) > 100: | 
|  | 323       subject = subject[:97] + '...' | 
|  | 324 | 
|  | 325     self._subject = subject | 
| 317     self._reviewers = reviewers | 326     self._reviewers = reviewers | 
| 318     self._description = '\n'.join(parsed_lines) | 327     self._description = '\n'.join(parsed_lines) | 
| 319 | 328 | 
| 320   description = property(_get_description, _set_description) | 329   description = property(_get_description, _set_description) | 
| 321 | 330 | 
| 322   @property | 331   @property | 
| 323   def reviewers(self): | 332   def reviewers(self): | 
| 324     return self._reviewers | 333     return self._reviewers | 
| 325 | 334 | 
|  | 335   @property | 
|  | 336   def subject(self): | 
|  | 337     return self._subject | 
|  | 338 | 
| 326   def NeedsUpload(self): | 339   def NeedsUpload(self): | 
| 327     return self.needs_upload | 340     return self.needs_upload | 
| 328 | 341 | 
| 329   def GetFileNames(self): | 342   def GetFileNames(self): | 
| 330     """Returns the list of file names included in this change.""" | 343     """Returns the list of file names included in this change.""" | 
| 331     return [f[1] for f in self._files] | 344     return [f[1] for f in self._files] | 
| 332 | 345 | 
| 333   def GetFiles(self): | 346   def GetFiles(self): | 
| 334     """Returns the list of files included in this change with their status.""" | 347     """Returns the list of files included in this change with their status.""" | 
| 335     return self._files | 348     return self._files | 
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 839   reviewers = change_info.reviewers or output.reviewers | 852   reviewers = change_info.reviewers or output.reviewers | 
| 840   if (reviewers and | 853   if (reviewers and | 
| 841       not any(arg.startswith('-r') or arg.startswith('--reviewer') for | 854       not any(arg.startswith('-r') or arg.startswith('--reviewer') for | 
| 842               arg in args)): | 855               arg in args)): | 
| 843     upload_arg.append('--reviewers=%s' % ','.join(reviewers)) | 856     upload_arg.append('--reviewers=%s' % ','.join(reviewers)) | 
| 844 | 857 | 
| 845   upload_arg.extend(args) | 858   upload_arg.extend(args) | 
| 846 | 859 | 
| 847   desc_file = None | 860   desc_file = None | 
| 848   try: | 861   try: | 
| 849     if change_info.issue: | 862     if change_info.issue:  # Uploading a new patchset. | 
| 850       # Uploading a new patchset. | 863       found_message = False | 
|  | 864       for arg in args: | 
|  | 865         if arg.startswith("--message") or arg.startswith("-m"): | 
|  | 866           found_message = True | 
|  | 867           break | 
|  | 868 | 
|  | 869       if not found_message: | 
|  | 870         upload_arg.append("--message=''") | 
|  | 871 | 
| 851       upload_arg.append("--issue=%d" % change_info.issue) | 872       upload_arg.append("--issue=%d" % change_info.issue) | 
| 852     else: | 873     else: # First time we upload. | 
| 853       # First time we upload. |  | 
| 854       handle, desc_file = tempfile.mkstemp(text=True) | 874       handle, desc_file = tempfile.mkstemp(text=True) | 
| 855       os.write(handle, change_info.description) | 875       os.write(handle, change_info.description) | 
| 856       os.close(handle) | 876       os.close(handle) | 
| 857 | 877 | 
| 858       # Watchlist processing -- CC people interested in this changeset | 878       # Watchlist processing -- CC people interested in this changeset | 
| 859       # http://dev.chromium.org/developers/contributing-code/watchlists | 879       # http://dev.chromium.org/developers/contributing-code/watchlists | 
| 860       if not no_watchlists: | 880       if not no_watchlists: | 
| 861         import watchlists | 881         import watchlists | 
| 862         watchlist = watchlists.Watchlists(change_info.GetLocalRoot()) | 882         watchlist = watchlists.Watchlists(change_info.GetLocalRoot()) | 
| 863         watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames()) | 883         watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames()) | 
| 864 | 884 | 
| 865       cc_list = GetCodeReviewSetting("CC_LIST") | 885       cc_list = GetCodeReviewSetting("CC_LIST") | 
| 866       if not no_watchlists and watchers: | 886       if not no_watchlists and watchers: | 
| 867         # Filter out all empty elements and join by ',' | 887         # Filter out all empty elements and join by ',' | 
| 868         cc_list = ','.join(filter(None, [cc_list] + watchers)) | 888         cc_list = ','.join(filter(None, [cc_list] + watchers)) | 
| 869       if cc_list: | 889       if cc_list: | 
| 870         upload_arg.append("--cc=" + cc_list) | 890         upload_arg.append("--cc=" + cc_list) | 
| 871       upload_arg.append("--file=%s" % desc_file) | 891       upload_arg.append("--description_file=%s" % desc_file) | 
|  | 892       if change_info.subject: | 
|  | 893         upload_arg.append("--message=" + change_info.subject) | 
| 872 | 894 | 
| 873       if GetCodeReviewSetting("PRIVATE") == "True": | 895       if GetCodeReviewSetting("PRIVATE") == "True": | 
| 874         upload_arg.append("--private") | 896         upload_arg.append("--private") | 
| 875 | 897 | 
| 876     # If we have a lot of files with long paths, then we won't be able to fit | 898     # If we have a lot of files with long paths, then we won't be able to fit | 
| 877     # the command to "svn diff".  Instead, we generate the diff manually for | 899     # the command to "svn diff".  Instead, we generate the diff manually for | 
| 878     # each file and concatenate them before passing it to upload.py. | 900     # each file and concatenate them before passing it to upload.py. | 
| 879     if change_info.patch is None: | 901     if change_info.patch is None: | 
| 880       change_info.patch = GenerateDiff(change_info.GetFileNames()) | 902       change_info.patch = GenerateDiff(change_info.GetFileNames()) | 
| 881 | 903 | 
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1440       raise | 1462       raise | 
| 1441     print >> sys.stderr, ( | 1463     print >> sys.stderr, ( | 
| 1442         'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 1464         'AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 
| 1443         'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 1465         'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)) | 
| 1444     return 1 | 1466     return 1 | 
| 1445 | 1467 | 
| 1446 | 1468 | 
| 1447 if __name__ == "__main__": | 1469 if __name__ == "__main__": | 
| 1448   fix_encoding.fix_encoding() | 1470   fix_encoding.fix_encoding() | 
| 1449   sys.exit(main(sys.argv[1:])) | 1471   sys.exit(main(sys.argv[1:])) | 
| OLD | NEW | 
|---|