| 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 27 matching lines...) Expand all Loading... |
| 38 COMMIT_POSITION_FOOTER_KEY = 'Cr-Commit-Position' | 38 COMMIT_POSITION_FOOTER_KEY = 'Cr-Commit-Position' |
| 39 | 39 |
| 40 # Regular expression to parse a commit position | 40 # Regular expression to parse a commit position |
| 41 COMMIT_POSITION_RE = re.compile(r'(.+)@\{#(\d+)\}') | 41 COMMIT_POSITION_RE = re.compile(r'(.+)@\{#(\d+)\}') |
| 42 | 42 |
| 43 # Key for the 'git-svn' ID metadata commit footer entry. | 43 # Key for the 'git-svn' ID metadata commit footer entry. |
| 44 GIT_SVN_ID_FOOTER_KEY = 'git-svn-id' | 44 GIT_SVN_ID_FOOTER_KEY = 'git-svn-id' |
| 45 | 45 |
| 46 # e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117 | 46 # e.g., git-svn-id: https://v8.googlecode.com/svn/trunk@23117 |
| 47 # ce2b1a6d-e550-0410-aec6-3dcde31c8c00 | 47 # ce2b1a6d-e550-0410-aec6-3dcde31c8c00 |
| 48 GIT_SVN_ID_RE = re.compile(r'((?:\w+)://[^@]+)@(\d+)\s+(?:[a-zA-Z0-9\-]+)') | 48 GIT_SVN_ID_RE = re.compile(r'[^@]+@(\d+)\s+(?:[a-zA-Z0-9\-]+)') |
| 49 | 49 |
| 50 | 50 |
| 51 # Copied from bot_update.py. | 51 # Copied from bot_update.py. |
| 52 def GetCommitMessageFooterMap(message): | 52 def GetCommitMessageFooterMap(message): |
| 53 """Returns: (dict) A dictionary of commit message footer entries. | 53 """Returns: (dict) A dictionary of commit message footer entries. |
| 54 """ | 54 """ |
| 55 footers = {} | 55 footers = {} |
| 56 | 56 |
| 57 # Extract the lines in the footer block. | 57 # Extract the lines in the footer block. |
| 58 lines = [] | 58 lines = [] |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if value: | 278 if value: |
| 279 match = COMMIT_POSITION_RE.match(value) | 279 match = COMMIT_POSITION_RE.match(value) |
| 280 if match: | 280 if match: |
| 281 return match.group(2) | 281 return match.group(2) |
| 282 | 282 |
| 283 # Extract the svn revision from 'git-svn' metadata | 283 # Extract the svn revision from 'git-svn' metadata |
| 284 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) | 284 value = footer_map.get(GIT_SVN_ID_FOOTER_KEY) |
| 285 if value: | 285 if value: |
| 286 match = GIT_SVN_ID_RE.match(value) | 286 match = GIT_SVN_ID_RE.match(value) |
| 287 if match: | 287 if match: |
| 288 return match.group(2) | 288 return match.group(1) |
| 289 return None | 289 raise GitFailedException("Couldn't determine commit position for %s" % |
| 290 | 290 git_hash) |
| 291 ### Git svn stuff | |
| 292 | |
| 293 def GitSVNFetch(self, **kwargs): | |
| 294 self.Git("svn fetch", **kwargs) | |
| 295 | |
| 296 def GitSVNRebase(self, **kwargs): | |
| 297 self.Git("svn rebase", **kwargs) | |
| 298 | |
| 299 # TODO(machenbach): Unused? Remove. | |
| 300 @Strip | |
| 301 def GitSVNLog(self, **kwargs): | |
| 302 return self.Git("svn log -1 --oneline", **kwargs) | |
| 303 | |
| 304 @Strip | |
| 305 def GitSVNFindGitHash(self, revision, branch="", **kwargs): | |
| 306 assert revision | |
| 307 args = MakeArgs(["svn find-rev", "r%s" % revision, branch]) | |
| 308 | |
| 309 # Pick the last line if multiple lines are available. The first lines might | |
| 310 # print information about rebuilding the svn-git mapping. | |
| 311 return self.Git(args, **kwargs).splitlines()[-1] | |
| 312 | |
| 313 @Strip | |
| 314 def GitSVNFindSVNRev(self, git_hash, branch="", **kwargs): | |
| 315 return self.Git(MakeArgs(["svn find-rev", git_hash, branch]), **kwargs) | |
| 316 | |
| 317 def GitSVNDCommit(self, **kwargs): | |
| 318 return self.Git("svn dcommit 2>&1", retry_on=lambda x: x is None, **kwargs) | |
| 319 | |
| 320 def GitSVNTag(self, version, **kwargs): | |
| 321 self.Git(("svn tag %s -m \"Tagging version %s\"" % (version, version)), | |
| 322 retry_on=lambda x: x is None, | |
| 323 **kwargs) | |
| OLD | NEW |