| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-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 # | 5 # |
| 6 # Wrapper script around Rietveld's upload.py that groups files into | 6 # Wrapper script around Rietveld's upload.py that groups files into |
| 7 # changelists. | 7 # changelists. |
| 8 | 8 |
| 9 import getpass | 9 import getpass |
| 10 import os | 10 import os |
| 11 import random | 11 import random |
| 12 import re | 12 import re |
| 13 import string | 13 import string |
| 14 import subprocess | 14 import subprocess |
| 15 import sys | 15 import sys |
| 16 import tempfile | 16 import tempfile |
| 17 import upload | 17 import upload |
| 18 import urllib2 | 18 import urllib2 |
| 19 | 19 |
| 20 |
| 21 __version__ = '1.0' |
| 22 |
| 23 |
| 20 CODEREVIEW_SETTINGS = { | 24 CODEREVIEW_SETTINGS = { |
| 21 # Default values. | 25 # Default values. |
| 22 "CODE_REVIEW_SERVER": "codereview.chromium.org", | 26 "CODE_REVIEW_SERVER": "codereview.chromium.org", |
| 23 "CC_LIST": "chromium-reviews@googlegroups.com", | 27 "CC_LIST": "chromium-reviews@googlegroups.com", |
| 24 "VIEW_VC": "http://src.chromium.org/viewvc/chrome?view=rev&revision=", | 28 "VIEW_VC": "http://src.chromium.org/viewvc/chrome?view=rev&revision=", |
| 25 } | 29 } |
| 26 | 30 |
| 27 # Use a shell for subcommands on Windows to get a PATH search, and because svn | 31 # Use a shell for subcommands on Windows to get a PATH search, and because svn |
| 28 # may be a batch file. | 32 # may be a batch file. |
| 29 use_shell = sys.platform.startswith("win") | 33 use_shell = sys.platform.startswith("win") |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 p.wait() | 196 p.wait() |
| 193 p.stdout.close() | 197 p.stdout.close() |
| 194 return output, p.returncode | 198 return output, p.returncode |
| 195 | 199 |
| 196 | 200 |
| 197 def RunShell(command, print_output=False): | 201 def RunShell(command, print_output=False): |
| 198 """Executes a command and returns the output.""" | 202 """Executes a command and returns the output.""" |
| 199 return RunShellWithReturnCode(command, print_output)[0] | 203 return RunShellWithReturnCode(command, print_output)[0] |
| 200 | 204 |
| 201 | 205 |
| 202 def ReadFile(filename): | 206 def ReadFile(filename, flags='r'): |
| 203 """Returns the contents of a file.""" | 207 """Returns the contents of a file.""" |
| 204 file = open(filename, 'r') | 208 file = open(filename, flags) |
| 205 result = file.read() | 209 result = file.read() |
| 206 file.close() | 210 file.close() |
| 207 return result | 211 return result |
| 208 | 212 |
| 209 | 213 |
| 210 def WriteFile(filename, contents): | 214 def WriteFile(filename, contents): |
| 211 """Overwrites the file with the given contents.""" | 215 """Overwrites the file with the given contents.""" |
| 212 file = open(filename, 'w') | 216 file = open(filename, 'w') |
| 213 file.write(contents) | 217 file.write(contents) |
| 214 file.close() | 218 file.close() |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 print "".join(file) | 569 print "".join(file) |
| 566 | 570 |
| 567 | 571 |
| 568 def Help(argv=None): | 572 def Help(argv=None): |
| 569 if argv and argv[0] == 'try': | 573 if argv and argv[0] == 'try': |
| 570 TryChange(None, ['--help'], swallow_exception=False) | 574 TryChange(None, ['--help'], swallow_exception=False) |
| 571 return | 575 return |
| 572 | 576 |
| 573 print ( | 577 print ( |
| 574 """GCL is a wrapper for Subversion that simplifies working with groups of files. | 578 """GCL is a wrapper for Subversion that simplifies working with groups of files. |
| 579 version """ + __version__ + """ |
| 575 | 580 |
| 576 Basic commands: | 581 Basic commands: |
| 577 ----------------------------------------- | 582 ----------------------------------------- |
| 578 gcl change change_name | 583 gcl change change_name |
| 579 Add/remove files to a changelist. Only scans the current directory and | 584 Add/remove files to a changelist. Only scans the current directory and |
| 580 subdirectories. | 585 subdirectories. |
| 581 | 586 |
| 582 gcl upload change_name [-r reviewer1@gmail.com,reviewer2@gmail.com,...] | 587 gcl upload change_name [-r reviewer1@gmail.com,reviewer2@gmail.com,...] |
| 583 [--send_mail] [--no_try] [--no_presubmit] | 588 [--send_mail] [--no_try] [--no_presubmit] |
| 584 Uploads the changelist to the server for review. | 589 Uploads the changelist to the server for review. |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 # the files. This allows commands such as 'gcl diff xxx' to work. | 1097 # the files. This allows commands such as 'gcl diff xxx' to work. |
| 1093 args =["svn", command] | 1098 args =["svn", command] |
| 1094 root = GetRepositoryRoot() | 1099 root = GetRepositoryRoot() |
| 1095 args.extend([os.path.join(root, x) for x in change_info.FileList()]) | 1100 args.extend([os.path.join(root, x) for x in change_info.FileList()]) |
| 1096 RunShell(args, True) | 1101 RunShell(args, True) |
| 1097 return 0 | 1102 return 0 |
| 1098 | 1103 |
| 1099 | 1104 |
| 1100 if __name__ == "__main__": | 1105 if __name__ == "__main__": |
| 1101 sys.exit(main()) | 1106 sys.exit(main()) |
| OLD | NEW |