Merge lp:~mwhudson/launchpad/no-hosted-area-branchChanged-on-branch into lp:launchpad
- no-hosted-area-branchChanged-on-branch
- Merge into devel
Proposed by
Michael Hudson-Doyle
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 10828 |
Proposed branch: | lp:~mwhudson/launchpad/no-hosted-area-branchChanged-on-branch |
Merge into: | lp:launchpad |
Prerequisite: | lp:~mwhudson/launchpad/no-hosted-area-one-codehosting-endpoint |
Diff against target: |
512 lines (+215/-130) 9 files modified
lib/lp/code/configure.zcml (+1/-1) lib/lp/code/interfaces/branch.py (+17/-0) lib/lp/code/interfaces/codehosting.py (+10/-4) lib/lp/code/model/branch.py (+29/-0) lib/lp/code/model/tests/test_branch.py (+107/-2) lib/lp/code/xmlrpc/codehosting.py (+31/-39) lib/lp/code/xmlrpc/tests/test_codehosting.py (+14/-80) lib/lp/codehosting/inmemory.py (+3/-2) lib/lp/codehosting/vfs/branchfsclient.py (+3/-2) |
To merge this branch: | bzr merge lp:~mwhudson/launchpad/no-hosted-area-branchChanged-on-branch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+23803@code.launchpad.net |
Commit message
Description of the change
Hi,
This branch moves the guts of the branchChanged method from the endpoint implementation to a method on the branch itself.
Cheers,
mwh
To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) : | # |
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/configure.zcml' |
2 | --- lib/lp/code/configure.zcml 2010-04-27 02:17:46 +0000 |
3 | +++ lib/lp/code/configure.zcml 2010-04-27 02:18:06 +0000 |
4 | @@ -548,7 +548,7 @@ |
5 | <require |
6 | permission="launchpad.Edit" |
7 | attributes="destroySelf destroySelfBreakReferences setPrivate |
8 | - setOwner setTarget requestUpgrade" |
9 | + setOwner setTarget requestUpgrade branchChanged" |
10 | set_attributes="name url mirror_status_message |
11 | description lifecycle_status |
12 | last_mirrored last_mirrored_id last_mirror_attempt |
13 | |
14 | === modified file 'lib/lp/code/interfaces/branch.py' |
15 | --- lib/lp/code/interfaces/branch.py 2010-04-27 02:17:46 +0000 |
16 | +++ lib/lp/code/interfaces/branch.py 2010-04-27 02:18:06 +0000 |
17 | @@ -1088,6 +1088,23 @@ |
18 | def startMirroring(): |
19 | """Signal that this branch is being mirrored.""" |
20 | |
21 | + def branchChanged(stacked_on_url, last_revision_id, control_format, |
22 | + branch_format, repository_format): |
23 | + """Record that a branch has been changed. |
24 | + |
25 | + This method records the stacked on branch tip revision id and format |
26 | + or the branch and creates a scan job if the tip revision id has |
27 | + changed. |
28 | + |
29 | + :param stacked_on_url: The unique name of the branch this branch is |
30 | + stacked on, or '' if this branch is not stacked. |
31 | + :param last_revision_id: The tip revision ID of the branch. |
32 | + :param control_format: The entry from ControlFormat for the branch. |
33 | + :param branch_format: The entry from BranchFormat for the branch. |
34 | + :param repository_format: The entry from RepositoryFormat for the |
35 | + branch. |
36 | + """ |
37 | + |
38 | def mirrorComplete(last_revision_id): |
39 | """Signal that a mirror attempt has completed successfully. |
40 | |
41 | |
42 | === modified file 'lib/lp/code/interfaces/codehosting.py' |
43 | --- lib/lp/code/interfaces/codehosting.py 2010-04-27 02:17:46 +0000 |
44 | +++ lib/lp/code/interfaces/codehosting.py 2010-04-27 02:18:06 +0000 |
45 | @@ -166,16 +166,22 @@ |
46 | :param branchID: a branch ID. |
47 | """ |
48 | |
49 | - def branchChanged(branch_id, stacked_on_url, last_revision_id): |
50 | + def branchChanged(login_id, branch_id, stacked_on_url, last_revision_id, |
51 | + control_string, branch_string, repository_string): |
52 | """Record that a branch has been changed. |
53 | |
54 | - This method records the stacked on branch and tip revision id of the |
55 | - branch and creates a scan job if the tip revision id has changed. |
56 | + See `IBranch.branchChanged`. |
57 | |
58 | - :param branchID: The database id of the branch to operate on. |
59 | + :param login_id: the person ID of the user changing the branch. |
60 | + :param branch_id: The database id of the branch to operate on. |
61 | :param stacked_on_url: The unique name of the branch this branch is |
62 | stacked on, or '' if this branch is not stacked. |
63 | :param last_revision_id: The tip revision ID of the branch. |
64 | + :param control_string: The format string of the control directory of |
65 | + the branch. |
66 | + :param branch_string: The format string of the branch. |
67 | + :param repository_string: The format string of the branch's |
68 | + repository. |
69 | """ |
70 | |
71 | def translatePath(requester_id, path): |
72 | |
73 | === modified file 'lib/lp/code/model/branch.py' |
74 | --- lib/lp/code/model/branch.py 2010-04-27 02:17:46 +0000 |
75 | +++ lib/lp/code/model/branch.py 2010-04-27 02:18:06 +0000 |
76 | @@ -899,6 +899,35 @@ |
77 | self.last_mirror_attempt = UTC_NOW |
78 | self.next_mirror_time = None |
79 | |
80 | + def branchChanged(self, stacked_on_location, last_revision_id, |
81 | + control_format, branch_format, repository_format): |
82 | + """See `IBranch`.""" |
83 | + self.mirror_status_message = None |
84 | + if stacked_on_location == '': |
85 | + stacked_on_branch = None |
86 | + else: |
87 | + stacked_on_branch = getUtility(IBranchLookup).getByUniqueName( |
88 | + stacked_on_location.strip('/')) |
89 | + if stacked_on_branch is None: |
90 | + self.mirror_status_message = ( |
91 | + 'Invalid stacked on location: ' + stacked_on_location) |
92 | + self.stacked_on = stacked_on_branch |
93 | + self.last_mirrored = UTC_NOW |
94 | + self.mirror_failures = 0 |
95 | + if (self.next_mirror_time is None |
96 | + and self.branch_type == BranchType.MIRRORED): |
97 | + # No mirror was requested since we started mirroring. |
98 | + increment = getUtility(IBranchPuller).MIRROR_TIME_INCREMENT |
99 | + self.next_mirror_time = ( |
100 | + datetime.datetime.now(pytz.timezone('UTC')) + increment) |
101 | + if self.last_mirrored_id != last_revision_id: |
102 | + self.last_mirrored_id = last_revision_id |
103 | + from lp.code.model.branchjob import BranchScanJob |
104 | + BranchScanJob.create(self) |
105 | + self.control_format = control_format |
106 | + self.branch_format = branch_format |
107 | + self.repository_format = repository_format |
108 | + |
109 | def mirrorComplete(self, last_revision_id): |
110 | """See `IBranch`.""" |
111 | if self.branch_type == BranchType.REMOTE: |
112 | |
113 | === modified file 'lib/lp/code/model/tests/test_branch.py' |
114 | --- lib/lp/code/model/tests/test_branch.py 2010-04-27 02:17:46 +0000 |
115 | +++ lib/lp/code/model/tests/test_branch.py 2010-04-27 02:18:06 +0000 |
116 | @@ -38,7 +38,7 @@ |
117 | SpecificationBranch) |
118 | from lp.bugs.interfaces.bug import CreateBugParams, IBugSet |
119 | from lp.bugs.model.bugbranch import BugBranch |
120 | -from lp.code.bzr import BranchFormat, RepositoryFormat |
121 | +from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat |
122 | from lp.code.enums import ( |
123 | BranchLifecycleStatus, BranchSubscriptionNotificationLevel, BranchType, |
124 | BranchVisibilityRule, CodeReviewNotificationLevel) |
125 | @@ -47,7 +47,8 @@ |
126 | BranchCannotBePrivate, BranchCannotBePublic, |
127 | BranchCreatorNotMemberOfOwnerTeam, BranchCreatorNotOwner, |
128 | BranchTargetError, CannotDeleteBranch, DEFAULT_BRANCH_STATUS_IN_LISTING) |
129 | -from lp.code.interfaces.branchjob import IBranchUpgradeJobSource |
130 | +from lp.code.interfaces.branchjob import ( |
131 | + IBranchUpgradeJobSource, IBranchScanJobSource) |
132 | from lp.code.interfaces.branchlookup import IBranchLookup |
133 | from lp.code.interfaces.branchnamespace import IBranchNamespaceSet |
134 | from lp.code.interfaces.branchmergeproposal import ( |
135 | @@ -94,6 +95,110 @@ |
136 | self.assertEqual(None, branch.code_import) |
137 | |
138 | |
139 | +class TestBranchChanged(TestCaseWithFactory): |
140 | + """Tests for `IBranch.branchChanged`.""" |
141 | + |
142 | + layer = DatabaseFunctionalLayer |
143 | + |
144 | + def setUp(self): |
145 | + TestCaseWithFactory.setUp(self) |
146 | + self.arbitrary_formats = ( |
147 | + ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_6, |
148 | + RepositoryFormat.BZR_CHK_2A) |
149 | + |
150 | + def test_branchChanged_sets_last_mirrored_id(self): |
151 | + # branchChanged sets the last_mirrored_id attribute on the branch. |
152 | + revid = self.factory.getUniqueString() |
153 | + branch = self.factory.makeAnyBranch() |
154 | + login_person(branch.owner) |
155 | + branch.branchChanged('', revid, *self.arbitrary_formats) |
156 | + self.assertEqual(revid, branch.last_mirrored_id) |
157 | + |
158 | + def test_branchChanged_sets_stacked_on(self): |
159 | + # branchChanged sets the stacked_on attribute based on the unique_name |
160 | + # passed in. |
161 | + branch = self.factory.makeAnyBranch() |
162 | + stacked_on = self.factory.makeAnyBranch() |
163 | + login_person(branch.owner) |
164 | + branch.branchChanged( |
165 | + stacked_on.unique_name, '', *self.arbitrary_formats) |
166 | + self.assertEqual(stacked_on, branch.stacked_on) |
167 | + |
168 | + def test_branchChanged_unsets_stacked_on(self): |
169 | + # branchChanged clears the stacked_on attribute on the branch if '' is |
170 | + # passed in as the stacked_on location. |
171 | + branch = self.factory.makeAnyBranch() |
172 | + removeSecurityProxy(branch).stacked_on = self.factory.makeAnyBranch() |
173 | + login_person(branch.owner) |
174 | + branch.branchChanged('', '', *self.arbitrary_formats) |
175 | + self.assertIs(None, branch.stacked_on) |
176 | + |
177 | + def test_branchChanged_sets_last_mirrored(self): |
178 | + # branchChanged sets the last_mirrored attribute on the branch to the |
179 | + # current time. |
180 | + branch = self.factory.makeAnyBranch() |
181 | + login_person(branch.owner) |
182 | + branch.branchChanged('', '', *self.arbitrary_formats) |
183 | + self.assertSqlAttributeEqualsDate( |
184 | + branch, 'last_mirrored', UTC_NOW) |
185 | + |
186 | + def test_branchChanged_records_bogus_stacked_on_url(self): |
187 | + # If a bogus location is passed in as the stacked_on parameter, |
188 | + # mirror_status_message is set to indicate the problem and stacked_on |
189 | + # set to None. |
190 | + branch = self.factory.makeAnyBranch() |
191 | + login_person(branch.owner) |
192 | + branch.branchChanged('~does/not/exist', '', *self.arbitrary_formats) |
193 | + self.assertIs(None, branch.stacked_on) |
194 | + self.assertTrue('~does/not/exist' in branch.mirror_status_message) |
195 | + |
196 | + def test_branchChanged_clears_mirror_status_message_if_no_error(self): |
197 | + # branchChanged() clears any error that's currently mentioned in |
198 | + # mirror_status_message. |
199 | + branch = self.factory.makeAnyBranch() |
200 | + removeSecurityProxy(branch).mirror_status_message = 'foo' |
201 | + login_person(branch.owner) |
202 | + branch.branchChanged('', '', *self.arbitrary_formats) |
203 | + self.assertIs(None, branch.mirror_status_message) |
204 | + |
205 | + def test_branchChanged_creates_scan_job(self): |
206 | + # branchChanged() creates a scan job for the branch. |
207 | + branch = self.factory.makeAnyBranch() |
208 | + login_person(branch.owner) |
209 | + jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
210 | + self.assertEqual(0, len(jobs)) |
211 | + branch.branchChanged('', 'rev1', *self.arbitrary_formats) |
212 | + jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
213 | + self.assertEqual(1, len(jobs)) |
214 | + |
215 | + def test_branchChanged_doesnt_create_scan_job_for_noop_change(self): |
216 | + # branchChanged() doesn't create a scan job if the tip revision id |
217 | + # hasn't changed. |
218 | + branch = self.factory.makeAnyBranch() |
219 | + login_person(branch.owner) |
220 | + removeSecurityProxy(branch).last_mirrored_id = 'rev1' |
221 | + jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
222 | + self.assertEqual(0, len(jobs)) |
223 | + branch.branchChanged('', 'rev1', *self.arbitrary_formats) |
224 | + jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
225 | + self.assertEqual(0, len(jobs)) |
226 | + |
227 | + def test_branchChanged_packs_format(self): |
228 | + # branchChanged sets the branch_format etc attributes to the passed in |
229 | + # values. |
230 | + branch = self.factory.makeAnyBranch() |
231 | + login_person(branch.owner) |
232 | + branch.branchChanged( |
233 | + '', 'rev1', ControlFormat.BZR_METADIR_1, |
234 | + BranchFormat.BZR_BRANCH_6, RepositoryFormat.BZR_KNITPACK_1) |
235 | + login(ANONYMOUS) |
236 | + self.assertEqual( |
237 | + (ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_6, |
238 | + RepositoryFormat.BZR_KNITPACK_1), |
239 | + (branch.control_format, branch.branch_format, |
240 | + branch.repository_format)) |
241 | + |
242 | + |
243 | class TestBranchGetRevision(TestCaseWithFactory): |
244 | """Make sure that `Branch.getBranchRevision` works as expected.""" |
245 | |
246 | |
247 | === modified file 'lib/lp/code/xmlrpc/codehosting.py' |
248 | --- lib/lp/code/xmlrpc/codehosting.py 2010-04-27 02:17:46 +0000 |
249 | +++ lib/lp/code/xmlrpc/codehosting.py 2010-04-27 02:18:06 +0000 |
250 | @@ -22,7 +22,6 @@ |
251 | from zope.security.proxy import removeSecurityProxy |
252 | from zope.security.management import endInteraction |
253 | |
254 | -from canonical.database.constants import UTC_NOW |
255 | from canonical.launchpad.validators import LaunchpadValidationError |
256 | from canonical.launchpad.webapp import LaunchpadXMLRPCView |
257 | from canonical.launchpad.webapp.authorization import check_permission |
258 | @@ -36,7 +35,6 @@ |
259 | from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat |
260 | from lp.code.enums import BranchType |
261 | from lp.code.interfaces.branch import BranchCreationException |
262 | -from lp.code.interfaces.branchjob import IBranchScanJobSource |
263 | from lp.code.interfaces.branchlookup import IBranchLookup |
264 | from lp.code.interfaces.branchnamespace import ( |
265 | InvalidNamespace, lookup_branch_namespace, split_unique_name) |
266 | @@ -240,44 +238,38 @@ |
267 | return True |
268 | return run_with_login(login_id, request_mirror) |
269 | |
270 | - def branchChanged(self, branch_id, stacked_on_location, last_revision_id, |
271 | - control_string, branch_string, repository_string): |
272 | + def branchChanged(self, login_id, branch_id, stacked_on_location, |
273 | + last_revision_id, control_string, branch_string, |
274 | + repository_string): |
275 | """See `ICodehostingAPI`.""" |
276 | - branch_set = removeSecurityProxy(getUtility(IBranchLookup)) |
277 | - branch = branch_set.get(branch_id) |
278 | - if branch is None: |
279 | - return faults.NoBranchWithID(branch_id) |
280 | - branch.mirror_status_message = None |
281 | - if stacked_on_location == '': |
282 | - stacked_on_branch = None |
283 | - else: |
284 | - stacked_on_branch = branch_set.getByUniqueName( |
285 | - stacked_on_location.strip('/')) |
286 | - if stacked_on_branch is None: |
287 | - branch.mirror_status_message = ( |
288 | - 'Invalid stacked on location: ' + stacked_on_location) |
289 | - branch.stacked_on = stacked_on_branch |
290 | - branch.last_mirrored = UTC_NOW |
291 | - if branch.last_mirrored_id != last_revision_id: |
292 | - branch.last_mirrored_id = last_revision_id |
293 | - getUtility(IBranchScanJobSource).create(branch) |
294 | - |
295 | - def match_title(enum, title, default): |
296 | - for value in enum.items: |
297 | - if value.title == title: |
298 | - return value |
299 | - else: |
300 | - return default |
301 | - |
302 | - branch.control_format = match_title( |
303 | - ControlFormat, control_string, ControlFormat.UNRECOGNIZED) |
304 | - branch.branch_format = match_title( |
305 | - BranchFormat, branch_string, BranchFormat.UNRECOGNIZED) |
306 | - branch.repository_format = match_title( |
307 | - RepositoryFormat, repository_string, |
308 | - RepositoryFormat.UNRECOGNIZED) |
309 | - |
310 | - return True |
311 | + def branch_changed(request_mirror): |
312 | + branch_set = getUtility(IBranchLookup) |
313 | + branch = branch_set.get(branch_id) |
314 | + if branch is None: |
315 | + return faults.NoBranchWithID(branch_id) |
316 | + |
317 | + def match_title(enum, title, default): |
318 | + for value in enum.items: |
319 | + if value.title == title: |
320 | + return value |
321 | + else: |
322 | + return default |
323 | + |
324 | + control_format = match_title( |
325 | + ControlFormat, control_string, ControlFormat.UNRECOGNIZED) |
326 | + branch_format = match_title( |
327 | + BranchFormat, branch_string, BranchFormat.UNRECOGNIZED) |
328 | + repository_format = match_title( |
329 | + RepositoryFormat, repository_string, |
330 | + RepositoryFormat.UNRECOGNIZED) |
331 | + |
332 | + branch.branchChanged( |
333 | + stacked_on_location, last_revision_id, control_format, |
334 | + branch_format, repository_format) |
335 | + |
336 | + return True |
337 | + |
338 | + return run_with_login(login_id, branch_changed) |
339 | |
340 | def _serializeBranch(self, requester, branch, trailing_path): |
341 | if requester == LAUNCHPAD_SERVICES: |
342 | |
343 | === modified file 'lib/lp/code/xmlrpc/tests/test_codehosting.py' |
344 | --- lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-04-27 02:17:46 +0000 |
345 | +++ lib/lp/code/xmlrpc/tests/test_codehosting.py 2010-04-27 02:18:06 +0000 |
346 | @@ -578,102 +578,34 @@ |
347 | return self.getFormatStringsForFormatName('default') |
348 | |
349 | def test_branchChanged_sets_last_mirrored_id(self): |
350 | - # branchChanged sets the last_mirrored_id attribute on the branch. |
351 | + # branchChanged does many things but lets just check the setting of |
352 | + # last_mirrored_id here. The other things are tested in unit tests. |
353 | revid = self.factory.getUniqueString() |
354 | branch = self.factory.makeAnyBranch() |
355 | self.codehosting_api.branchChanged( |
356 | - branch.id, '', revid, *self.arbitrary_format_strings) |
357 | + branch.owner.id, branch.id, '', revid, |
358 | + *self.arbitrary_format_strings) |
359 | + login(ANONYMOUS) |
360 | self.assertEqual(revid, branch.last_mirrored_id) |
361 | |
362 | - def test_branchChanged_sets_stacked_on(self): |
363 | - # branchChanged sets the stacked_on attribute based on the unique_name |
364 | - # passed in. |
365 | - branch = self.factory.makeAnyBranch() |
366 | - stacked_on = self.factory.makeAnyBranch() |
367 | - self.codehosting_api.branchChanged( |
368 | - branch.id, stacked_on.unique_name, '', |
369 | - *self.arbitrary_format_strings) |
370 | - self.assertEqual(stacked_on, branch.stacked_on) |
371 | - |
372 | - def test_branchChanged_unsets_stacked_on(self): |
373 | - # branchChanged clears the stacked_on attribute on the branch if '' is |
374 | - # passed in as the stacked_on location. |
375 | - branch = self.factory.makeAnyBranch() |
376 | - removeSecurityProxy(branch).stacked_on = self.factory.makeAnyBranch() |
377 | - self.codehosting_api.branchChanged( |
378 | - branch.id, '', '', *self.arbitrary_format_strings) |
379 | - self.assertIs(None, branch.stacked_on) |
380 | - |
381 | - def test_branchChanged_sets_last_mirrored(self): |
382 | - # branchChanged sets the last_mirrored attribute on the branch to the |
383 | - # current time. |
384 | - branch = self.factory.makeAnyBranch() |
385 | - self.codehosting_api.branchChanged( |
386 | - branch.id, '', '', *self.arbitrary_format_strings) |
387 | - if self.frontend == LaunchpadDatabaseFrontend: |
388 | - self.assertSqlAttributeEqualsDate( |
389 | - branch, 'last_mirrored', UTC_NOW) |
390 | - else: |
391 | - self.assertIs(UTC_NOW, branch.last_mirrored) |
392 | - |
393 | - def test_branchChanged_records_bogus_stacked_on_url(self): |
394 | - # If a bogus location is passed in as the stacked_on parameter, |
395 | - # mirror_status_message is set to indicate the problem and stacked_on |
396 | - # set to None. |
397 | - branch = self.factory.makeAnyBranch() |
398 | - self.codehosting_api.branchChanged( |
399 | - branch.id, '~does/not/exist', '', *self.arbitrary_format_strings) |
400 | - self.assertIs(None, branch.stacked_on) |
401 | - self.assertTrue('~does/not/exist' in branch.mirror_status_message) |
402 | - |
403 | - def test_branchChanged_clears_mirror_status_message_if_no_error(self): |
404 | - # branchChanged() clears any error that's currently mentioned in |
405 | - # mirror_status_message. |
406 | - branch = self.factory.makeAnyBranch() |
407 | - removeSecurityProxy(branch).mirror_status_message = 'foo' |
408 | - self.codehosting_api.branchChanged( |
409 | - branch.id, '', '', *self.arbitrary_format_strings) |
410 | - self.assertIs(None, branch.mirror_status_message) |
411 | - |
412 | def test_branchChanged_fault_on_unknown_id(self): |
413 | # If the id passed in doesn't match an existing branch, the fault |
414 | # "NoBranchWithID" is returned. |
415 | unused_id = -1 |
416 | expected_fault = faults.NoBranchWithID(unused_id) |
417 | received_fault = self.codehosting_api.branchChanged( |
418 | - unused_id, '', '', *self.arbitrary_format_strings) |
419 | + 1, unused_id, '', '', *self.arbitrary_format_strings) |
420 | + login(ANONYMOUS) |
421 | self.assertEqual( |
422 | (expected_fault.faultCode, expected_fault.faultString), |
423 | (received_fault.faultCode, received_fault.faultString)) |
424 | |
425 | - def test_branchChanged_creates_scan_job(self): |
426 | - # branchChanged() creates a scan job for the branch. |
427 | - if self.frontend != LaunchpadDatabaseFrontend: |
428 | - return |
429 | - branch = self.factory.makeAnyBranch() |
430 | - jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
431 | - self.assertEqual(0, len(jobs)) |
432 | - self.codehosting_api.branchChanged( |
433 | - branch.id, '', 'rev1', *self.arbitrary_format_strings) |
434 | - jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
435 | - self.assertEqual(1, len(jobs)) |
436 | - |
437 | - def test_branchChanged_doesnt_create_scan_job_for_noop_change(self): |
438 | - if self.frontend != LaunchpadDatabaseFrontend: |
439 | - return |
440 | - branch = self.factory.makeAnyBranch() |
441 | - removeSecurityProxy(branch).last_mirrored_id = 'rev1' |
442 | - jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
443 | - self.assertEqual(0, len(jobs)) |
444 | - self.codehosting_api.branchChanged( |
445 | - branch.id, '', 'rev1', *self.arbitrary_format_strings) |
446 | - jobs = list(getUtility(IBranchScanJobSource).iterReady()) |
447 | - self.assertEqual(0, len(jobs)) |
448 | - |
449 | def test_branchChanged_2a_format(self): |
450 | branch = self.factory.makeAnyBranch() |
451 | self.codehosting_api.branchChanged( |
452 | - branch.id, '', 'rev1', *self.getFormatStringsForFormatName('2a')) |
453 | + branch.owner.id, branch.id, '', 'rev1', |
454 | + *self.getFormatStringsForFormatName('2a')) |
455 | + login(ANONYMOUS) |
456 | self.assertEqual( |
457 | (ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_7, |
458 | RepositoryFormat.BZR_CHK_2A), |
459 | @@ -683,8 +615,9 @@ |
460 | def test_branchChanged_packs_format(self): |
461 | branch = self.factory.makeAnyBranch() |
462 | self.codehosting_api.branchChanged( |
463 | - branch.id, '', 'rev1', |
464 | + branch.owner.id, branch.id, '', 'rev1', |
465 | *self.getFormatStringsForFormatName('pack-0.92')) |
466 | + login(ANONYMOUS) |
467 | self.assertEqual( |
468 | (ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_6, |
469 | RepositoryFormat.BZR_KNITPACK_1), |
470 | @@ -694,8 +627,9 @@ |
471 | def test_branchChanged_knits_format(self): |
472 | branch = self.factory.makeAnyBranch() |
473 | self.codehosting_api.branchChanged( |
474 | - branch.id, '', 'rev1', |
475 | + branch.owner.id, branch.id, '', 'rev1', |
476 | *self.getFormatStringsForFormatName('knit')) |
477 | + login(ANONYMOUS) |
478 | self.assertEqual( |
479 | (ControlFormat.BZR_METADIR_1, BranchFormat.BZR_BRANCH_5, |
480 | RepositoryFormat.BZR_KNIT_1), |
481 | |
482 | === modified file 'lib/lp/codehosting/inmemory.py' |
483 | --- lib/lp/codehosting/inmemory.py 2010-04-27 02:17:46 +0000 |
484 | +++ lib/lp/codehosting/inmemory.py 2010-04-27 02:18:06 +0000 |
485 | @@ -614,8 +614,9 @@ |
486 | def requestMirror(self, requester_id, branch_id): |
487 | self._branch_set.get(branch_id).requestMirror() |
488 | |
489 | - def branchChanged(self, branch_id, stacked_on_location, last_revision_id, |
490 | - control_string, branch_string, repository_string): |
491 | + def branchChanged(self, login_id, branch_id, stacked_on_location, |
492 | + last_revision_id, control_string, branch_string, |
493 | + repository_string): |
494 | branch = self._branch_set._find(id=branch_id) |
495 | if branch is None: |
496 | return faults.NoBranchWithID(branch_id) |
497 | |
498 | === modified file 'lib/lp/codehosting/vfs/branchfsclient.py' |
499 | --- lib/lp/codehosting/vfs/branchfsclient.py 2010-04-27 02:17:46 +0000 |
500 | +++ lib/lp/codehosting/vfs/branchfsclient.py 2010-04-27 02:18:06 +0000 |
501 | @@ -126,8 +126,9 @@ |
502 | """ |
503 | return defer.maybeDeferred( |
504 | self._codehosting_endpoint.callRemote, |
505 | - 'branchChanged', branch_id, stacked_on_url, last_revision_id, |
506 | - control_string, branch_string, repository_string) |
507 | + 'branchChanged', self._user_id, branch_id, stacked_on_url, |
508 | + last_revision_id, control_string, branch_string, |
509 | + repository_string) |
510 | |
511 | def translatePath(self, path): |
512 | """Translate 'path'.""" |