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

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/resources/fetch_intervening_revisions.py

Issue 2282563004: Do not exclude the last revision in the range returned by gitiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 3 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
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Gets list of revisions between two commits and their commit positions. 7 """Gets list of revisions between two commits and their commit positions.
8 8
9 Example usage: 9 Example usage:
10 ./fetch_intervening_revisions.py 343b531d31 7b43807df3 \ 10 ./fetch_intervening_revisions.py 343b531d31 7b43807df3 \
(...skipping 23 matching lines...) Expand all
34 34
35 def fetch_intervening_revisions(start, end, base_url): 35 def fetch_intervening_revisions(start, end, base_url):
36 """Fetches a list of revision in between two commits. 36 """Fetches a list of revision in between two commits.
37 37
38 Args: 38 Args:
39 start (str): A git commit hash in the Chromium src repository. 39 start (str): A git commit hash in the Chromium src repository.
40 end (str): Another git commit hash, after start. 40 end (str): Another git commit hash, after start.
41 base_url (str): A repository gitiles URL. 41 base_url (str): A repository gitiles URL.
42 42
43 Returns: 43 Returns:
44 A list of pairs (commit hash, commit position), from earliest to latest, 44 A list of pairs (commit hash, commit position), from earliest to latest,
dtu 2016/08/26 01:16:56 This comment needs to be updated.
RobertoCN 2016/08/26 18:17:36 Done.
45 for all commits in between the two given commits, not including either 45 for all commits in between the two given commits, not including either
46 of the given commits. 46 of the given commits.
47 47
48 Raises: 48 Raises:
49 urllib2.URLError: The request to gitiles failed. 49 urllib2.URLError: The request to gitiles failed.
50 ValueError: The response wasn't valid JSON. 50 ValueError: The response wasn't valid JSON.
51 KeyError: The JSON didn't contain the expected data. 51 KeyError: The JSON didn't contain the expected data.
52 """ 52 """
53 revisions = _fetch_range_from_gitiles(start, end, base_url) 53 revisions = _fetch_range_from_gitiles(start, end, base_url)
54 # The response from gitiles includes the end revision and is ordered 54 # The response from gitiles includes the end revision and is ordered
55 # from latest to earliest. 55 # from latest to earliest.
56 return [_commit_pair(r) for r in reversed(revisions[1:])] 56 return [_commit_pair(r) for r in reversed(revisions)]
57 57
58 58
59 def _fetch_range_from_gitiles(start, end, base_url): 59 def _fetch_range_from_gitiles(start, end, base_url):
60 """Fetches a list of revision dicts from gitiles. 60 """Fetches a list of revision dicts from gitiles.
61 61
62 Make multiple requests to get multiple pages, if necessary. 62 Make multiple requests to get multiple pages, if necessary.
63 """ 63 """
64 revisions = [] 64 revisions = []
65 url = '%s/+log/%s..%s?format=json&n=%d' % (base_url, start, end, _PAGE_SIZE) 65 url = '%s/+log/%s..%s?format=json&n=%d' % (base_url, start, end, _PAGE_SIZE)
66 current_page_url = url 66 current_page_url = url
(...skipping 26 matching lines...) Expand all
93 parser.add_argument('end') 93 parser.add_argument('end')
94 parser.add_argument('url') 94 parser.add_argument('url')
95 args = parser.parse_args() 95 args = parser.parse_args()
96 revision_pairs = fetch_intervening_revisions( 96 revision_pairs = fetch_intervening_revisions(
97 args.start, args.end, args.url) 97 args.start, args.end, args.url)
98 print json.dumps(revision_pairs) 98 print json.dumps(revision_pairs)
99 99
100 100
101 if __name__ == '__main__': 101 if __name__ == '__main__':
102 main() 102 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698