OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. | 5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. |
6 # Derived from https://gist.github.com/aljungberg/626518 | 6 # Derived from https://gist.github.com/aljungberg/626518 |
7 import multiprocessing.pool | 7 import multiprocessing.pool |
8 from multiprocessing.pool import IMapIterator | 8 from multiprocessing.pool import IMapIterator |
9 def wrapper(func): | 9 def wrapper(func): |
10 def wrap(self, timeout=None): | 10 def wrap(self, timeout=None): |
(...skipping 24 matching lines...) Expand all Loading... |
35 TEST_MODE = False | 35 TEST_MODE = False |
36 | 36 |
37 FREEZE = 'FREEZE' | 37 FREEZE = 'FREEZE' |
38 FREEZE_SECTIONS = { | 38 FREEZE_SECTIONS = { |
39 'indexed': 'soft', | 39 'indexed': 'soft', |
40 'unindexed': 'mixed' | 40 'unindexed': 'mixed' |
41 } | 41 } |
42 FREEZE_MATCHER = re.compile(r'%s.(%s)' % (FREEZE, '|'.join(FREEZE_SECTIONS))) | 42 FREEZE_MATCHER = re.compile(r'%s.(%s)' % (FREEZE, '|'.join(FREEZE_SECTIONS))) |
43 | 43 |
44 | 44 |
| 45 # Retry a git operation if git returns a error response with any of these |
| 46 # messages. It's all observed 'bad' GoB responses so far. |
| 47 # |
| 48 # This list is inspired/derived from the one in ChromiumOS's Chromite: |
| 49 # <CHROMITE>/lib/git.py::GIT_TRANSIENT_ERRORS |
| 50 # |
| 51 # It was last imported from '7add3ac29564d98ac35ce426bc295e743e7c0c02'. |
| 52 GIT_TRANSIENT_ERRORS = ( |
| 53 # crbug.com/285832 |
| 54 r'! \[remote rejected\].*\(error in hook\)', |
| 55 |
| 56 # crbug.com/289932 |
| 57 r'! \[remote rejected\].*\(failed to lock\)', |
| 58 |
| 59 # crbug.com/307156 |
| 60 r'! \[remote rejected\].*\(error in Gerrit backend\)', |
| 61 |
| 62 # crbug.com/285832 |
| 63 r'remote error: Internal Server Error', |
| 64 |
| 65 # crbug.com/294449 |
| 66 r'fatal: Couldn\'t find remote ref ', |
| 67 |
| 68 # crbug.com/220543 |
| 69 r'git fetch_pack: expected ACK/NAK, got', |
| 70 |
| 71 # crbug.com/189455 |
| 72 r'protocol error: bad pack header', |
| 73 |
| 74 # crbug.com/202807 |
| 75 r'The remote end hung up unexpectedly', |
| 76 |
| 77 # crbug.com/298189 |
| 78 r'TLS packet with unexpected length was received', |
| 79 |
| 80 # crbug.com/187444 |
| 81 r'RPC failed; result=\d+, HTTP code = \d+', |
| 82 |
| 83 # crbug.com/315421 |
| 84 r'The requested URL returned error: 500 while accessing', |
| 85 |
| 86 # crbug.com/388876 |
| 87 r'Connection timed out', |
| 88 ) |
| 89 |
| 90 GIT_TRANSIENT_ERRORS_RE = re.compile('|'.join(GIT_TRANSIENT_ERRORS), |
| 91 re.IGNORECASE) |
| 92 |
| 93 |
45 class BadCommitRefException(Exception): | 94 class BadCommitRefException(Exception): |
46 def __init__(self, refs): | 95 def __init__(self, refs): |
47 msg = ('one of %s does not seem to be a valid commitref.' % | 96 msg = ('one of %s does not seem to be a valid commitref.' % |
48 str(refs)) | 97 str(refs)) |
49 super(BadCommitRefException, self).__init__(msg) | 98 super(BadCommitRefException, self).__init__(msg) |
50 | 99 |
51 | 100 |
52 def memoize_one(**kwargs): | 101 def memoize_one(**kwargs): |
53 """Memoizes a single-argument pure function. | 102 """Memoizes a single-argument pure function. |
54 | 103 |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 return None | 708 return None |
660 return ret | 709 return ret |
661 | 710 |
662 | 711 |
663 def upstream(branch): | 712 def upstream(branch): |
664 try: | 713 try: |
665 return run('rev-parse', '--abbrev-ref', '--symbolic-full-name', | 714 return run('rev-parse', '--abbrev-ref', '--symbolic-full-name', |
666 branch+'@{upstream}') | 715 branch+'@{upstream}') |
667 except subprocess2.CalledProcessError: | 716 except subprocess2.CalledProcessError: |
668 return None | 717 return None |
OLD | NEW |