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

Unified Diff: recipe_engine/autoroll_impl/commit_list.py

Issue 2829203002: [autoroller] All commits in updates(), only roll interesting ones. (Closed)
Patch Set: windows fix Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_engine/autoroll_impl/candidate_algorithm.py ('k') | recipe_engine/fetch.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/autoroll_impl/commit_list.py
diff --git a/recipe_engine/autoroll_impl/commit_list.py b/recipe_engine/autoroll_impl/commit_list.py
index 189159ddd6cb8a5ce6d710429af04131e58fc1f0..f5eff8fa3a9f913a5463fd6299540ca8dbe0d370 100644
--- a/recipe_engine/autoroll_impl/commit_list.py
+++ b/recipe_engine/autoroll_impl/commit_list.py
@@ -24,6 +24,7 @@ class CommitList(object):
assert all(isinstance(c, CommitMetadata) for c in commit_list)
self._commits = list(commit_list)
self._cur_idx = 0
+ self._next_roll_candidate_idx = None
# This maps from commit hash -> index in _commits.
self._rev_idx = {}
@@ -69,6 +70,28 @@ class CommitList(object):
return None
return self._commits[nxt_idx]
+ @property
+ def next_roll_candidate(self):
+ """Gets the next CommitMetadata and distance with roll_candidate==True
+ without advancing the current index.
+
+ Returns (CommitMetadata, <distance>), or (None, None) if there is no next
+ roll_candidate.
+ """
+ # Compute and cache the next roll candidate index.
+ nxt_idx = self._next_roll_candidate_idx
+ if nxt_idx is None or nxt_idx <= self._cur_idx:
+ nxt_idx = None
+ for i, commit in enumerate(self._commits[self._cur_idx+1:]):
+ if commit.roll_candidate:
+ nxt_idx = self._cur_idx + i + 1
+ break
+ self._next_roll_candidate_idx = nxt_idx
+
+ if nxt_idx is not None:
+ return self._commits[nxt_idx], nxt_idx - self._cur_idx
+ return (None, None)
+
def advance(self):
"""Advances the current CommitMetadata by one.
« no previous file with comments | « recipe_engine/autoroll_impl/candidate_algorithm.py ('k') | recipe_engine/fetch.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698