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

Side by Side Diff: drover.py

Issue 501081: Add a minimum SVN version check to drover, to enforce the 1.5.x requirement. (Closed) Base URL: svn://chrome-svn/chrome/trunk/tools/depot_tools/
Patch Set: Created 11 years 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 | 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 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import optparse 5 import optparse
6 import os 6 import os
7 import re 7 import re
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 import webbrowser 10 import webbrowser
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 stderr=subprocess.PIPE).stdout.readlines() 120 stderr=subprocess.PIPE).stdout.readlines()
121 log = "" 121 log = ""
122 pos = 0 122 pos = 0
123 for line in svn_log: 123 for line in svn_log:
124 if (pos > 2): 124 if (pos > 2):
125 log += line.replace('-','').replace('\r','') 125 log += line.replace('-','').replace('\r','')
126 else: 126 else:
127 pos = pos + 1 127 pos = pos + 1
128 return log 128 return log
129 129
130 def getSVNVersionInfo():
131 """Extract version information from SVN"""
132 command = 'svn --version'
133 svn_info = subprocess.Popen(command,
134 shell=True,
135 stdout=subprocess.PIPE,
136 stderr=subprocess.PIPE).stdout.readlines()
137 info = {}
138 for line in svn_info:
139 match = re.search(r"svn, version ((\d+)\.(\d+)\.(\d+)) \(r(\d+)\)", line)
140 if match:
141 info['version']=match.group(1)
142 info['major']=int(match.group(2))
143 info['minor']=int(match.group(3))
144 info['patch']=int(match.group(4))
145 info['revision']=match.group(5)
146 return info
147
148 return None
149
150 def isMinimumSVNVersion(major, minor, patch=0):
151 """Test for minimum SVN version"""
152 return _isMinimumSVNVersion(getSVNVersionInfo(), major, minor, patch)
153
154 def _isMinimumSVNVersion(version, major, minor, patch=0):
155 """Test for minimum SVN version, internal method"""
156 if not version:
157 return False
158
159 if (version['major'] > major):
160 return True
161 elif (version['major'] < major):
162 return False
163
164 if (version['minor'] > minor):
165 return True
166 elif (version['minor'] < minor):
167 return False
168
169 if (version['patch'] >= patch):
170 return True
171 else:
172 return False
173
130 def checkoutRevision(url, revision, branch_url, revert=False): 174 def checkoutRevision(url, revision, branch_url, revert=False):
131 files_info = getFileInfo(url, revision) 175 files_info = getFileInfo(url, revision)
132 paths = getBestMergePaths2(files_info, revision) 176 paths = getBestMergePaths2(files_info, revision)
133 export_map = getBestExportPathsMap2(files_info, revision) 177 export_map = getBestExportPathsMap2(files_info, revision)
134 178
135 command = 'svn checkout -N ' + branch_url 179 command = 'svn checkout -N ' + branch_url
136 print command 180 print command
137 os.system(command) 181 os.system(command)
138 182
139 match = re.search(r"svn://.*/(.*)", branch_url) 183 match = re.search(r"svn://.*/(.*)", branch_url)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 BASE_URL = "svn://svn.chromium.org/chrome" 407 BASE_URL = "svn://svn.chromium.org/chrome"
364 TRUNK_URL = BASE_URL + "/trunk/src" 408 TRUNK_URL = BASE_URL + "/trunk/src"
365 BRANCH_URL = BASE_URL + "/branches/$branch/src" 409 BRANCH_URL = BASE_URL + "/branches/$branch/src"
366 SKIP_CHECK_WORKING = True 410 SKIP_CHECK_WORKING = True
367 PROMPT_FOR_AUTHOR = False 411 PROMPT_FOR_AUTHOR = False
368 412
369 DEFAULT_WORKING = "drover_" + str(revision) 413 DEFAULT_WORKING = "drover_" + str(revision)
370 if options.branch: 414 if options.branch:
371 DEFAULT_WORKING += ("_" + options.branch) 415 DEFAULT_WORKING += ("_" + options.branch)
372 416
417 if not isMinimumSVNVersion(1,5):
418 print "You need to use at least SVN version 1.5.x"
419 sys.exit(1)
420
373 # Override the default properties if there is a drover.properties file. 421 # Override the default properties if there is a drover.properties file.
374 global file_pattern_ 422 global file_pattern_
375 if os.path.exists("drover.properties"): 423 if os.path.exists("drover.properties"):
376 file = open("drover.properties") 424 file = open("drover.properties")
377 exec(file) 425 exec(file)
378 file.close() 426 file.close()
379 if FILE_PATTERN: 427 if FILE_PATTERN:
380 file_pattern_ = FILE_PATTERN 428 file_pattern_ = FILE_PATTERN
381 429
382 if options.revert and options.branch: 430 if options.revert and options.branch:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 532
485 if not options.merge and not options.revert: 533 if not options.merge and not options.revert:
486 option_parser.error("You need at least --merge or --revert") 534 option_parser.error("You need at least --merge or --revert")
487 sys.exit(1) 535 sys.exit(1)
488 536
489 if options.merge and not options.branch: 537 if options.merge and not options.branch:
490 option_parser.error("--merge requires a --branch") 538 option_parser.error("--merge requires a --branch")
491 sys.exit(1) 539 sys.exit(1)
492 540
493 sys.exit(main(options, args)) 541 sys.exit(main(options, args))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698