Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: infra/services/lkgr_finder/lkgr_lib.py

Issue 491583004: Make CollateRevisionHistory handle git and svn at the same time. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fixed a bug where keyfunc throws exception when NOREV is passed. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 # Copyright (c) 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 """A collection of helpers to make lkgr_finder's life easier.""" 5 """A collection of helpers to make lkgr_finder's life easier."""
6 6
7 7
8 import ast 8 import ast
9 import datetime 9 import datetime
10 import json 10 import json
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 def check_rev(self, r): # pragma: no cover 114 def check_rev(self, r): # pragma: no cover
115 if r is NOREV: 115 if r is NOREV:
116 return False 116 return False
117 return bool(self._GIT_HASH_RE.match(r)) 117 return bool(self._GIT_HASH_RE.match(r))
118 118
119 def _cache(self, *revs): # pragma: no cover 119 def _cache(self, *revs): # pragma: no cover
120 nums = map(int, self._git.number(*revs)) 120 nums = map(int, self._git.number(*revs))
121 self._number_cache.update(dict(zip(revs, nums))) 121 self._number_cache.update(dict(zip(revs, nums)))
122 122
123 def keyfunc(self, r): # pragma: no cover 123 def keyfunc(self, r): # pragma: no cover
124 if r is NOREV:
szager1 2014/08/20 19:09:55 agable and I can't understand why this is necessar
zty 2014/08/20 19:55:46 Acknowledged.
125 return -1
124 if not self.check_rev(r): 126 if not self.check_rev(r):
125 raise ValueError('%s is not a Git revision.' % r) 127 raise ValueError('%s is not a Git revision.' % r)
126 k = self._number_cache.get(r) 128 k = self._number_cache.get(r)
127 if k is None: 129 if k is None:
128 self._cache(r) 130 self._cache(r)
129 k = self._number_cache.get(r) 131 k = self._number_cache.get(r)
130 if k is None: 132 if k is None:
131 raise LookupError('%s could not be found in the Git repo.' % r) 133 raise LookupError('%s could not be found in the Git repo.' % r)
132 return k 134 return k
133 135
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 continue 319 continue
318 LOGGER.debug('Collating builder %s', builder) 320 LOGGER.debug('Collating builder %s', builder)
319 builder_history = [] 321 builder_history = []
320 for build_num in sorted(builder_data.keys(), key=int): 322 for build_num in sorted(builder_data.keys(), key=int):
321 this_build_data = builder_data[build_num] 323 this_build_data = builder_data[build_num]
322 txt = this_build_data.get('text', []) 324 txt = this_build_data.get('text', [])
323 if 'exception' in txt and 'slave' in txt and 'lost' in txt: 325 if 'exception' in txt and 'slave' in txt and 'lost' in txt:
324 continue 326 continue
325 revision = None 327 revision = None
326 for prop in this_build_data.get('properties', []): 328 for prop in this_build_data.get('properties', []):
327 if prop[0] == 'got_revision': 329 if type(repo) is SvnWrapper and prop[0] == 'got_revision':
330 revision = prop[1]
331 break
332 if type(repo) is GitWrapper and prop[0] == 'got_revision_git':
333 revision = prop[1]
334 break
335 # If repo is a project that depends on 'src'
336 if prop[0] == 'got_src_revision':
328 revision = prop[1] 337 revision = prop[1]
329 break 338 break
330 if not revision: 339 if not revision:
331 revision = this_build_data.get( 340 revision = this_build_data.get(
332 'sourceStamp', {}).get('revision', None) 341 'sourceStamp', {}).get('revision', None)
333 if not revision: 342 if not revision:
334 continue 343 continue
335 revisions.add(str(revision)) 344 revisions.add(str(revision))
336 status = EvaluateBuildData(this_build_data) 345 status = EvaluateBuildData(this_build_data)
337 builder_history.append((revision, status, build_num)) 346 builder_history.append((revision, status, build_num))
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 605
597 try: 606 try:
598 config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 607 config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
599 'config', '%s_cfg.pyl' % project) 608 'config', '%s_cfg.pyl' % project)
600 config.update(ast.literal_eval(open(config_file).read())) 609 config.update(ast.literal_eval(open(config_file).read()))
601 except (IOError, ValueError): 610 except (IOError, ValueError):
602 LOGGER.fatal('Could not read project configuration file. Does it exist?') 611 LOGGER.fatal('Could not read project configuration file. Does it exist?')
603 raise 612 raise
604 613
605 return config 614 return config
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698