[email protected] | ba55177 | 2010-02-03 18:21:42 | [diff] [blame] | 1 | #!/usr/bin/python |
[email protected] | 0c6b52b | 2010-06-02 21:56:22 | [diff] [blame] | 2 | # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 6 | import optparse |
| 7 | import os |
| 8 | import re |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 9 | import subprocess |
| 10 | import sys |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 11 | import webbrowser |
| 12 | |
[email protected] | ada4c65 | 2009-12-03 15:32:01 | [diff] [blame] | 13 | import breakpad |
| 14 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 15 | USAGE = """ |
| 16 | WARNING: Please use this tool in an empty directory |
| 17 | (or at least one that you don't mind clobbering.) |
| 18 | |
| 19 | REQUIRES: SVN 1.5+ |
| 20 | NOTE: NO NEED TO CHECKOUT ANYTHING IN ADVANCE OF USING THIS TOOL." |
| 21 | Valid parameters: |
| 22 | |
| 23 | [Merge from trunk to branch] |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 24 | --merge <revision> --branch <branch_num> |
| 25 | Example: %(app)s --merge 12345 --branch 187 |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 26 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 27 | [Merge from trunk to local copy] |
| 28 | --merge <revision> --local |
| 29 | Example: %(app)s --merge 12345 --local |
| 30 | |
[email protected] | 2d6af5f | 2010-01-22 18:18:51 | [diff] [blame] | 31 | [Merge from branch to branch] |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 32 | --merge <revision> --sbranch <branch_num> --branch <branch_num> |
[email protected] | 2d6af5f | 2010-01-22 18:18:51 | [diff] [blame] | 33 | Example: %(app)s --merge 12345 --sbranch 248 --branch 249 |
| 34 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 35 | [Revert from trunk] |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 36 | --revert <revision> |
| 37 | Example: %(app)s --revert 12345 |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 38 | |
| 39 | [Revert from branch] |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 40 | --revert <revision> --branch <branch_num> |
| 41 | Example: %(app)s --revert 12345 --branch 187 |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 42 | """ |
| 43 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 44 | export_map_ = None |
| 45 | files_info_ = None |
| 46 | delete_map_ = None |
[email protected] | 3529954 | 2010-01-27 01:22:16 | [diff] [blame] | 47 | file_pattern_ = r"[ ]+([MADUC])[ ]+/((?:trunk|branches/.*?)/src(.*)/(.*))" |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 48 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 49 | def deltree(root): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 50 | """Removes a given directory""" |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 51 | if (not os.path.exists(root)): |
| 52 | return |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 53 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 54 | if sys.platform == 'win32': |
| 55 | os.system('rmdir /S /Q ' + root.replace('/','\\')) |
| 56 | else: |
| 57 | for name in os.listdir(root): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 58 | path = os.path.join(root, name) |
| 59 | if os.path.isdir(path): |
| 60 | deltree(path) |
| 61 | else: |
| 62 | os.unlink(path) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 63 | os.rmdir(root) |
| 64 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 65 | def clobberDir(dirname): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 66 | """Removes a given directory""" |
| 67 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 68 | if (os.path.exists(dirname)): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 69 | print dir + " directory found, deleting" |
| 70 | # The following line was removed due to access controls in Windows |
| 71 | # which make os.unlink(path) calls impossible. |
| 72 | #TODO(laforge) : Is this correct? |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 73 | deltree(dirname) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 74 | |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 75 | def runGcl(subcommand): |
| 76 | gcl_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "gcl") |
| 77 | if not os.path.exists(gcl_path): |
| 78 | print "WARNING: gcl not found beside drover.py. Using system gcl instead..." |
| 79 | gcl_path = 'gcl' |
| 80 | |
| 81 | command = "%s %s" % (gcl_path, subcommand) |
| 82 | return os.system(command) |
| 83 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 84 | def gclUpload(revision, author): |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 85 | command = ("upload " + str(revision) + |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 86 | " --send_mail --no_try --no_presubmit --reviewers=" + author) |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 87 | return runGcl(command) |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 88 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 89 | def getSVNInfo(url, revision): |
| 90 | command = 'svn info ' + url + "@"+str(revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 91 | svn_info = subprocess.Popen(command, |
| 92 | shell=True, |
| 93 | stdout=subprocess.PIPE, |
| 94 | stderr=subprocess.PIPE).stdout.readlines() |
| 95 | info = {} |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 96 | for line in svn_info: |
| 97 | match = re.search(r"(.*?):(.*)", line) |
| 98 | if match: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 99 | info[match.group(1).strip()]=match.group(2).strip() |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 100 | |
| 101 | return info |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 102 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 103 | def isSVNDirty(): |
| 104 | command = 'svn status' |
| 105 | svn_status = subprocess.Popen(command, |
| 106 | shell=True, |
| 107 | stdout=subprocess.PIPE, |
| 108 | stderr=subprocess.PIPE).stdout.readlines() |
| 109 | for line in svn_status: |
| 110 | match = re.search(r"^[^X?]", line) |
| 111 | if match: |
| 112 | return True |
| 113 | |
| 114 | return False |
| 115 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 116 | def getAuthor(url, revision): |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 117 | info = getSVNInfo(url, revision) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 118 | if (info.has_key("Last Changed Author")): |
| 119 | return info["Last Changed Author"] |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 120 | return None |
| 121 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 122 | def isSVNFile(url, revision): |
| 123 | info = getSVNInfo(url, revision) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 124 | if (info.has_key("Node Kind")): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 125 | if (info["Node Kind"] == "file"): |
| 126 | return True |
| 127 | return False |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 128 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 129 | def isSVNDirectory(url, revision): |
| 130 | info = getSVNInfo(url, revision) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 131 | if (info.has_key("Node Kind")): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 132 | if (info["Node Kind"] == "directory"): |
| 133 | return True |
| 134 | return False |
| 135 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 136 | def inCheckoutRoot(path): |
| 137 | info = getSVNInfo(path, "HEAD") |
| 138 | if (not info.has_key("Repository Root")): |
| 139 | return False |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 140 | repo_root = info["Repository Root"] |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 141 | info = getSVNInfo(os.path.dirname(os.path.abspath(path)), "HEAD") |
| 142 | if (info.get("Repository Root", None) != repo_root): |
| 143 | return True |
| 144 | return False |
| 145 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 146 | def getRevisionLog(url, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 147 | """Takes an svn url and gets the associated revision.""" |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 148 | command = 'svn log ' + url + " -r"+str(revision) |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 149 | svn_log = subprocess.Popen(command, |
| 150 | shell=True, |
| 151 | stdout=subprocess.PIPE, |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 152 | stderr=subprocess.PIPE).stdout.readlines() |
[email protected] | 0c6b52b | 2010-06-02 21:56:22 | [diff] [blame] | 153 | # Don't include the header lines and the trailing "---..." line and eliminate |
| 154 | # any '\r's. |
| 155 | return ''.join([l.replace('\r','') for l in svn_log[3:-1]]) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 156 | |
[email protected] | 004d2ef | 2009-12-17 23:49:04 | [diff] [blame] | 157 | def getSVNVersionInfo(): |
| 158 | """Extract version information from SVN""" |
| 159 | command = 'svn --version' |
| 160 | svn_info = subprocess.Popen(command, |
| 161 | shell=True, |
| 162 | stdout=subprocess.PIPE, |
| 163 | stderr=subprocess.PIPE).stdout.readlines() |
| 164 | info = {} |
| 165 | for line in svn_info: |
| 166 | match = re.search(r"svn, version ((\d+)\.(\d+)\.(\d+)) \(r(\d+)\)", line) |
| 167 | if match: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 168 | info['version'] = match.group(1) |
| 169 | info['major'] = int(match.group(2)) |
| 170 | info['minor'] = int(match.group(3)) |
| 171 | info['patch'] = int(match.group(4)) |
| 172 | info['revision'] = match.group(5) |
| 173 | return info |
[email protected] | 004d2ef | 2009-12-17 23:49:04 | [diff] [blame] | 174 | |
| 175 | return None |
| 176 | |
| 177 | def isMinimumSVNVersion(major, minor, patch=0): |
| 178 | """Test for minimum SVN version""" |
| 179 | return _isMinimumSVNVersion(getSVNVersionInfo(), major, minor, patch) |
| 180 | |
| 181 | def _isMinimumSVNVersion(version, major, minor, patch=0): |
| 182 | """Test for minimum SVN version, internal method""" |
| 183 | if not version: |
| 184 | return False |
| 185 | |
| 186 | if (version['major'] > major): |
| 187 | return True |
| 188 | elif (version['major'] < major): |
| 189 | return False |
| 190 | |
| 191 | if (version['minor'] > minor): |
| 192 | return True |
| 193 | elif (version['minor'] < minor): |
| 194 | return False |
| 195 | |
| 196 | if (version['patch'] >= patch): |
| 197 | return True |
| 198 | else: |
| 199 | return False |
| 200 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 201 | def checkoutRevision(url, revision, branch_url, revert=False): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 202 | files_info = getFileInfo(url, revision) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 203 | paths = getBestMergePaths2(files_info, revision) |
| 204 | export_map = getBestExportPathsMap2(files_info, revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 205 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 206 | command = 'svn checkout -N ' + branch_url |
| 207 | print command |
| 208 | os.system(command) |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 209 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 210 | match = re.search(r"svn://.*/(.*)", branch_url) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 211 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 212 | if match: |
| 213 | os.chdir(match.group(1)) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 214 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 215 | # This line is extremely important due to the way svn behaves in the |
| 216 | # set-depths action. If parents aren't handled before children, the child |
| 217 | # directories get clobbered and the merge step fails. |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 218 | paths.sort() |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 219 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 220 | # Checkout the directories that already exist |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 221 | for path in paths: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 222 | if (export_map.has_key(path) and not revert): |
| 223 | print "Exclude new directory " + path |
| 224 | continue |
| 225 | subpaths = path.split('/') |
| 226 | subpaths.pop(0) |
| 227 | base = '' |
| 228 | for subpath in subpaths: |
| 229 | base += '/' + subpath |
| 230 | # This logic ensures that you don't empty out any directories |
| 231 | if not os.path.exists("." + base): |
| 232 | command = ('svn update --depth empty ' + "." + base) |
| 233 | print command |
| 234 | os.system(command) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 235 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 236 | if (revert): |
| 237 | files = getAllFilesInRevision(files_info) |
| 238 | else: |
| 239 | files = getExistingFilesInRevision(files_info) |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 240 | |
| 241 | for f in files: |
| 242 | # Prevent the tool from clobbering the src directory |
| 243 | if (f == ""): |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 244 | continue |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 245 | command = ('svn up ".' + f + '"') |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 246 | print command |
| 247 | os.system(command) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 248 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 249 | def mergeRevision(url, revision): |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 250 | paths = getBestMergePaths(url, revision) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 251 | export_map = getBestExportPathsMap(url, revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 252 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 253 | for path in paths: |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 254 | if export_map.has_key(path): |
| 255 | continue |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 256 | command = ('svn merge -N -r ' + str(revision-1) + ":" + str(revision) + " ") |
[email protected] | 94ed502 | 2009-10-21 20:28:53 | [diff] [blame] | 257 | command += " --ignore-ancestry " |
[email protected] | f5a1163 | 2009-12-18 00:07:37 | [diff] [blame] | 258 | command += " -x --ignore-eol-style " |
[email protected] | 94ed502 | 2009-10-21 20:28:53 | [diff] [blame] | 259 | command += url + path + "@" + str(revision) + " ." + path |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 260 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 261 | print command |
| 262 | os.system(command) |
| 263 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 264 | def exportRevision(url, revision): |
| 265 | paths = getBestExportPathsMap(url, revision).keys() |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 266 | paths.sort() |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 267 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 268 | for path in paths: |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 269 | command = ('svn export -N ' + url + path + "@" + str(revision) + " ." + |
| 270 | path) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 271 | print command |
| 272 | os.system(command) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 273 | |
| 274 | command = 'svn add .' + path |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 275 | print command |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 276 | os.system(command) |
| 277 | |
| 278 | def deleteRevision(url, revision): |
| 279 | paths = getBestDeletePathsMap(url, revision).keys() |
| 280 | paths.sort() |
| 281 | paths.reverse() |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 282 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 283 | for path in paths: |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 284 | command = "svn delete ." + path |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 285 | print command |
| 286 | os.system(command) |
| 287 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 288 | def revertExportRevision(url, revision): |
| 289 | paths = getBestExportPathsMap(url, revision).keys() |
| 290 | paths.sort() |
| 291 | paths.reverse() |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 292 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 293 | for path in paths: |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 294 | command = "svn delete ." + path |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 295 | print command |
| 296 | os.system(command) |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 297 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 298 | def revertRevision(url, revision): |
| 299 | paths = getBestMergePaths(url, revision) |
| 300 | for path in paths: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 301 | command = ('svn merge -N -r ' + str(revision) + ":" + str(revision-1) + |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 302 | " " + url + path + " ." + path) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 303 | print command |
| 304 | os.system(command) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 305 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 306 | def getFileInfo(url, revision): |
| 307 | global files_info_, file_pattern_ |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 308 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 309 | if (files_info_ != None): |
| 310 | return files_info_ |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 311 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 312 | command = 'svn log ' + url + " -r " + str(revision) + " -v" |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 313 | svn_log = subprocess.Popen(command, |
| 314 | shell=True, |
| 315 | stdout=subprocess.PIPE, |
| 316 | stderr=subprocess.PIPE).stdout.readlines() |
| 317 | |
| 318 | info = [] |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 319 | for line in svn_log: |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 320 | # A workaround to dump the (from .*) stuff, regex not so friendly in the 2nd |
| 321 | # pass... |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 322 | match = re.search(r"(.*) \(from.*\)", line) |
| 323 | if match: |
| 324 | line = match.group(1) |
| 325 | match = re.search(file_pattern_, line) |
| 326 | if match: |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 327 | info.append([match.group(1).strip(), match.group(2).strip(), |
| 328 | match.group(3).strip(),match.group(4).strip()]) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 329 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 330 | files_info_ = info |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 331 | return info |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 332 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 333 | def getBestMergePaths(url, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 334 | """Takes an svn url and gets the associated revision.""" |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 335 | return getBestMergePaths2(getFileInfo(url, revision), revision) |
| 336 | |
| 337 | def getBestMergePaths2(files_info, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 338 | """Takes an svn url and gets the associated revision.""" |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 339 | return list(set([f[2] for f in files_info])) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 340 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 341 | def getBestExportPathsMap(url, revision): |
| 342 | return getBestExportPathsMap2(getFileInfo(url, revision), revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 343 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 344 | def getBestExportPathsMap2(files_info, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 345 | """Takes an svn url and gets the associated revision.""" |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 346 | global export_map_ |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 347 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 348 | if export_map_: |
| 349 | return export_map_ |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 350 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 351 | result = {} |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 352 | for file_info in files_info: |
| 353 | if (file_info[0] == "A"): |
[email protected] | b2ab069 | 2009-11-03 23:35:27 | [diff] [blame] | 354 | if(isSVNDirectory("svn://svn.chromium.org/chrome/" + file_info[1], |
| 355 | revision)): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 356 | result[file_info[2] + "/" + file_info[3]] = "" |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 357 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 358 | export_map_ = result |
| 359 | return result |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 360 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 361 | def getBestDeletePathsMap(url, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 362 | return getBestDeletePathsMap2(getFileInfo(url, revision), revision) |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 363 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 364 | def getBestDeletePathsMap2(files_info, revision): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 365 | """Takes an svn url and gets the associated revision.""" |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 366 | global delete_map_ |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 367 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 368 | if delete_map_: |
| 369 | return delete_map_ |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 370 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 371 | result = {} |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 372 | for file_info in files_info: |
| 373 | if (file_info[0] == "D"): |
[email protected] | b2ab069 | 2009-11-03 23:35:27 | [diff] [blame] | 374 | if(isSVNDirectory("svn://svn.chromium.org/chrome/" + file_info[1], |
| 375 | revision)): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 376 | result[file_info[2] + "/" + file_info[3]] = "" |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 377 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 378 | delete_map_ = result |
| 379 | return result |
| 380 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 381 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 382 | def getExistingFilesInRevision(files_info): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 383 | """Checks for existing files in the revision. |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 384 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 385 | Anything that's A will require special treatment (either a merge or an |
| 386 | export + add) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 387 | """ |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 388 | return ['%s/%s' % (f[2], f[3]) for f in files_info if f[0] != 'A'] |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 389 | |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 390 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 391 | def getAllFilesInRevision(files_info): |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 392 | """Checks for existing files in the revision. |
| 393 | |
| 394 | Anything that's A will require special treatment (either a merge or an |
| 395 | export + add) |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 396 | """ |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 397 | return ['%s/%s' % (f[2], f[3]) for f in files_info] |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 398 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 399 | def prompt(question): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 400 | while True: |
[email protected] | c4e7bb3 | 2009-11-20 23:58:27 | [diff] [blame] | 401 | print question + " [y|n]:", |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 402 | answer = sys.stdin.readline() |
| 403 | if answer.lower().startswith('n'): |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 404 | return False |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 405 | elif answer.lower().startswith('y'): |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 406 | return True |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 407 | |
[email protected] | 817ba61 | 2009-09-23 21:00:53 | [diff] [blame] | 408 | |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 409 | def text_prompt(question, default): |
| 410 | print question + " [" + default + "]:" |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 411 | answer = sys.stdin.readline() |
| 412 | if answer.strip() == "": |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 413 | return default |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 414 | return answer |
| 415 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 416 | |
| 417 | def drover(options, args): |
[email protected] | 5ebf163 | 2009-10-23 22:33:47 | [diff] [blame] | 418 | revision = options.revert or options.merge |
| 419 | |
| 420 | # Initialize some variables used below. They can be overwritten by |
| 421 | # the drover.properties file. |
[email protected] | b2ab069 | 2009-11-03 23:35:27 | [diff] [blame] | 422 | BASE_URL = "svn://svn.chromium.org/chrome" |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 423 | TRUNK_URL = BASE_URL + "/trunk/src" |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 424 | BRANCH_URL = BASE_URL + "/branches/$branch/src" |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 425 | SKIP_CHECK_WORKING = True |
| 426 | PROMPT_FOR_AUTHOR = False |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 427 | |
[email protected] | 5ebf163 | 2009-10-23 22:33:47 | [diff] [blame] | 428 | DEFAULT_WORKING = "drover_" + str(revision) |
| 429 | if options.branch: |
| 430 | DEFAULT_WORKING += ("_" + options.branch) |
| 431 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 432 | if not isMinimumSVNVersion(1, 5): |
[email protected] | 004d2ef | 2009-12-17 23:49:04 | [diff] [blame] | 433 | print "You need to use at least SVN version 1.5.x" |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 434 | return 1 |
[email protected] | 004d2ef | 2009-12-17 23:49:04 | [diff] [blame] | 435 | |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 436 | # Override the default properties if there is a drover.properties file. |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 437 | global file_pattern_ |
| 438 | if os.path.exists("drover.properties"): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 439 | f = open("drover.properties") |
| 440 | exec(f) |
| 441 | f.close() |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 442 | if FILE_PATTERN: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 443 | file_pattern_ = FILE_PATTERN |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 444 | |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 445 | if options.revert and options.branch: |
[email protected] | 2d6af5f | 2010-01-22 18:18:51 | [diff] [blame] | 446 | url = BRANCH_URL.replace("$branch", options.branch) |
| 447 | elif options.merge and options.sbranch: |
| 448 | url = BRANCH_URL.replace("$branch", options.sbranch) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 449 | else: |
| 450 | url = TRUNK_URL |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 451 | |
[email protected] | 864fbdd | 2009-10-23 20:11:40 | [diff] [blame] | 452 | working = options.workdir or DEFAULT_WORKING |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 453 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 454 | if options.local: |
| 455 | working = os.getcwd() |
| 456 | if not inCheckoutRoot(working): |
| 457 | print "'%s' appears not to be the root of a working copy" % working |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 458 | return 1 |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 459 | if isSVNDirty(): |
| 460 | print "Working copy contains uncommitted files" |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 461 | return 1 |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 462 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 463 | command = 'svn log ' + url + " -r "+str(revision) + " -v" |
| 464 | os.system(command) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 465 | |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 466 | if not (options.revertbot or prompt("Is this the correct revision?")): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 467 | return 0 |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 468 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 469 | if (os.path.exists(working)) and not options.local: |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 470 | if not (options.revertbot or SKIP_CHECK_WORKING or |
| 471 | prompt("Working directory: '%s' already exists, clobber?" % working)): |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 472 | return 0 |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 473 | deltree(working) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 474 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 475 | if not options.local: |
| 476 | os.makedirs(working) |
| 477 | os.chdir(working) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 478 | |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 479 | if options.merge: |
| 480 | action = "Merge" |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 481 | if not options.local: |
| 482 | branch_url = BRANCH_URL.replace("$branch", options.branch) |
| 483 | # Checkout everything but stuff that got added into a new dir |
| 484 | checkoutRevision(url, revision, branch_url) |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 485 | # Merge everything that changed |
| 486 | mergeRevision(url, revision) |
| 487 | # "Export" files that were added from the source and add them to branch |
| 488 | exportRevision(url, revision) |
| 489 | # Delete directories that were deleted (file deletes are handled in the |
| 490 | # merge). |
| 491 | deleteRevision(url, revision) |
| 492 | elif options.revert: |
| 493 | action = "Revert" |
| 494 | if options.branch: |
| 495 | url = BRANCH_URL.replace("$branch", options.branch) |
| 496 | checkoutRevision(url, revision, url, True) |
| 497 | revertRevision(url, revision) |
| 498 | revertExportRevision(url, revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 499 | |
| 500 | # Check the base url so we actually find the author who made the change |
[email protected] | 638044d | 2010-01-25 18:52:41 | [diff] [blame] | 501 | if options.auditor: |
| 502 | author = options.auditor |
| 503 | else: |
| 504 | author = getAuthor(url, revision) |
| 505 | if not author: |
| 506 | author = getAuthor(TRUNK_URL, revision) |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 507 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 508 | filename = str(revision)+".txt" |
| 509 | out = open(filename,"w") |
| 510 | out.write(action +" " + str(revision) + " - ") |
| 511 | out.write(getRevisionLog(url, revision)) |
| 512 | if (author): |
[email protected] | 0c6b52b | 2010-06-02 21:56:22 | [diff] [blame] | 513 | out.write("\nTBR=" + author) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 514 | out.close() |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 515 | |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 516 | change_cmd = 'change ' + str(revision) + " " + filename |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 517 | if options.revertbot: |
| 518 | change_cmd += ' --silent' |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 519 | runGcl(change_cmd) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 520 | os.unlink(filename) |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 521 | |
| 522 | if options.local: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 523 | return 0 |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 524 | |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 525 | print author |
| 526 | print revision |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 527 | print ("gcl upload " + str(revision) + |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 528 | " --send_mail --no_try --no_presubmit --reviewers=" + author) |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 529 | |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 530 | if options.revertbot or prompt("Would you like to upload?"): |
[email protected] | b97010c | 2009-10-15 23:50:56 | [diff] [blame] | 531 | if PROMPT_FOR_AUTHOR: |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 532 | author = text_prompt("Enter new author or press enter to accept default", |
| 533 | author) |
| 534 | if options.revertbot and options.revertbot_reviewers: |
| 535 | author += "," |
| 536 | author += options.revertbot_reviewers |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 537 | gclUpload(revision, author) |
| 538 | else: |
| 539 | print "Deleting the changelist." |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 540 | print "gcl delete " + str(revision) |
[email protected] | 363b4d4 | 2009-11-03 21:13:36 | [diff] [blame] | 541 | runGcl("delete " + str(revision)) |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 542 | return 0 |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 543 | |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 544 | # We commit if the reverbot is set to commit automatically, or if this is |
| 545 | # not the revertbot and the user agrees. |
| 546 | if options.revertbot_commit or (not options.revertbot and |
| 547 | prompt("Would you like to commit?")): |
| 548 | print "gcl commit " + str(revision) + " --no_presubmit --force" |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 549 | return runGcl("commit " + str(revision) + " --no_presubmit --force") |
[email protected] | d90ad9b | 2009-08-06 00:20:17 | [diff] [blame] | 550 | else: |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 551 | return 0 |
[email protected] | a489904 | 2009-10-16 19:42:41 | [diff] [blame] | 552 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 553 | |
| 554 | def main(): |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 555 | option_parser = optparse.OptionParser(usage=USAGE % {"app": sys.argv[0]}) |
| 556 | option_parser.add_option('-m', '--merge', type="int", |
| 557 | help='Revision to merge from trunk to branch') |
| 558 | option_parser.add_option('-b', '--branch', |
| 559 | help='Branch to revert or merge from') |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 560 | option_parser.add_option('-l', '--local', action='store_true', |
| 561 | help='Local working copy to merge to') |
[email protected] | 2d6af5f | 2010-01-22 18:18:51 | [diff] [blame] | 562 | option_parser.add_option('-s', '--sbranch', |
| 563 | help='Source branch for merge') |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 564 | option_parser.add_option('-r', '--revert', type="int", |
| 565 | help='Revision to revert') |
[email protected] | 864fbdd | 2009-10-23 20:11:40 | [diff] [blame] | 566 | option_parser.add_option('-w', '--workdir', |
| 567 | help='subdir to use for the revert') |
[email protected] | 638044d | 2010-01-25 18:52:41 | [diff] [blame] | 568 | option_parser.add_option('-a', '--auditor', |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 569 | help='overrides the author for reviewer') |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 570 | option_parser.add_option('', '--revertbot', action='store_true', |
| 571 | default=False) |
| 572 | option_parser.add_option('', '--revertbot-commit', action='store_true', |
| 573 | default=False) |
| 574 | option_parser.add_option('', '--revertbot-reviewers') |
| 575 | options, args = option_parser.parse_args() |
| 576 | |
| 577 | if not options.merge and not options.revert: |
| 578 | option_parser.error("You need at least --merge or --revert") |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 579 | return 1 |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 580 | |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 581 | if options.merge and not options.branch and not options.local: |
| 582 | option_parser.error("--merge requires either --branch or --local") |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 583 | return 1 |
[email protected] | 0b9e693 | 2010-02-22 16:49:06 | [diff] [blame] | 584 | |
| 585 | if options.local and (options.revert or options.branch): |
| 586 | option_parser.error("--local cannot be used with --revert or --branch") |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 587 | return 1 |
[email protected] | 9ce9822 | 2009-10-19 20:24:17 | [diff] [blame] | 588 | |
[email protected] | 6e29d57 | 2010-06-04 17:32:20 | [diff] [blame] | 589 | return drover(options, args) |
| 590 | |
| 591 | |
| 592 | if __name__ == "__main__": |
| 593 | sys.exit(main()) |