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

Side by Side Diff: gcl.py

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

Powered by Google App Engine
This is Rietveld 408576698