OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return False | 111 return False |
112 repo_root = info["Repository Root"] | 112 repo_root = info["Repository Root"] |
113 info = getSVNInfo(os.path.dirname(os.path.abspath(path)), "HEAD") | 113 info = getSVNInfo(os.path.dirname(os.path.abspath(path)), "HEAD") |
114 if (info.get("Repository Root", None) != repo_root): | 114 if (info.get("Repository Root", None) != repo_root): |
115 return True | 115 return True |
116 return False | 116 return False |
117 | 117 |
118 def getRevisionLog(url, revision): | 118 def getRevisionLog(url, revision): |
119 """Takes an svn url and gets the associated revision.""" | 119 """Takes an svn url and gets the associated revision.""" |
120 svn_log = subprocess2.check_output( | 120 svn_log = subprocess2.check_output( |
121 ['svn', 'log', url, '-r', str(revision)]).splitlines() | 121 ['svn', 'log', url, '-r', str(revision)], |
122 # Don't include the header lines and the trailing "---..." line and eliminate | 122 universal_newlines=True).splitlines(True) |
123 # any '\r's. | 123 # Don't include the header lines and the trailing "---..." line. |
124 return ''.join([l.replace('\r','') for l in svn_log[3:-1]]) | 124 return ''.join(svn_log[3:-1]) |
125 | 125 |
126 def getSVNVersionInfo(): | 126 def getSVNVersionInfo(): |
127 """Extract version information from SVN""" | 127 """Extract version information from SVN""" |
128 svn_info = subprocess2.check_output(['svn', '--version']).splitlines() | 128 svn_info = subprocess2.check_output(['svn', '--version']).splitlines() |
129 info = {} | 129 info = {} |
130 for line in svn_info: | 130 for line in svn_info: |
131 match = re.search(r"svn, version ((\d+)\.(\d+)\.(\d+))", line) | 131 match = re.search(r"svn, version ((\d+)\.(\d+)\.(\d+))", line) |
132 if match: | 132 if match: |
133 info['version'] = match.group(1) | 133 info['version'] = match.group(1) |
134 info['major'] = int(match.group(2)) | 134 info['major'] = int(match.group(2)) |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 546 |
547 if options.local and (options.revert or options.branch): | 547 if options.local and (options.revert or options.branch): |
548 option_parser.error("--local cannot be used with --revert or --branch") | 548 option_parser.error("--local cannot be used with --revert or --branch") |
549 return 1 | 549 return 1 |
550 | 550 |
551 return drover(options, args) | 551 return drover(options, args) |
552 | 552 |
553 | 553 |
554 if __name__ == "__main__": | 554 if __name__ == "__main__": |
555 sys.exit(main()) | 555 sys.exit(main()) |
OLD | NEW |