Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 json | |
| 6 import logging | |
| 5 import re | 7 import re |
| 8 import subprocess | |
| 9 import urllib2 | |
|
chanli
2016/11/08 01:56:20
You have these imports but you don't use them?
Sharu Jiang
2016/11/11 00:29:05
Oops, cleaned up.
| |
| 6 | 10 |
| 7 CODE_REVIEW_URL_PATTERN = re.compile( | 11 CODE_REVIEW_URL_PATTERN = re.compile( |
| 8 '^(?:Review URL|Review-Url): (.*\d+).*$', re.IGNORECASE) | 12 '^(?:Review URL|Review-Url): (.*\d+).*$', re.IGNORECASE) |
| 9 COMMIT_POSITION_PATTERN = re.compile( | 13 COMMIT_POSITION_PATTERN = re.compile( |
| 10 '^Cr-Commit-Position: refs/heads/master@{#(\d+)}$', re.IGNORECASE) | 14 '^Cr-Commit-Position: refs/heads/master@{#(\d+)}$', re.IGNORECASE) |
| 11 REVERTED_REVISION_PATTERN = re.compile( | 15 REVERTED_REVISION_PATTERN = re.compile( |
| 12 '^> Committed: https://.+/([0-9a-fA-F]{40})$', re.IGNORECASE) | 16 '^> Committed: https://.+/([0-9a-fA-F]{40})$', re.IGNORECASE) |
| 13 START_OF_CR_COMMIT_POSITION = -5 | 17 START_OF_CR_COMMIT_POSITION = -5 |
| 14 | 18 |
| 15 | 19 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 """Parse message to get the reverted revision if there is one.""" | 66 """Parse message to get the reverted revision if there is one.""" |
| 63 lines = message.strip().splitlines() | 67 lines = message.strip().splitlines() |
| 64 if not lines[0].lower().startswith('revert'): | 68 if not lines[0].lower().startswith('revert'): |
| 65 return None | 69 return None |
| 66 | 70 |
| 67 for line in reversed(lines): # pragma: no cover | 71 for line in reversed(lines): # pragma: no cover |
| 68 # TODO: Handle cases where no reverted_revision in reverting message. | 72 # TODO: Handle cases where no reverted_revision in reverting message. |
| 69 reverted_revision_match = REVERTED_REVISION_PATTERN.match(line) | 73 reverted_revision_match = REVERTED_REVISION_PATTERN.match(line) |
| 70 if reverted_revision_match: | 74 if reverted_revision_match: |
| 71 return reverted_revision_match.group(1) | 75 return reverted_revision_match.group(1) |
| OLD | NEW |