@@ -48,15 +48,17 @@ def retrieve_revision(commit_id, username, project, revision=None):
4848 raise e
4949
5050 if commit_json ["message" ] in ("Not Found" , "Server Error" ,):
51- # We'll still cache these for a brief period of time to avoid making too many requests:
51+ # We'll still cache these for a brief period of time to avoid
52+ # making too many requests:
5253 cache .set (commit_url , commit_json , 300 )
5354 else :
5455 # We'll cache successes for a very long period of time since
5556 # SCM diffs shouldn't change:
5657 cache .set (commit_url , commit_json , 86400 * 30 )
5758
5859 if commit_json ["message" ] in ("Not Found" , "Server Error" ,):
59- raise CommitLogError ("Unable to load %s: %s" % (commit_url , commit_json ["message" ]))
60+ raise CommitLogError (
61+ "Unable to load %s: %s" % (commit_url , commit_json ["message" ]))
6062
6163 date = isodate .parse_datetime (commit_json ['committer' ]['date' ])
6264
@@ -66,7 +68,8 @@ def retrieve_revision(commit_id, username, project, revision=None):
6668
6769 # We need to convert the timezone-aware date to a naive (i.e.
6870 # timezone-less) date in UTC to avoid killing MySQL:
69- revision .date = date .astimezone (isodate .tzinfo .Utc ()).replace (tzinfo = None )
71+ revision .date = date .astimezone (
72+ isodate .tzinfo .Utc ()).replace (tzinfo = None )
7073 revision .author = commit_json ['author' ]['name' ]
7174 revision .message = commit_json ['message' ]
7275 revision .full_clean ()
@@ -85,7 +88,7 @@ def retrieve_revision(commit_id, username, project, revision=None):
8588def getlogs (endrev , startrev ):
8689 if endrev != startrev :
8790 revisions = endrev .branch .revisions .filter (
88- date__lte = endrev .date , date__gte = startrev .date )
91+ date__lte = endrev .date , date__gte = startrev .date )
8992 else :
9093 revisions = [i for i in (startrev , endrev ) if i .commitid ]
9194
@@ -105,23 +108,29 @@ def getlogs(endrev, startrev):
105108 last_rev_data = None
106109 revision_count = 0
107110 ancestor_found = False
108- #TODO: get all revisions between endrev and startrev,
111+ # TODO: get all revisions between endrev and startrev,
109112 # not only those present in the Codespeed DB
110113
111114 for revision in revisions :
112- last_rev_data = retrieve_revision (revision .commitid , username , project , revision )
115+ last_rev_data = retrieve_revision (
116+ revision .commitid , username , project , revision )
113117 logs .append (last_rev_data )
114118 revision_count += 1
115- ancestor_found = (startrev .commitid in [rev ['sha' ] for rev in last_rev_data ['parents' ]])
119+ ancestor_found = (
120+ startrev .commitid in [
121+ rev ['sha' ] for rev in last_rev_data ['parents' ]])
116122
117123 # Simple approach to find the startrev, stop after found or after
118124 # #GITHUB_REVISION_LIMIT revisions are fetched
119125 while (revision_count < GITHUB_REVISION_LIMIT
120126 and not ancestor_found
121127 and len (last_rev_data ['parents' ]) > 0 ):
122- last_rev_data = retrieve_revision (last_rev_data ['parents' ][0 ]['sha' ], username , project )
128+ last_rev_data = retrieve_revision (
129+ last_rev_data ['parents' ][0 ]['sha' ], username , project )
123130 logs .append (last_rev_data )
124131 revision_count += 1
125- ancestor_found = (startrev .commitid in [rev ['sha' ] for rev in last_rev_data ['parents' ]])
132+ ancestor_found = (
133+ startrev .commitid in [
134+ rev ['sha' ] for rev in last_rev_data ['parents' ]])
126135
127136 return sorted (logs , key = lambda i : i ['date' ], reverse = True )
0 commit comments