Merge lp:~mwhudson/launchpad/directbranchcommit-calls-branchChanged-bug-578331 into lp:launchpad

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: 10888
Proposed branch: lp:~mwhudson/launchpad/directbranchcommit-calls-branchChanged-bug-578331
Merge into: lp:launchpad
Diff against target: 131 lines (+26/-15)
6 files modified
database/schema/security.cfg (+2/-2)
lib/lp/code/model/branch.py (+1/-1)
lib/lp/code/model/directbranchcommit.py (+5/-1)
lib/lp/code/tests/test_directbranchcommit.py (+7/-0)
lib/lp/codehosting/bzrutils.py (+9/-0)
lib/lp/codehosting/vfs/branchfs.py (+2/-11)
To merge this branch: bzr merge lp:~mwhudson/launchpad/directbranchcommit-calls-branchChanged-bug-578331
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Aaron Bentley (community) Approve
Review via email: mp+25059@code.launchpad.net

Commit message

directbranchcommit should call branchChanged not requestMirror

Description of the change

Hi there,

This branch changes directbranchcommit to call branchChanged rather than requestMirror, as the latter doesn't make sense now since no-hosted-area landed.

Cheers,
mwh

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) wrote :

Looks good, subject to updating the test comment, as we discussed in IRC.

review: Approve
Revision history for this message
Данило Шеган (danilo) wrote :

Per discussion on IRC, and after confirming that the new test fails as-is on the existing code, I think this is good to land.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/schema/security.cfg'
2--- database/schema/security.cfg 2010-05-03 06:59:06 +0000
3+++ database/schema/security.cfg 2010-05-12 08:45:50 +0000
4@@ -1362,9 +1362,9 @@
5 type=user
6 groups=script
7 public.branch = SELECT, UPDATE
8-public.branchjob = SELECT
9+public.branchjob = SELECT, UPDATE, INSERT
10 public.emailaddress = SELECT
11-public.job = SELECT
12+public.job = SELECT, UPDATE, INSERT
13 public.language = SELECT
14 public.person = SELECT
15 public.pofile = SELECT
16
17=== modified file 'lib/lp/code/model/branch.py'
18--- lib/lp/code/model/branch.py 2010-04-23 04:11:12 +0000
19+++ lib/lp/code/model/branch.py 2010-05-12 08:45:50 +0000
20@@ -897,7 +897,7 @@
21 control_format, branch_format, repository_format):
22 """See `IBranch`."""
23 self.mirror_status_message = None
24- if stacked_on_location == '':
25+ if stacked_on_location == '' or stacked_on_location is None:
26 stacked_on_branch = None
27 else:
28 stacked_on_branch = getUtility(IBranchLookup).getByUniqueName(
29
30=== modified file 'lib/lp/code/model/directbranchcommit.py'
31--- lib/lp/code/model/directbranchcommit.py 2010-04-26 00:24:26 +0000
32+++ lib/lp/code/model/directbranchcommit.py 2010-05-12 08:45:50 +0000
33@@ -18,6 +18,7 @@
34
35 from canonical.launchpad.interfaces import IMasterObject
36
37+from lp.codehosting.bzrutils import get_stacked_on_url
38
39 class ConcurrentUpdateError(Exception):
40 """Bailout exception for concurrent updates.
41@@ -189,7 +190,10 @@
42 return
43 new_rev_id = self.transform_preview.commit(
44 self.bzrbranch, commit_message)
45- IMasterObject(self.db_branch).requestMirror()
46+ IMasterObject(self.db_branch).branchChanged(
47+ get_stacked_on_url(self.bzrbranch), new_rev_id,
48+ self.db_branch.control_format, self.db_branch.branch_format,
49+ self.db_branch.repository_format)
50
51 if txn:
52 txn.commit()
53
54=== modified file 'lib/lp/code/tests/test_directbranchcommit.py'
55--- lib/lp/code/tests/test_directbranchcommit.py 2010-04-23 03:02:01 +0000
56+++ lib/lp/code/tests/test_directbranchcommit.py 2010-05-12 08:45:50 +0000
57@@ -174,6 +174,13 @@
58 self.committer.writeFile('hi.py', 'print "hi world"')
59 self.assertRaises(ConcurrentUpdateError, self.committer.commit, '')
60
61+ def test_DirectBranchCommit_records_committed_revision_id(self):
62+ # commit() records the committed revision in the database record for
63+ # the branch.
64+ self.committer.writeFile('hi.c', 'main(){puts("hi world");}')
65+ revid = self.committer.commit('')
66+ self.assertEqual(revid, self.db_branch.last_mirrored_id)
67+
68
69 class TestDirectBranchCommit_getDir(DirectBranchCommitTestCase):
70 """Test `DirectBranchCommit._getDir`."""
71
72=== modified file 'lib/lp/codehosting/bzrutils.py'
73--- lib/lp/codehosting/bzrutils.py 2010-04-27 01:39:55 +0000
74+++ lib/lp/codehosting/bzrutils.py 2010-05-12 08:45:50 +0000
75@@ -12,6 +12,7 @@
76 'add_exception_logging_hook',
77 'DenyingServer',
78 'get_branch_stacked_on_url',
79+ 'get_stacked_on_url',
80 'get_vfs_format_classes',
81 'HttpAsLocalTransport',
82 'identical_formats',
83@@ -340,3 +341,11 @@
84 """
85 return checked_open(
86 makeURLChecker(allowed_scheme), url, possible_transports)
87+
88+
89+def get_stacked_on_url(branch):
90+ """Get the stacked-on URL for 'branch', or `None` if not stacked."""
91+ try:
92+ return branch.get_stacked_on_url()
93+ except (NotStacked, UnstackableBranchFormat):
94+ return None
95
96=== modified file 'lib/lp/codehosting/vfs/branchfs.py'
97--- lib/lp/codehosting/vfs/branchfs.py 2010-05-04 23:42:28 +0000
98+++ lib/lp/codehosting/vfs/branchfs.py 2010-05-12 08:45:50 +0000
99@@ -66,9 +66,7 @@
100 from bzrlib.branch import Branch
101 from bzrlib.bzrdir import BzrDir, BzrDirFormat
102 from bzrlib.config import TransportConfig
103-from bzrlib.errors import (
104- NoSuchFile, NotStacked, PermissionDenied, TransportNotPossible,
105- UnstackableBranchFormat)
106+from bzrlib.errors import NoSuchFile, PermissionDenied, TransportNotPossible
107 from bzrlib.plugins.loom.branch import LoomSupport
108 from bzrlib.smart.request import jail_info
109 from bzrlib.transport import get_transport
110@@ -83,6 +81,7 @@
111 from zope.component import getUtility
112 from zope.interface import implements, Interface
113
114+from lp.codehosting.bzrutils import get_stacked_on_url
115 from lp.codehosting.vfs.branchfsclient import (
116 BlockingProxy, BranchFileSystemClient)
117 from lp.codehosting.vfs.transport import (
118@@ -706,14 +705,6 @@
119 return lp_server
120
121
122-def get_stacked_on_url(branch):
123- """Get the stacked-on URL for 'branch', or `None` if not stacked."""
124- try:
125- return branch.get_stacked_on_url()
126- except (NotStacked, UnstackableBranchFormat):
127- return None
128-
129-
130 class BranchPolicy:
131 """Policy on how to mirror branches.
132