Merge lp:~mwhudson/launchpad/dont-acquire-remote-branch-bug-408656 into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/dont-acquire-remote-branch-bug-408656
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~mwhudson/launchpad/dont-acquire-remote-branch-bug-408656
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+9619@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Hi,

From the bug report (bug 408656):

In general, remote branches never have next_mirror_time set. However, we have a bunch in the database that do, from when we mass-converted Jelmer's gnome-svn mirror branches from MIRRORED to REMOTE. It's probably better for acquireBranchToPull to not return these than fix the database and never have this happen again.

The fix is very simple.

Revision history for this message
Tim Penhey (thumper) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/branchpuller.py'
2--- lib/lp/code/model/branchpuller.py 2009-06-30 16:56:07 +0000
3+++ lib/lp/code/model/branchpuller.py 2009-08-04 05:14:32 +0000
4@@ -55,7 +55,8 @@
5 store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
6 branch = store.find(
7 Branch,
8- Branch.next_mirror_time <= UTC_NOW).order_by(
9+ Branch.next_mirror_time <= UTC_NOW,
10+ Branch.branch_type != BranchType.REMOTE).order_by(
11 Branch.next_mirror_time).first()
12 if branch is not None:
13 branch.startMirroring()
14
15=== modified file 'lib/lp/code/model/tests/test_branchpuller.py'
16--- lib/lp/code/model/tests/test_branchpuller.py 2009-07-17 00:26:05 +0000
17+++ lib/lp/code/model/tests/test_branchpuller.py 2009-08-04 05:14:32 +0000
18@@ -73,7 +73,6 @@
19 self.assertEqual(
20 [branch],
21 list(self.branch_puller.getPullQueue(branch.branch_type)))
22- next_mirror_time = branch.next_mirror_time
23 branch.mirrorComplete('rev1')
24 self.assertEqual(
25 [branch],
26@@ -256,6 +255,16 @@
27 branch.requestMirror()
28 self.assertBranchIsAquired(branch)
29
30+ def test_remote_branch_not_acquired(self):
31+ # On a few occasions a branch type that is mirrored has been
32+ # converted, with non-NULL next_mirror_time, to a remote branch, which
33+ # is not mirrored. These branches should not be returned.
34+ branch = self.factory.makeAnyBranch(branch_type=BranchType.HOSTED)
35+ branch.requestMirror()
36+ removeSecurityProxy(branch).branch_type = BranchType.REMOTE
37+ self.assertNoBranchIsAquired()
38+
39+
40 def test_private(self):
41 # If there is a private branch that needs mirroring,
42 # acquireBranchToPull returns that.
43
44=== modified file 'lib/lp/codehosting/inmemory.py'
45--- lib/lp/codehosting/inmemory.py 2009-07-17 00:26:05 +0000
46+++ lib/lp/codehosting/inmemory.py 2009-08-04 05:14:32 +0000
47@@ -468,7 +468,8 @@
48 def acquireBranchToPull(self):
49 branches = sorted(
50 [branch for branch in self._branch_set
51- if branch.next_mirror_time is not None],
52+ if branch.next_mirror_time is not None
53+ and branch.branch_type != BranchType.REMOTE],
54 key=operator.attrgetter('next_mirror_time'))
55 if branches:
56 branch = branches[-1]