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

Side by Side Diff: trychange.py

Issue 4127014: Blacklist more characters when sending a try job. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Use whitelist instead of blacklist, fix unit test Created 10 years, 1 month 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 | « tests/trychange_unittest.py ('k') | 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) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to 5 """Client-side script to send a try job to the try server. It communicates to
6 the try server by either writting to a svn repository or by directly connecting 6 the try server by either writting to a svn repository or by directly connecting
7 to the server by HTTP. 7 to the server by HTTP.
8 """ 8 """
9 9
10 import datetime 10 import datetime
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 class InvalidScript(Exception): 78 class InvalidScript(Exception):
79 def __str__(self): 79 def __str__(self):
80 return self.args[0] + '\n' + HELP_STRING 80 return self.args[0] + '\n' + HELP_STRING
81 81
82 82
83 class NoTryServerAccess(Exception): 83 class NoTryServerAccess(Exception):
84 def __str__(self): 84 def __str__(self):
85 return self.args[0] + '\n' + HELP_STRING 85 return self.args[0] + '\n' + HELP_STRING
86 86
87 87
88 def EscapeDot(name): 88 def Escape(name):
89 return name.replace('.', '-') 89 """Escapes characters that could interfere with the file system or try job
90 parsing.
91 """
92 return re.sub(r'[^\w#-]', '_', name)
90 93
91 94
92 class SCM(object): 95 class SCM(object):
93 """Simplistic base class to implement one function: ProcessOptions.""" 96 """Simplistic base class to implement one function: ProcessOptions."""
94 def __init__(self, options, path): 97 def __init__(self, options, path):
95 items = path.split('@') 98 items = path.split('@')
96 assert len(items) <= 2 99 assert len(items) <= 2
97 self.checkout_root = items[0] 100 self.checkout_root = items[0]
98 items.append(None) 101 items.append(None)
99 self.diff_against = items[1] 102 self.diff_against = items[1]
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 temp_dir = tempfile.mkdtemp() 374 temp_dir = tempfile.mkdtemp()
372 temp_file = tempfile.NamedTemporaryFile() 375 temp_file = tempfile.NamedTemporaryFile()
373 try: 376 try:
374 try: 377 try:
375 # Description 378 # Description
376 temp_file.write(description) 379 temp_file.write(description)
377 temp_file.flush() 380 temp_file.flush()
378 381
379 # Diff file 382 # Diff file
380 current_time = str(datetime.datetime.now()).replace(':', '.') 383 current_time = str(datetime.datetime.now()).replace(':', '.')
381 file_name = (EscapeDot(options.user) + '.' + EscapeDot(options.name) + 384 file_name = (Escape(options.user) + '.' + Escape(options.name) +
382 '.%s.diff' % current_time) 385 '.%s.diff' % current_time)
383 full_path = os.path.join(temp_dir, file_name) 386 full_path = os.path.join(temp_dir, file_name)
384 gclient_utils.FileWrite(full_path, options.diff, 'wb') 387 gclient_utils.FileWrite(full_path, options.diff, 'wb')
385 388
386 # Committing it will trigger a try job. 389 # Committing it will trigger a try job.
387 if sys.platform == "cygwin": 390 if sys.platform == "cygwin":
388 # Small chromium-specific issue here: 391 # Small chromium-specific issue here:
389 # git-try uses /usr/bin/python on cygwin but svn.bat will be used 392 # git-try uses /usr/bin/python on cygwin but svn.bat will be used
390 # instead of /usr/bin/svn by default. That causes bad things(tm) since 393 # instead of /usr/bin/svn by default. That causes bad things(tm) since
391 # Windows' svn.exe has no clue about cygwin paths. Hence force to use 394 # Windows' svn.exe has no clue about cygwin paths. Hence force to use
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 print >> sys.stderr, e 760 print >> sys.stderr, e
758 return 1 761 return 1
759 except gclient_utils.Error, e: 762 except gclient_utils.Error, e:
760 print >> sys.stderr, e 763 print >> sys.stderr, e
761 return 1 764 return 1
762 return 0 765 return 0
763 766
764 767
765 if __name__ == "__main__": 768 if __name__ == "__main__":
766 sys.exit(TryChange(None, [], False)) 769 sys.exit(TryChange(None, [], False))
OLDNEW
« no previous file with comments | « tests/trychange_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698