OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 the V8 project authors. All rights reserved. | 2 # Copyright 2014 the V8 project authors. All rights reserved. |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following | 10 # copyright notice, this list of conditions and the following |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 def GitDiff(self, loc1, loc2, **kwargs): | 238 def GitDiff(self, loc1, loc2, **kwargs): |
239 return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs) | 239 return self.Git(MakeArgs(["diff", loc1, loc2]), **kwargs) |
240 | 240 |
241 def GitPull(self, **kwargs): | 241 def GitPull(self, **kwargs): |
242 self.Git("pull", **kwargs) | 242 self.Git("pull", **kwargs) |
243 | 243 |
244 def GitFetchOrigin(self, **kwargs): | 244 def GitFetchOrigin(self, **kwargs): |
245 self.Git("fetch origin", **kwargs) | 245 self.Git("fetch origin", **kwargs) |
246 | 246 |
247 def GitConvertToSVNRevision(self, git_hash, **kwargs): | |
248 result = self.Git(MakeArgs(["rev-list", "-n", "1", git_hash]), **kwargs) | |
249 if not result or not SHA1_RE.match(result): | |
250 raise GitFailedException("Git hash %s is unknown." % git_hash) | |
251 log = self.GitLog(n=1, format="%B", git_hash=git_hash, **kwargs) | |
252 for line in reversed(log.splitlines()): | |
253 match = ROLL_DEPS_GIT_SVN_ID_RE.match(line.strip()) | |
254 if match: | |
255 return match.group(1) | |
256 raise GitFailedException("Couldn't convert %s to SVN." % git_hash) | |
257 | |
258 @Strip | 247 @Strip |
259 # Copied from bot_update.py and modified for svn-like numbers only. | 248 # Copied from bot_update.py and modified for svn-like numbers only. |
260 def GetCommitPositionNumber(self, git_hash, **kwargs): | 249 def GetCommitPositionNumber(self, git_hash, **kwargs): |
261 """Dumps the 'git' log for a specific revision and parses out the commit | 250 """Dumps the 'git' log for a specific revision and parses out the commit |
262 position number. | 251 position number. |
263 | 252 |
264 If a commit position metadata key is found, its number will be returned. | 253 If a commit position metadata key is found, its number will be returned. |
265 | 254 |
266 Otherwise, we will search for a 'git-svn' metadata entry. If one is found, | 255 Otherwise, we will search for a 'git-svn' metadata entry. If one is found, |
267 its SVN revision value is returned. | 256 its SVN revision value is returned. |
268 """ | 257 """ |
269 git_log = self.GitLog(format='%B', n=1, git_hash=git_hash, **kwargs) | 258 git_log = self.GitLog(format='%B', n=1, git_hash=git_hash, **kwargs) |
270 footer_map = GetCommitMessageFooterMap(git_log) | 259 footer_map = GetCommitMessageFooterMap(git_log) |
271 | 260 |
272 # Search for commit position metadata | 261 # Search for commit position metadata |
273 value = footer_map.get(COMMIT_POSITION_FOOTER_KEY) | 262 value = footer_map.get(COMMIT_POSITION_FOOTER_KEY) |
274 if value: | 263 if value: |
275 match = COMMIT_POSITION_RE.match(value) | 264 match = COMMIT_POSITION_RE.match(value) |
276 if match: | 265 if match: |
277 return match.group(2) | 266 return match.group(2) |
278 | 267 |
279 # Extract the svn revision from 'git-svn' metadata | 268 # Extract the svn revision from 'git-svn' metadata |
280 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) | 269 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) |
281 if value: | 270 if value: |
282 match = GIT_SVN_ID_RE.match(value) | 271 match = GIT_SVN_ID_RE.match(value) |
283 if match: | 272 if match: |
284 return match.group(1) | 273 return match.group(1) |
285 raise GitFailedException("Couldn't determine commit position for %s" % | 274 raise GitFailedException("Couldn't determine commit position for %s" % |
286 git_hash) | 275 git_hash) |
OLD | NEW |