Skip to content

Commit 9ebe1f1

Browse files
committed
Shrink the size of the argument to SCMProvider.check_for_update
We don't need the whole job object, just its version is sufficient. This is an ugly fix for a recursion overflow in the memoize implementation where we pickle the argument. A better fix would be to fix memoize. Or revisit the need to have a linked list of every single job for a library. Fixes #403
1 parent 38d734a commit 9ebe1f1

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

components/scmprovider.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _ensure_checkout(self, repo_url, specific_revision=None):
115115

116116
@logEntryExit
117117
@Memoize
118-
def check_for_update(self, library, task, new_version, most_recent_job):
118+
def check_for_update(self, library, task, new_version, most_recent_job_version):
119119
# This function uses two tricky variable names:
120120
# all_upstream_commits - This means the commits that have occured upstream, on the branch we care about,
121121
# between the library's current revision and the tip of the branch.
@@ -159,8 +159,8 @@ def check_for_update(self, library, task, new_version, most_recent_job):
159159
# in m-c we update the library to B (or maybe even a new rev C with no job)
160160
# Resulting in the most recent job (which was for B) occured _before_ the library's current revision
161161
# We can only do this if we have a most recent job, if we don't we're processing this library for the first time
162-
if most_recent_job:
163-
most_recent_job_newer_than_library_rev = most_recent_job.version in [c.revision for c in all_new_upstream_commits]
162+
if most_recent_job_version:
163+
most_recent_job_newer_than_library_rev = most_recent_job_version in [c.revision for c in all_new_upstream_commits]
164164
if most_recent_job_newer_than_library_rev:
165165
self.logger.log("The most recent job we have run is for a revision still upstream and not in the mozilla repo.", level=LogLevel.Debug)
166166
else:
@@ -172,11 +172,11 @@ def check_for_update(self, library, task, new_version, most_recent_job):
172172
unseen_new_upstream_commits = []
173173
if most_recent_job_newer_than_library_rev:
174174
# Step 5: Get the list of commits between the revision for the most recent job
175-
# and new_version. (We previously confirmed that most_recent_job.version is in the sequence
175+
# and new_version. (We previously confirmed that most_recent_job_version is in the sequence
176176
# of commits from common_ancestor..new_version)
177-
unseen_new_upstream_commits = self._commits_between(most_recent_job.version, new_version)
177+
unseen_new_upstream_commits = self._commits_between(most_recent_job_version, new_version)
178178
if len(unseen_new_upstream_commits) == 0:
179-
self.logger.log("Already processed revision %s in bug %s" % (most_recent_job.version, most_recent_job.bugzilla_id), level=LogLevel.Info)
179+
self.logger.log("Already processed revision %s" % (most_recent_job_version), level=LogLevel.Info)
180180
return all_new_upstream_commits, []
181181

182182
# Step 6: Ensure that the unseen list of a subset of the 'all-new' list

tasktypes/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def frequency_type():
6565
return False
6666

6767
if commit_count > 0:
68-
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, most_recent_job)
68+
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, most_recent_job.version if most_recent_job else None)
6969
commits_since_in_tree = len(all_upstream_commits)
7070
commits_since_new_job = len(unseen_upstream_commits)
7171

tasktypes/commitalert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def process_task(self, library, task):
3333
my_ff_version = self.config['General']['ff-version']
3434

3535
all_library_jobs = self.dbProvider.get_all_jobs_for_library(library, JOBTYPE.COMMITALERT)
36-
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, task.branch or "HEAD", all_library_jobs[0] if all_library_jobs else None)
36+
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, task.branch or "HEAD", all_library_jobs[0].version if all_library_jobs else None)
3737
self.logger.log("We found %s previous jobs, %s upstream commits, and %s unseen upstream commits." % (
3838
len(all_library_jobs), len(all_upstream_commits), len(unseen_upstream_commits)), level=LogLevel.Info)
3939

tasktypes/vendoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def _process_new_job(self, library, task, new_version, timestamp, most_recent_jo
130130
self.logger.set_context(library.name, created_job.id)
131131

132132
# File the bug ------------------------
133-
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, most_recent_job)
133+
all_upstream_commits, unseen_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, most_recent_job.version if most_recent_job else None)
134134
commit_stats = self.mercurialProvider.diff_stats()
135135
commit_details = self.scmProvider.build_bug_description(all_upstream_commits, 65534 - len(commit_stats) - 220) if library.should_show_commit_details else ""
136136

tests/frequency.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ def testFrequency(self):
7777
self.assertFalse(bt._should_process_new_job(library, task))
7878

7979
task.frequency = '1 week, 3 commits'
80-
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1)})]
80+
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1), "version": "whatever"})]
8181
self.assertFalse(bt._should_process_new_job(library, task))
8282

8383
task.frequency = '2 weeks, 2 commits'
84-
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1)})]
84+
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1), "version": "whatever"})]
8585
self.assertFalse(bt._should_process_new_job(library, task))
8686

8787
task.frequency = '1 week, 2 commits'
88-
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1)})]
88+
bt.dbProvider.get_all_jobs_for_library = lambda a, b: [Struct(**{"created": datetime.now() - timedelta(weeks=1, hours=1), "version": "whatever"})]
8989
self.assertTrue(bt._should_process_new_job(library, task))
9090

9191

tests/scm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def testCheckForUpdates(self):
9292
new_version = COMMITS_MAIN[0]
9393
library.revision = COMMITS_MAIN[-1]
9494
ignoreme = Struct(**{'version': COMMITS_MAIN[3]})
95-
all_new_upstream_commits, unseen_new_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, ignoreme)
95+
all_new_upstream_commits, unseen_new_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, ignoreme.version)
9696
self.assertEqual(len(all_new_upstream_commits), len(COMMITS_MAIN) - 1)
9797
for i in range(len(COMMITS_MAIN) - 1):
9898
self.assertEqual(all_new_upstream_commits[i].revision, COMMITS_MAIN_R[i + 1])
@@ -115,7 +115,7 @@ def testCheckForUpdatesOnTagSkipOne(self):
115115
new_version = 'v0.0.2'
116116
library.revision = 'v0.0.1'
117117
ignoreme = Struct(**{'version': COMMITS_MAIN[-4]})
118-
all_new_upstream_commits, unseen_new_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, ignoreme)
118+
all_new_upstream_commits, unseen_new_upstream_commits = self.scmProvider.check_for_update(library, task, new_version, ignoreme.version)
119119
self.assertEqual(len(all_new_upstream_commits), 2)
120120
self.assertEqual(len(unseen_new_upstream_commits), 1)
121121

0 commit comments

Comments
 (0)