Merge lp:~mwhudson/launchpad/no-hosted-area-fix-useBzrBranch-users into lp:launchpad/db-devel
- no-hosted-area-fix-useBzrBranch-users
- Merge into db-devel
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~mwhudson/launchpad/no-hosted-area-fix-useBzrBranch-users |
Merge into: | lp:launchpad/db-devel |
Prerequisite: | lp:~mwhudson/launchpad/no-hosted-area-fix-directbranchcommit |
Diff against target: |
1127 lines (+136/-160) 28 files modified
lib/canonical/buildd/tests/test_generate_translation_templates.py (+4/-4) lib/canonical/launchpad/scripts/tests/test_garbo.py (+0/-2) lib/lp/code/configure.zcml (+1/-1) lib/lp/code/interfaces/branch.py (+9/-7) lib/lp/code/interfaces/branchtarget.py (+4/-2) lib/lp/code/mail/codehandler.py (+1/-2) lib/lp/code/mail/tests/test_codehandler.py (+18/-50) lib/lp/code/model/branch.py (+3/-4) lib/lp/code/model/branchjob.py (+6/-5) lib/lp/code/model/branchmergeproposaljob.py (+4/-4) lib/lp/code/model/diff.py (+3/-4) lib/lp/code/model/directbranchcommit.py (+7/-1) lib/lp/code/model/tests/test_branch.py (+1/-1) lib/lp/code/model/tests/test_branchjob.py (+24/-26) lib/lp/code/model/tests/test_branchmergeproposaljobs.py (+4/-4) lib/lp/code/model/tests/test_diff.py (+12/-10) lib/lp/code/scripts/tests/test_create_merge_proposals.py (+4/-10) lib/lp/code/scripts/tests/test_scan_branches.py (+3/-4) lib/lp/code/scripts/tests/test_upgrade_branches.py (+4/-5) lib/lp/codehosting/inmemory.py (+2/-2) lib/lp/codehosting/scanner/bzrsync.py (+1/-2) lib/lp/codehosting/tests/test_branchdistro.py (+1/-1) lib/lp/codehosting/tests/test_jobs.py (+1/-1) lib/lp/codehosting/vfs/__init__.py (+3/-2) lib/lp/codehosting/vfs/branchfs.py (+4/-2) lib/lp/testing/__init__.py (+8/-1) lib/lp/testing/factory.py (+2/-2) lib/lp/translations/tests/test_translationtemplatesbuildjob.py (+2/-1) |
To merge this branch: | bzr merge lp:~mwhudson/launchpad/no-hosted-area-fix-useBzrBranch-users |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | conditional | Approve | |
Review via email:
|
Commit message
Description of the change
Hi Tim,
This branch is a bit of a mess of assorted test fixes. I hope it's not too deathly dull to read!
Cheers,
mwh
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Michael Hudson-Doyle (mwhudson) wrote : | # |
On 26/04/10 20:58, Tim Penhey wrote:
> Review: Approve conditional
> I know that it is not worth it now, but in
> lib/lp/
> have just overridden the inherited useBzrBranches method
> to make it always specify direct_
Yeah, this aspect of things does smell a bit doesn't it?
> It may be an interesting count, but which is used more?
> direct_
It seems 43 of 64 calls use direct_
Part of my unease around this comes from the fact that what determines
whether to use direct_database or not basically depends on the layer --
if it's a appserver layer, don't use direct_database, otherwise do. I
don't know if tying it to the layer makes sense though.
What do you think?
> lib/lp/
> - you still have: raise AssertionError(
>
> removeSecurityP
> - is there a bzrlib constant we can use here?
Yes, but that line disappears in a later pipe anyway I think...
> And yes, it was a pretty boring branch to review. Great
> to see a consistent use of getInternalBzrUrl and getBzrBranch.
Yeah!
Cheers,
mwh
Preview Diff
1 | === modified file 'lib/canonical/buildd/tests/test_generate_translation_templates.py' | |||
2 | --- lib/canonical/buildd/tests/test_generate_translation_templates.py 2010-03-18 13:27:47 +0000 | |||
3 | +++ lib/canonical/buildd/tests/test_generate_translation_templates.py 2010-04-27 02:24:35 +0000 | |||
4 | @@ -57,7 +57,7 @@ | |||
5 | 57 | 57 | ||
6 | 58 | :return: a fresh lp.code.model.Branch backed by a real bzr branch. | 58 | :return: a fresh lp.code.model.Branch backed by a real bzr branch. |
7 | 59 | """ | 59 | """ |
9 | 60 | db_branch, tree = self.create_branch_and_tree(hosted=True) | 60 | db_branch, tree = self.create_branch_and_tree() |
10 | 61 | populist = DirectBranchCommit(db_branch) | 61 | populist = DirectBranchCommit(db_branch) |
11 | 62 | last_revision = populist.bzrbranch.last_revision() | 62 | last_revision = populist.bzrbranch.last_revision() |
12 | 63 | db_branch.last_scanned_id = populist.last_scanned_id = last_revision | 63 | db_branch.last_scanned_id = populist.last_scanned_id = last_revision |
13 | @@ -71,13 +71,13 @@ | |||
14 | 71 | 71 | ||
15 | 72 | def test_getBranch_bzr(self): | 72 | def test_getBranch_bzr(self): |
16 | 73 | # _getBranch can retrieve branch contents from a branch URL. | 73 | # _getBranch can retrieve branch contents from a branch URL. |
18 | 74 | self.useBzrBranches() | 74 | self.useBzrBranches(direct_database=True) |
19 | 75 | marker_text = "Ceci n'est pas cet branch." | 75 | marker_text = "Ceci n'est pas cet branch." |
20 | 76 | branch = self._createBranch({'marker.txt': marker_text}) | 76 | branch = self._createBranch({'marker.txt': marker_text}) |
21 | 77 | branch_url = branch.getPullURL() | ||
22 | 78 | 77 | ||
23 | 79 | generator = GenerateTranslationTemplates( | 78 | generator = GenerateTranslationTemplates( |
25 | 80 | branch_url, self.result_name, self.makeTemporaryDirectory()) | 79 | branch.getInternalBzrUrl(), self.result_name, |
26 | 80 | self.makeTemporaryDirectory()) | ||
27 | 81 | generator.branch_dir = self.makeTemporaryDirectory() | 81 | generator.branch_dir = self.makeTemporaryDirectory() |
28 | 82 | generator._getBranch() | 82 | generator._getBranch() |
29 | 83 | 83 | ||
30 | 84 | 84 | ||
31 | === added directory 'lib/canonical/launchpad/apidoc' | |||
32 | === modified file 'lib/canonical/launchpad/scripts/tests/test_garbo.py' | |||
33 | --- lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-14 13:14:00 +0000 | |||
34 | +++ lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-27 02:24:35 +0000 | |||
35 | @@ -448,7 +448,6 @@ | |||
36 | 448 | 448 | ||
37 | 449 | def test_BranchJobPruner(self): | 449 | def test_BranchJobPruner(self): |
38 | 450 | # Garbo should remove jobs completed over 30 days ago. | 450 | # Garbo should remove jobs completed over 30 days ago. |
39 | 451 | self.useBzrBranches() | ||
40 | 452 | LaunchpadZopelessLayer.switchDbUser('testadmin') | 451 | LaunchpadZopelessLayer.switchDbUser('testadmin') |
41 | 453 | store = IMasterStore(Job) | 452 | store = IMasterStore(Job) |
42 | 454 | 453 | ||
43 | @@ -478,7 +477,6 @@ | |||
44 | 478 | def test_BranchJobPruner_doesnt_prune_recent_jobs(self): | 477 | def test_BranchJobPruner_doesnt_prune_recent_jobs(self): |
45 | 479 | # Check to make sure the garbo doesn't remove jobs that aren't more | 478 | # Check to make sure the garbo doesn't remove jobs that aren't more |
46 | 480 | # than thirty days old. | 479 | # than thirty days old. |
47 | 481 | self.useBzrBranches() | ||
48 | 482 | LaunchpadZopelessLayer.switchDbUser('testadmin') | 480 | LaunchpadZopelessLayer.switchDbUser('testadmin') |
49 | 483 | store = IMasterStore(Job) | 481 | store = IMasterStore(Job) |
50 | 484 | 482 | ||
51 | 485 | 483 | ||
52 | === modified file 'lib/lp/code/configure.zcml' | |||
53 | --- lib/lp/code/configure.zcml 2010-04-27 02:24:30 +0000 | |||
54 | +++ lib/lp/code/configure.zcml 2010-04-27 02:24:35 +0000 | |||
55 | @@ -471,7 +471,6 @@ | |||
56 | 471 | last_scanned | 471 | last_scanned |
57 | 472 | last_scanned_id | 472 | last_scanned_id |
58 | 473 | revision_count | 473 | revision_count |
59 | 474 | warehouse_url | ||
60 | 475 | bug_branches | 474 | bug_branches |
61 | 476 | linked_bugs | 475 | linked_bugs |
62 | 477 | linkBug | 476 | linkBug |
63 | @@ -519,6 +518,7 @@ | |||
64 | 519 | getNotificationRecipients | 518 | getNotificationRecipients |
65 | 520 | getScannerData | 519 | getScannerData |
66 | 521 | getPullURL | 520 | getPullURL |
67 | 521 | getInternalBzrUrl | ||
68 | 522 | getBzrBranch | 522 | getBzrBranch |
69 | 523 | requestMirror | 523 | requestMirror |
70 | 524 | startMirroring | 524 | startMirroring |
71 | 525 | 525 | ||
72 | === modified file 'lib/lp/code/interfaces/branch.py' | |||
73 | --- lib/lp/code/interfaces/branch.py 2010-04-27 02:24:30 +0000 | |||
74 | +++ lib/lp/code/interfaces/branch.py 2010-04-27 02:24:35 +0000 | |||
75 | @@ -596,12 +596,6 @@ | |||
76 | 596 | 596 | ||
77 | 597 | stacked_on = Attribute('Stacked-on branch') | 597 | stacked_on = Attribute('Stacked-on branch') |
78 | 598 | 598 | ||
79 | 599 | warehouse_url = Attribute( | ||
80 | 600 | "URL for accessing the branch by ID. " | ||
81 | 601 | "This is for in-datacentre services only and allows such services to " | ||
82 | 602 | "be unaffected during branch renames. " | ||
83 | 603 | "See doc/bazaar for more information about the branch warehouse.") | ||
84 | 604 | |||
85 | 605 | # Bug attributes | 599 | # Bug attributes |
86 | 606 | bug_branches = CollectionField( | 600 | bug_branches = CollectionField( |
87 | 607 | title=_("The bug-branch link objects that link this branch " | 601 | title=_("The bug-branch link objects that link this branch " |
88 | @@ -1076,7 +1070,15 @@ | |||
89 | 1076 | the corresponding BranchRevision rows for this branch. | 1070 | the corresponding BranchRevision rows for this branch. |
90 | 1077 | """ | 1071 | """ |
91 | 1078 | 1072 | ||
93 | 1079 | def getBzrBranch(self): | 1073 | def getInternalBzrUrl(): |
94 | 1074 | """Get the internal URL for this branch. | ||
95 | 1075 | |||
96 | 1076 | It's generally better to use `getBzrBranch` to open the branch | ||
97 | 1077 | directly, as that method is safe against the branch unexpectedly being | ||
98 | 1078 | a branch reference or stacked on something mischievous. | ||
99 | 1079 | """ | ||
100 | 1080 | |||
101 | 1081 | def getBzrBranch(): | ||
102 | 1080 | """Return the BzrBranch for this database Branch. | 1082 | """Return the BzrBranch for this database Branch. |
103 | 1081 | 1083 | ||
104 | 1082 | You can only call this if a server returned by `get_ro_server` or | 1084 | You can only call this if a server returned by `get_ro_server` or |
105 | 1083 | 1085 | ||
106 | === modified file 'lib/lp/code/interfaces/branchtarget.py' | |||
107 | --- lib/lp/code/interfaces/branchtarget.py 2010-04-13 11:05:58 +0000 | |||
108 | +++ lib/lp/code/interfaces/branchtarget.py 2010-04-27 02:24:35 +0000 | |||
109 | @@ -34,7 +34,9 @@ | |||
110 | 34 | Branches that are *not* suitable include: | 34 | Branches that are *not* suitable include: |
111 | 35 | - remote branches | 35 | - remote branches |
112 | 36 | - branches the user cannot see | 36 | - branches the user cannot see |
114 | 37 | - branches that have not yet been successfully processed by the puller. | 37 | - branches that have no last revision information set (hosted branches |
115 | 38 | where a push hasn't completed or a mirrored branch that hasn't been | ||
116 | 39 | mirrored, etc). | ||
117 | 38 | 40 | ||
118 | 39 | If the given branch is not suitable, return None. For convenience, also | 41 | If the given branch is not suitable, return None. For convenience, also |
119 | 40 | returns None if passed None. Otherwise, return the branch. | 42 | returns None if passed None. Otherwise, return the branch. |
120 | @@ -47,7 +49,7 @@ | |||
121 | 47 | return None | 49 | return None |
122 | 48 | if branch_type == BranchType.REMOTE: | 50 | if branch_type == BranchType.REMOTE: |
123 | 49 | return None | 51 | return None |
125 | 50 | if branch.last_mirrored is None: | 52 | if branch.last_mirrored_id is None: |
126 | 51 | return None | 53 | return None |
127 | 52 | return branch | 54 | return branch |
128 | 53 | 55 | ||
129 | 54 | 56 | ||
130 | === modified file 'lib/lp/code/mail/codehandler.py' | |||
131 | --- lib/lp/code/mail/codehandler.py 2010-03-18 20:53:36 +0000 | |||
132 | +++ lib/lp/code/mail/codehandler.py 2010-04-27 02:24:35 +0000 | |||
133 | @@ -21,7 +21,6 @@ | |||
134 | 21 | 21 | ||
135 | 22 | from zope.component import getUtility | 22 | from zope.component import getUtility |
136 | 23 | from zope.interface import implements | 23 | from zope.interface import implements |
137 | 24 | from zope.security.proxy import removeSecurityProxy | ||
138 | 25 | 24 | ||
139 | 26 | from lp.codehosting.bzrutils import is_branch_stackable | 25 | from lp.codehosting.bzrutils import is_branch_stackable |
140 | 27 | from lp.codehosting.vfs import get_lp_server | 26 | from lp.codehosting.vfs import get_lp_server |
141 | @@ -495,7 +494,7 @@ | |||
142 | 495 | # source branch - one that has *no* Bazaar data. Together these | 494 | # source branch - one that has *no* Bazaar data. Together these |
143 | 496 | # prevent users from using Launchpad disk space at a rate that is | 495 | # prevent users from using Launchpad disk space at a rate that is |
144 | 497 | # disproportionately greater than data uploaded. | 496 | # disproportionately greater than data uploaded. |
146 | 498 | mirrored_bzr_target = removeSecurityProxy(db_target).getBzrBranch() | 497 | mirrored_bzr_target = db_target.getBzrBranch() |
147 | 499 | if not is_branch_stackable(mirrored_bzr_target): | 498 | if not is_branch_stackable(mirrored_bzr_target): |
148 | 500 | return db_source | 499 | return db_source |
149 | 501 | assert db_source.branch_type == BranchType.HOSTED, ( | 500 | assert db_source.branch_type == BranchType.HOSTED, ( |
150 | 502 | 501 | ||
151 | === modified file 'lib/lp/code/mail/tests/test_codehandler.py' | |||
152 | --- lib/lp/code/mail/tests/test_codehandler.py 2010-04-27 02:24:30 +0000 | |||
153 | +++ lib/lp/code/mail/tests/test_codehandler.py 2010-04-27 02:24:35 +0000 | |||
154 | @@ -848,13 +848,6 @@ | |||
155 | 848 | transaction.commit() | 848 | transaction.commit() |
156 | 849 | LaunchpadZopelessLayer.switchDbUser(user) | 849 | LaunchpadZopelessLayer.switchDbUser(user) |
157 | 850 | 850 | ||
158 | 851 | def _mirror(self, db_branch, bzr_branch): | ||
159 | 852 | # Ensure the directories containing the mirror branch exist. | ||
160 | 853 | transport = get_transport(db_branch.warehouse_url) | ||
161 | 854 | lp_mirror = BzrDir.create_branch_convenience(db_branch.warehouse_url) | ||
162 | 855 | self.addCleanup(transport.delete_tree, '.') | ||
163 | 856 | lp_mirror.pull(bzr_branch) | ||
164 | 857 | |||
165 | 858 | def _createTargetSourceAndBundle(self, format=None): | 851 | def _createTargetSourceAndBundle(self, format=None): |
166 | 859 | """Create a merge directive with a bundle and associated branches. | 852 | """Create a merge directive with a bundle and associated branches. |
167 | 860 | 853 | ||
168 | @@ -909,7 +902,7 @@ | |||
169 | 909 | # branch that is created is an empty hosted branch. The new branch | 902 | # branch that is created is an empty hosted branch. The new branch |
170 | 910 | # will not have a mirror requested as there are no revisions, and | 903 | # will not have a mirror requested as there are no revisions, and |
171 | 911 | # there is no branch created in the hosted area. | 904 | # there is no branch created in the hosted area. |
173 | 912 | self.useBzrBranches(real_server=True) | 905 | self.useBzrBranches() |
174 | 913 | branch, source, message = self._createTargetSourceAndBundle( | 906 | branch, source, message = self._createTargetSourceAndBundle( |
175 | 914 | format="pack-0.92") | 907 | format="pack-0.92") |
176 | 915 | bmp = self._processMergeDirective(message) | 908 | bmp = self._processMergeDirective(message) |
177 | @@ -921,7 +914,7 @@ | |||
178 | 921 | # mirrored, the source branch that is created is an empty hosted | 914 | # mirrored, the source branch that is created is an empty hosted |
179 | 922 | # branch. The new branch will not have a mirror requested as there | 915 | # branch. The new branch will not have a mirror requested as there |
180 | 923 | # are no revisions, and there is no branch created in the hosted area. | 916 | # are no revisions, and there is no branch created in the hosted area. |
182 | 924 | self.useBzrBranches(real_server=True) | 917 | self.useBzrBranches() |
183 | 925 | branch, source, message = self._createTargetSourceAndBundle( | 918 | branch, source, message = self._createTargetSourceAndBundle( |
184 | 926 | format="1.9") | 919 | format="1.9") |
185 | 927 | # Mark the target branch as "unmirrored", at least as far as the db is | 920 | # Mark the target branch as "unmirrored", at least as far as the db is |
186 | @@ -936,7 +929,7 @@ | |||
187 | 936 | # branch that is created is a hosted branch stacked on the target | 929 | # branch that is created is a hosted branch stacked on the target |
188 | 937 | # branch. The source branch will have the revisions from the bundle, | 930 | # branch. The source branch will have the revisions from the bundle, |
189 | 938 | # and a mirror will have been triggered. | 931 | # and a mirror will have been triggered. |
191 | 939 | self.useBzrBranches(real_server=True) | 932 | self.useBzrBranches() |
192 | 940 | branch, source, message = self._createTargetSourceAndBundle( | 933 | branch, source, message = self._createTargetSourceAndBundle( |
193 | 941 | format="1.9") | 934 | format="1.9") |
194 | 942 | bmp = self._processMergeDirective(message) | 935 | bmp = self._processMergeDirective(message) |
195 | @@ -946,24 +939,10 @@ | |||
196 | 946 | self.assertEqual( | 939 | self.assertEqual( |
197 | 947 | source.last_revision(), source_bzr_branch.last_revision()) | 940 | source.last_revision(), source_bzr_branch.last_revision()) |
198 | 948 | 941 | ||
199 | 949 | def test_correct_area(self): | ||
200 | 950 | # When a branch is created for a merge directive, it is created in the | ||
201 | 951 | # hosted area (getPullURL) not the mirrored area (warehouse_url). | ||
202 | 952 | self.useBzrBranches(real_server=True) | ||
203 | 953 | branch, source, message = self._createTargetSourceAndBundle( | ||
204 | 954 | format="1.9") | ||
205 | 955 | bmp = self._processMergeDirective(message) | ||
206 | 956 | # The hosted location should be populated (open succeeds). | ||
207 | 957 | self._openBazaarBranchAsClient(bmp.source_branch) | ||
208 | 958 | # Not the mirror (open raises). | ||
209 | 959 | self.assertRaises( | ||
210 | 960 | bzr_errors.NotBranchError, Branch.open, | ||
211 | 961 | bmp.source_branch.warehouse_url) | ||
212 | 962 | |||
213 | 963 | def test_branch_stacked(self): | 942 | def test_branch_stacked(self): |
214 | 964 | # When a branch is created for a merge directive, it is created | 943 | # When a branch is created for a merge directive, it is created |
215 | 965 | # stacked on the target branch. | 944 | # stacked on the target branch. |
217 | 966 | self.useBzrBranches(real_server=True) | 945 | self.useBzrBranches() |
218 | 967 | branch, source, message = self._createTargetSourceAndBundle( | 946 | branch, source, message = self._createTargetSourceAndBundle( |
219 | 968 | format="1.9") | 947 | format="1.9") |
220 | 969 | bmp = self._processMergeDirective(message) | 948 | bmp = self._processMergeDirective(message) |
221 | @@ -983,7 +962,7 @@ | |||
222 | 983 | def test_source_not_newer(self): | 962 | def test_source_not_newer(self): |
223 | 984 | # The source branch is created correctly when the source is not newer | 963 | # The source branch is created correctly when the source is not newer |
224 | 985 | # than the target, instead of raising DivergedBranches. | 964 | # than the target, instead of raising DivergedBranches. |
226 | 986 | self.useBzrBranches(real_server=True) | 965 | self.useBzrBranches() |
227 | 987 | branch, source, message = self._createTargetSourceAndBundle( | 966 | branch, source, message = self._createTargetSourceAndBundle( |
228 | 988 | format="1.9") | 967 | format="1.9") |
229 | 989 | target_tree = WorkingTree.open('.') | 968 | target_tree = WorkingTree.open('.') |
230 | @@ -998,20 +977,16 @@ | |||
231 | 998 | db_target_branch, target_tree = self.create_branch_and_tree( | 977 | db_target_branch, target_tree = self.create_branch_and_tree( |
232 | 999 | 'target', format=target_format) | 978 | 'target', format=target_format) |
233 | 1000 | target_tree.branch.set_public_branch(db_target_branch.bzr_identity) | 979 | target_tree.branch.set_public_branch(db_target_branch.bzr_identity) |
237 | 1001 | target_tree.commit('rev1') | 980 | revid = target_tree.commit('rev1') |
235 | 1002 | # Make sure that the created branch has been mirrored. | ||
236 | 1003 | db_target_branch.startMirroring() | ||
238 | 1004 | removeSecurityProxy(db_target_branch).branchChanged( | 981 | removeSecurityProxy(db_target_branch).branchChanged( |
240 | 1005 | '', 'rev1', None, None, None) | 982 | '', revid, None, None, None) |
241 | 1006 | 983 | ||
242 | 1007 | db_source_branch, source_tree = self.create_branch_and_tree( | 984 | db_source_branch, source_tree = self.create_branch_and_tree( |
245 | 1008 | 'lpsource', db_target_branch.product, hosted=True, | 985 | 'lpsource', db_target_branch.product, format=source_format) |
244 | 1009 | format=source_format) | ||
246 | 1010 | # The branch is not scheduled to be mirrorred. | 986 | # The branch is not scheduled to be mirrorred. |
247 | 1011 | self.assertIs(db_source_branch.next_mirror_time, None) | 987 | self.assertIs(db_source_branch.next_mirror_time, None) |
248 | 1012 | source_tree.pull(target_tree.branch) | 988 | source_tree.pull(target_tree.branch) |
249 | 1013 | source_tree.commit('rev2', rev_id='rev2') | 989 | source_tree.commit('rev2', rev_id='rev2') |
250 | 1014 | self._mirror(db_source_branch, source_tree.branch) | ||
251 | 1015 | # bundle_tree is effectively behaving like a local copy of | 990 | # bundle_tree is effectively behaving like a local copy of |
252 | 1016 | # db_source_branch, and is used to create the merge directive. | 991 | # db_source_branch, and is used to create the merge directive. |
253 | 1017 | bundle_tree = source_tree.bzrdir.sprout('source').open_workingtree() | 992 | bundle_tree = source_tree.bzrdir.sprout('source').open_workingtree() |
254 | @@ -1030,41 +1005,34 @@ | |||
255 | 1030 | def test_existing_stacked_branch(self): | 1005 | def test_existing_stacked_branch(self): |
256 | 1031 | # A bundle can update an existing branch if they are both stackable, | 1006 | # A bundle can update an existing branch if they are both stackable, |
257 | 1032 | # and the source branch is stacked. | 1007 | # and the source branch is stacked. |
259 | 1033 | self.useBzrBranches(real_server=True) | 1008 | self.useBzrBranches() |
260 | 1034 | lp_source, message = self._createPreexistingSourceAndMessage( | 1009 | lp_source, message = self._createPreexistingSourceAndMessage( |
261 | 1035 | target_format="1.9", source_format="1.9", set_stacked=True) | 1010 | target_format="1.9", source_format="1.9", set_stacked=True) |
262 | 1036 | bmp = self._processMergeDirective(message) | 1011 | bmp = self._processMergeDirective(message) |
263 | 1037 | # The branch merge proposal should use the existing db branch. | 1012 | # The branch merge proposal should use the existing db branch. |
264 | 1038 | self.assertEqual(lp_source, bmp.source_branch) | 1013 | self.assertEqual(lp_source, bmp.source_branch) |
273 | 1039 | # Now the branch is now scheduled to be mirrorred. | 1014 | bzr_branch = self._openBazaarBranchAsClient(bmp.source_branch) |
274 | 1040 | self.assertIsNot(None, lp_source.next_mirror_time) | 1015 | # The branch has been updated. |
275 | 1041 | mirror = removeSecurityProxy(bmp.source_branch).getBzrBranch() | 1016 | self.assertEqual('rev3', bzr_branch.last_revision()) |
268 | 1042 | # The mirrored copy of the branch has not been updated. | ||
269 | 1043 | self.assertEqual('rev2', mirror.last_revision()) | ||
270 | 1044 | hosted = self._openBazaarBranchAsClient(bmp.source_branch) | ||
271 | 1045 | # The hosted copy of the branch has been updated. | ||
272 | 1046 | self.assertEqual('rev3', hosted.last_revision()) | ||
276 | 1047 | 1017 | ||
277 | 1048 | def test_existing_unstacked_branch(self): | 1018 | def test_existing_unstacked_branch(self): |
278 | 1049 | # Even if the source and target are stackable, if the source is not | 1019 | # Even if the source and target are stackable, if the source is not |
279 | 1050 | # stacked, we don't support stacking something that wasn't stacked | 1020 | # stacked, we don't support stacking something that wasn't stacked |
280 | 1051 | # before (yet). | 1021 | # before (yet). |
282 | 1052 | self.useBzrBranches(real_server=True) | 1022 | self.useBzrBranches() |
283 | 1053 | lp_source, message = self._createPreexistingSourceAndMessage( | 1023 | lp_source, message = self._createPreexistingSourceAndMessage( |
284 | 1054 | target_format="1.9", source_format="1.9") | 1024 | target_format="1.9", source_format="1.9") |
285 | 1055 | bmp = self._processMergeDirective(message) | 1025 | bmp = self._processMergeDirective(message) |
286 | 1056 | # The branch merge proposal should use the existing db branch. | 1026 | # The branch merge proposal should use the existing db branch. |
287 | 1057 | self.assertEqual(lp_source, bmp.source_branch) | 1027 | self.assertEqual(lp_source, bmp.source_branch) |
291 | 1058 | # Now the branch is not scheduled to be mirrorred. | 1028 | bzr_branch = self._openBazaarBranchAsClient(bmp.source_branch) |
289 | 1059 | self.assertIs(None, lp_source.next_mirror_time) | ||
290 | 1060 | hosted = self._openBazaarBranchAsClient(bmp.source_branch) | ||
292 | 1061 | # The hosted copy of the branch has not been updated. | 1029 | # The hosted copy of the branch has not been updated. |
294 | 1062 | self.assertEqual('rev2', hosted.last_revision()) | 1030 | self.assertEqual('rev2', bzr_branch.last_revision()) |
295 | 1063 | 1031 | ||
296 | 1064 | def test_existing_branch_nonstackable_target(self): | 1032 | def test_existing_branch_nonstackable_target(self): |
297 | 1065 | # If the target branch is not stackable, then we don't pull any | 1033 | # If the target branch is not stackable, then we don't pull any |
298 | 1066 | # revisions. | 1034 | # revisions. |
300 | 1067 | self.useBzrBranches(real_server=True) | 1035 | self.useBzrBranches() |
301 | 1068 | lp_source, message = self._createPreexistingSourceAndMessage( | 1036 | lp_source, message = self._createPreexistingSourceAndMessage( |
302 | 1069 | target_format="pack-0.92", source_format="1.9") | 1037 | target_format="pack-0.92", source_format="1.9") |
303 | 1070 | bmp = self._processMergeDirective(message) | 1038 | bmp = self._processMergeDirective(message) |
304 | @@ -1079,7 +1047,7 @@ | |||
305 | 1079 | def test_existing_branch_nonstackable_source(self): | 1047 | def test_existing_branch_nonstackable_source(self): |
306 | 1080 | # If the source branch is not stackable, then we don't pull any | 1048 | # If the source branch is not stackable, then we don't pull any |
307 | 1081 | # revisions. | 1049 | # revisions. |
309 | 1082 | self.useBzrBranches(real_server=True) | 1050 | self.useBzrBranches() |
310 | 1083 | lp_source, message = self._createPreexistingSourceAndMessage( | 1051 | lp_source, message = self._createPreexistingSourceAndMessage( |
311 | 1084 | target_format="1.9", source_format="pack-0.92") | 1052 | target_format="1.9", source_format="pack-0.92") |
312 | 1085 | bmp = self._processMergeDirective(message) | 1053 | bmp = self._processMergeDirective(message) |
313 | @@ -1093,7 +1061,7 @@ | |||
314 | 1093 | 1061 | ||
315 | 1094 | def test_forbidden_target(self): | 1062 | def test_forbidden_target(self): |
316 | 1095 | """Specifying a branch in a forbidden target generates email.""" | 1063 | """Specifying a branch in a forbidden target generates email.""" |
318 | 1096 | self.useBzrBranches(real_server=True) | 1064 | self.useBzrBranches() |
319 | 1097 | branch, source, message = self._createTargetSourceAndBundle( | 1065 | branch, source, message = self._createTargetSourceAndBundle( |
320 | 1098 | format="pack-0.92") | 1066 | format="pack-0.92") |
321 | 1099 | branch.product.setBranchVisibilityTeamPolicy( | 1067 | branch.product.setBranchVisibilityTeamPolicy( |
322 | 1100 | 1068 | ||
323 | === modified file 'lib/lp/code/model/branch.py' | |||
324 | --- lib/lp/code/model/branch.py 2010-04-27 02:24:30 +0000 | |||
325 | +++ lib/lp/code/model/branch.py 2010-04-27 02:24:35 +0000 | |||
326 | @@ -460,14 +460,13 @@ | |||
327 | 460 | "Private branch %s has no public URL." % self.unique_name) | 460 | "Private branch %s has no public URL." % self.unique_name) |
328 | 461 | return compose_public_url(scheme, self.unique_name) | 461 | return compose_public_url(scheme, self.unique_name) |
329 | 462 | 462 | ||
332 | 463 | @property | 463 | def getInternalBzrUrl(self): |
331 | 464 | def warehouse_url(self): | ||
333 | 465 | """See `IBranch`.""" | 464 | """See `IBranch`.""" |
335 | 466 | return 'lp-mirrored:///%s' % self.unique_name | 465 | return 'lp-internal:///' + self.unique_name |
336 | 467 | 466 | ||
337 | 468 | def getBzrBranch(self): | 467 | def getBzrBranch(self): |
338 | 469 | """See `IBranch`.""" | 468 | """See `IBranch`.""" |
340 | 470 | return safe_open('lp-internal', 'lp-internal:///' + self.unique_name) | 469 | return safe_open('lp-internal', self.getInternalBzrUrl()) |
341 | 471 | 470 | ||
342 | 472 | @property | 471 | @property |
343 | 473 | def displayname(self): | 472 | def displayname(self): |
344 | 474 | 473 | ||
345 | === modified file 'lib/lp/code/model/branchjob.py' | |||
346 | --- lib/lp/code/model/branchjob.py 2010-04-27 02:24:30 +0000 | |||
347 | +++ lib/lp/code/model/branchjob.py 2010-04-27 02:24:35 +0000 | |||
348 | @@ -51,8 +51,8 @@ | |||
349 | 51 | from lp.code.model.diff import StaticDiff | 51 | from lp.code.model.diff import StaticDiff |
350 | 52 | from lp.code.model.revision import RevisionSet | 52 | from lp.code.model.revision import RevisionSet |
351 | 53 | from lp.codehosting.scanner.bzrsync import BzrSync | 53 | from lp.codehosting.scanner.bzrsync import BzrSync |
354 | 54 | from lp.codehosting.vfs import (branch_id_to_path, get_multi_server, | 54 | from lp.codehosting.vfs import ( |
355 | 55 | get_scanner_server) | 55 | branch_id_to_path, get_rw_server, get_ro_server) |
356 | 56 | from lp.services.job.model.job import Job | 56 | from lp.services.job.model.job import Job |
357 | 57 | from lp.services.job.interfaces.job import JobStatus | 57 | from lp.services.job.interfaces.job import JobStatus |
358 | 58 | from lp.services.job.runner import BaseRunnableJob | 58 | from lp.services.job.runner import BaseRunnableJob |
359 | @@ -284,7 +284,7 @@ | |||
360 | 284 | def contextManager(cls): | 284 | def contextManager(cls): |
361 | 285 | """See `IBranchScanJobSource`.""" | 285 | """See `IBranchScanJobSource`.""" |
362 | 286 | errorlog.globalErrorUtility.configure('branchscanner') | 286 | errorlog.globalErrorUtility.configure('branchscanner') |
364 | 287 | cls.server = get_scanner_server() | 287 | cls.server = get_ro_server() |
365 | 288 | cls.server.start_server() | 288 | cls.server.start_server() |
366 | 289 | yield | 289 | yield |
367 | 290 | cls.server.stop_server() | 290 | cls.server.stop_server() |
368 | @@ -313,7 +313,7 @@ | |||
369 | 313 | def contextManager(): | 313 | def contextManager(): |
370 | 314 | """See `IBranchUpgradeJobSource`.""" | 314 | """See `IBranchUpgradeJobSource`.""" |
371 | 315 | errorlog.globalErrorUtility.configure('upgrade_branches') | 315 | errorlog.globalErrorUtility.configure('upgrade_branches') |
373 | 316 | server = get_multi_server(write_hosted=True) | 316 | server = get_rw_server() |
374 | 317 | server.start_server() | 317 | server.start_server() |
375 | 318 | yield | 318 | yield |
376 | 319 | server.stop_server() | 319 | server.stop_server() |
377 | @@ -325,7 +325,8 @@ | |||
378 | 325 | try: | 325 | try: |
379 | 326 | upgrade_transport = get_transport(upgrade_branch_path) | 326 | upgrade_transport = get_transport(upgrade_branch_path) |
380 | 327 | upgrade_transport.mkdir('.bzr') | 327 | upgrade_transport.mkdir('.bzr') |
382 | 328 | source_branch_transport = get_transport(self.branch.getPullURL()) | 328 | source_branch_transport = get_transport( |
383 | 329 | self.branch.getInternalBzrUrl()) | ||
384 | 329 | source_branch_transport.clone('.bzr').copy_tree_to_transport( | 330 | source_branch_transport.clone('.bzr').copy_tree_to_transport( |
385 | 330 | upgrade_transport.clone('.bzr')) | 331 | upgrade_transport.clone('.bzr')) |
386 | 331 | upgrade_branch = BzrBranch.open_from_transport(upgrade_transport) | 332 | upgrade_branch = BzrBranch.open_from_transport(upgrade_transport) |
387 | 332 | 333 | ||
388 | === modified file 'lib/lp/code/model/branchmergeproposaljob.py' | |||
389 | --- lib/lp/code/model/branchmergeproposaljob.py 2010-04-06 03:37:16 +0000 | |||
390 | +++ lib/lp/code/model/branchmergeproposaljob.py 2010-04-27 02:24:35 +0000 | |||
391 | @@ -69,7 +69,7 @@ | |||
392 | 69 | from lp.code.mail.codereviewcomment import CodeReviewCommentMailer | 69 | from lp.code.mail.codereviewcomment import CodeReviewCommentMailer |
393 | 70 | from lp.code.model.branchmergeproposal import BranchMergeProposal | 70 | from lp.code.model.branchmergeproposal import BranchMergeProposal |
394 | 71 | from lp.code.model.diff import PreviewDiff | 71 | from lp.code.model.diff import PreviewDiff |
396 | 72 | from lp.codehosting.vfs import get_multi_server, get_scanner_server | 72 | from lp.codehosting.vfs import get_ro_server, get_rw_server |
397 | 73 | from lp.registry.interfaces.person import IPersonSet | 73 | from lp.registry.interfaces.person import IPersonSet |
398 | 74 | from lp.services.job.model.job import Job | 74 | from lp.services.job.model.job import Job |
399 | 75 | from lp.services.job.interfaces.job import JobStatus | 75 | from lp.services.job.interfaces.job import JobStatus |
400 | @@ -322,7 +322,7 @@ | |||
401 | 322 | def contextManager(): | 322 | def contextManager(): |
402 | 323 | """See `IUpdatePreviewDiffJobSource`.""" | 323 | """See `IUpdatePreviewDiffJobSource`.""" |
403 | 324 | errorlog.globalErrorUtility.configure('update_preview_diffs') | 324 | errorlog.globalErrorUtility.configure('update_preview_diffs') |
405 | 325 | server = get_scanner_server() | 325 | server = get_ro_server() |
406 | 326 | server.start_server() | 326 | server.start_server() |
407 | 327 | yield | 327 | yield |
408 | 328 | server.stop_server() | 328 | server.stop_server() |
409 | @@ -403,7 +403,7 @@ | |||
410 | 403 | raise AssertionError('No principal found for %s' % email_addr) | 403 | raise AssertionError('No principal found for %s' % email_addr) |
411 | 404 | setupInteraction(principal, email_addr) | 404 | setupInteraction(principal, email_addr) |
412 | 405 | 405 | ||
414 | 406 | server = get_multi_server(write_hosted=True) | 406 | server = get_rw_server() |
415 | 407 | server.start_server() | 407 | server.start_server() |
416 | 408 | try: | 408 | try: |
417 | 409 | return CodeHandler().processMergeProposal(message) | 409 | return CodeHandler().processMergeProposal(message) |
418 | @@ -635,7 +635,7 @@ | |||
419 | 635 | def contextManager(): | 635 | def contextManager(): |
420 | 636 | """See `IJobSource`.""" | 636 | """See `IJobSource`.""" |
421 | 637 | errorlog.globalErrorUtility.configure('merge_proposal_jobs') | 637 | errorlog.globalErrorUtility.configure('merge_proposal_jobs') |
423 | 638 | server = get_scanner_server() | 638 | server = get_ro_server() |
424 | 639 | server.start_server() | 639 | server.start_server() |
425 | 640 | yield | 640 | yield |
426 | 641 | server.stop_server() | 641 | server.stop_server() |
427 | 642 | 642 | ||
428 | === modified file 'lib/lp/code/model/diff.py' | |||
429 | --- lib/lp/code/model/diff.py 2010-02-17 19:10:51 +0000 | |||
430 | +++ lib/lp/code/model/diff.py 2010-04-27 02:24:35 +0000 | |||
431 | @@ -322,16 +322,15 @@ | |||
432 | 322 | :param bmp: The `BranchMergeProposal` to generate a `PreviewDiff` for. | 322 | :param bmp: The `BranchMergeProposal` to generate a `PreviewDiff` for. |
433 | 323 | :return: A `PreviewDiff`. | 323 | :return: A `PreviewDiff`. |
434 | 324 | """ | 324 | """ |
436 | 325 | source_branch = Branch.open(bmp.source_branch.warehouse_url) | 325 | source_branch = bmp.source_branch.getBzrBranch() |
437 | 326 | source_revision = source_branch.last_revision() | 326 | source_revision = source_branch.last_revision() |
439 | 327 | target_branch = Branch.open(bmp.target_branch.warehouse_url) | 327 | target_branch = bmp.target_branch.getBzrBranch() |
440 | 328 | target_revision = target_branch.last_revision() | 328 | target_revision = target_branch.last_revision() |
441 | 329 | preview = cls() | 329 | preview = cls() |
442 | 330 | preview.source_revision_id = source_revision.decode('utf-8') | 330 | preview.source_revision_id = source_revision.decode('utf-8') |
443 | 331 | preview.target_revision_id = target_revision.decode('utf-8') | 331 | preview.target_revision_id = target_revision.decode('utf-8') |
444 | 332 | if bmp.prerequisite_branch is not None: | 332 | if bmp.prerequisite_branch is not None: |
447 | 333 | prerequisite_branch = Branch.open( | 333 | prerequisite_branch = bmp.prerequisite_branch.getBzrBranch() |
446 | 334 | bmp.prerequisite_branch.warehouse_url) | ||
448 | 335 | else: | 334 | else: |
449 | 336 | prerequisite_branch = None | 335 | prerequisite_branch = None |
450 | 337 | preview.diff, conflicts = Diff.mergePreviewFromBranches( | 336 | preview.diff, conflicts = Diff.mergePreviewFromBranches( |
451 | 338 | 337 | ||
452 | === modified file 'lib/lp/code/model/directbranchcommit.py' | |||
453 | --- lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:30 +0000 | |||
454 | +++ lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:35 +0000 | |||
455 | @@ -47,7 +47,7 @@ | |||
456 | 47 | is_locked = False | 47 | is_locked = False |
457 | 48 | commit_builder = None | 48 | commit_builder = None |
458 | 49 | 49 | ||
460 | 50 | def __init__(self, db_branch, committer=None): | 50 | def __init__(self, db_branch, committer=None, no_race_check=False): |
461 | 51 | """Create context for direct commit to branch. | 51 | """Create context for direct commit to branch. |
462 | 52 | 52 | ||
463 | 53 | Before constructing a `DirectBranchCommit`, set up a server that | 53 | Before constructing a `DirectBranchCommit`, set up a server that |
464 | @@ -66,6 +66,8 @@ | |||
465 | 66 | 66 | ||
466 | 67 | :param db_branch: a Launchpad `Branch` object. | 67 | :param db_branch: a Launchpad `Branch` object. |
467 | 68 | :param committer: the `Person` writing to the branch. | 68 | :param committer: the `Person` writing to the branch. |
468 | 69 | :param no_race_check: don't check for other commits before committing | ||
469 | 70 | our changes, for use in tests. | ||
470 | 69 | """ | 71 | """ |
471 | 70 | self.db_branch = db_branch | 72 | self.db_branch = db_branch |
472 | 71 | 73 | ||
473 | @@ -75,6 +77,8 @@ | |||
474 | 75 | committer = db_branch.owner | 77 | committer = db_branch.owner |
475 | 76 | self.committer = committer | 78 | self.committer = committer |
476 | 77 | 79 | ||
477 | 80 | self.no_race_check = no_race_check | ||
478 | 81 | |||
479 | 78 | # Directories we create on the branch, and their ids. | 82 | # Directories we create on the branch, and their ids. |
480 | 79 | self.path_ids = {} | 83 | self.path_ids = {} |
481 | 80 | 84 | ||
482 | @@ -155,6 +159,8 @@ | |||
483 | 155 | If it does, raise `ConcurrentUpdateError`. | 159 | If it does, raise `ConcurrentUpdateError`. |
484 | 156 | """ | 160 | """ |
485 | 157 | assert self.is_locked, "Getting revision on un-locked branch." | 161 | assert self.is_locked, "Getting revision on un-locked branch." |
486 | 162 | if self.no_race_check: | ||
487 | 163 | return | ||
488 | 158 | last_revision = self.bzrbranch.last_revision() | 164 | last_revision = self.bzrbranch.last_revision() |
489 | 159 | if last_revision != self.last_scanned_id: | 165 | if last_revision != self.last_scanned_id: |
490 | 160 | raise ConcurrentUpdateError( | 166 | raise ConcurrentUpdateError( |
491 | 161 | 167 | ||
492 | === modified file 'lib/lp/code/model/tests/test_branch.py' | |||
493 | --- lib/lp/code/model/tests/test_branch.py 2010-04-27 02:24:30 +0000 | |||
494 | +++ lib/lp/code/model/tests/test_branch.py 2010-04-27 02:24:35 +0000 | |||
495 | @@ -2370,7 +2370,7 @@ | |||
496 | 2370 | 2370 | ||
497 | 2371 | def setUp(self): | 2371 | def setUp(self): |
498 | 2372 | TestCaseWithFactory.setUp(self) | 2372 | TestCaseWithFactory.setUp(self) |
500 | 2373 | self.useBzrBranches(real_server=True, direct_database=True) | 2373 | self.useBzrBranches(direct_database=True) |
501 | 2374 | 2374 | ||
502 | 2375 | def test_simple(self): | 2375 | def test_simple(self): |
503 | 2376 | # safe_open returns the underlying bzr branch of a database branch in | 2376 | # safe_open returns the underlying bzr branch of a database branch in |
504 | 2377 | 2377 | ||
505 | === modified file 'lib/lp/code/model/tests/test_branchjob.py' | |||
506 | --- lib/lp/code/model/tests/test_branchjob.py 2010-04-27 02:24:30 +0000 | |||
507 | +++ lib/lp/code/model/tests/test_branchjob.py 2010-04-27 02:24:35 +0000 | |||
508 | @@ -100,7 +100,7 @@ | |||
509 | 100 | 100 | ||
510 | 101 | def test_run_revision_ids(self): | 101 | def test_run_revision_ids(self): |
511 | 102 | """Ensure that run calculates revision ids.""" | 102 | """Ensure that run calculates revision ids.""" |
513 | 103 | self.useBzrBranches() | 103 | self.useBzrBranches(direct_database=True) |
514 | 104 | branch, tree = self.create_branch_and_tree() | 104 | branch, tree = self.create_branch_and_tree() |
515 | 105 | tree.commit('First commit', rev_id='rev1') | 105 | tree.commit('First commit', rev_id='rev1') |
516 | 106 | job = BranchDiffJob.create(branch, '0', '1') | 106 | job = BranchDiffJob.create(branch, '0', '1') |
517 | @@ -110,7 +110,7 @@ | |||
518 | 110 | 110 | ||
519 | 111 | def test_run_diff_content(self): | 111 | def test_run_diff_content(self): |
520 | 112 | """Ensure that run generates expected diff.""" | 112 | """Ensure that run generates expected diff.""" |
522 | 113 | self.useBzrBranches() | 113 | self.useBzrBranches(direct_database=True) |
523 | 114 | 114 | ||
524 | 115 | tree_location = tempfile.mkdtemp() | 115 | tree_location = tempfile.mkdtemp() |
525 | 116 | self.addCleanup(lambda: shutil.rmtree(tree_location)) | 116 | self.addCleanup(lambda: shutil.rmtree(tree_location)) |
526 | @@ -134,7 +134,7 @@ | |||
527 | 134 | 134 | ||
528 | 135 | def test_run_is_idempotent(self): | 135 | def test_run_is_idempotent(self): |
529 | 136 | """Ensure running an equivalent job emits the same diff.""" | 136 | """Ensure running an equivalent job emits the same diff.""" |
531 | 137 | self.useBzrBranches() | 137 | self.useBzrBranches(direct_database=True) |
532 | 138 | branch, tree = self.create_branch_and_tree() | 138 | branch, tree = self.create_branch_and_tree() |
533 | 139 | tree.commit('First commit') | 139 | tree.commit('First commit') |
534 | 140 | job1 = BranchDiffJob.create(branch, '0', '1') | 140 | job1 = BranchDiffJob.create(branch, '0', '1') |
535 | @@ -149,7 +149,7 @@ | |||
536 | 149 | This diff contains an add of a file called hello.txt, with contents | 149 | This diff contains an add of a file called hello.txt, with contents |
537 | 150 | "Hello World\n". | 150 | "Hello World\n". |
538 | 151 | """ | 151 | """ |
540 | 152 | self.useBzrBranches() | 152 | self.useBzrBranches(direct_database=True) |
541 | 153 | branch, tree = self.create_branch_and_tree() | 153 | branch, tree = self.create_branch_and_tree() |
542 | 154 | first_revision = 'rev-1' | 154 | first_revision = 'rev-1' |
543 | 155 | tree_transport = tree.bzrdir.root_transport | 155 | tree_transport = tree.bzrdir.root_transport |
544 | @@ -197,7 +197,7 @@ | |||
545 | 197 | 197 | ||
546 | 198 | def test_run(self): | 198 | def test_run(self): |
547 | 199 | """Ensure the job scans the branch.""" | 199 | """Ensure the job scans the branch.""" |
549 | 200 | self.useBzrBranches() | 200 | self.useBzrBranches(direct_database=True) |
550 | 201 | 201 | ||
551 | 202 | db_branch, bzr_tree = self.create_branch_and_tree() | 202 | db_branch, bzr_tree = self.create_branch_and_tree() |
552 | 203 | bzr_tree.commit('First commit', rev_id='rev1') | 203 | bzr_tree.commit('First commit', rev_id='rev1') |
553 | @@ -249,9 +249,8 @@ | |||
554 | 249 | 249 | ||
555 | 250 | def test_upgrades_branch(self): | 250 | def test_upgrades_branch(self): |
556 | 251 | """Ensure that a branch with an outdated format is upgraded.""" | 251 | """Ensure that a branch with an outdated format is upgraded.""" |
560 | 252 | self.useBzrBranches() | 252 | self.useBzrBranches(direct_database=True) |
561 | 253 | db_branch, tree = self.create_branch_and_tree( | 253 | db_branch, tree = self.create_branch_and_tree(format='knit') |
559 | 254 | hosted=True, format='knit') | ||
562 | 255 | db_branch.branch_format = BranchFormat.BZR_BRANCH_5 | 254 | db_branch.branch_format = BranchFormat.BZR_BRANCH_5 |
563 | 256 | db_branch.repository_format = RepositoryFormat.BZR_KNIT_1 | 255 | db_branch.repository_format = RepositoryFormat.BZR_KNIT_1 |
564 | 257 | self.assertEqual( | 256 | self.assertEqual( |
565 | @@ -278,14 +277,13 @@ | |||
566 | 278 | def test_existing_bzr_backup(self): | 277 | def test_existing_bzr_backup(self): |
567 | 279 | # If the target branch already has a backup.bzr dir, the upgrade copy | 278 | # If the target branch already has a backup.bzr dir, the upgrade copy |
568 | 280 | # should remove it. | 279 | # should remove it. |
572 | 281 | self.useBzrBranches() | 280 | self.useBzrBranches(direct_database=True) |
573 | 282 | db_branch, tree = self.create_branch_and_tree( | 281 | db_branch, tree = self.create_branch_and_tree(format='knit') |
571 | 283 | hosted=True, format='knit') | ||
574 | 284 | db_branch.branch_format = BranchFormat.BZR_BRANCH_5 | 282 | db_branch.branch_format = BranchFormat.BZR_BRANCH_5 |
575 | 285 | db_branch.repository_format = RepositoryFormat.BZR_KNIT_1 | 283 | db_branch.repository_format = RepositoryFormat.BZR_KNIT_1 |
576 | 286 | 284 | ||
577 | 287 | # Add a fake backup.bzr dir | 285 | # Add a fake backup.bzr dir |
579 | 288 | source_branch_transport = get_transport(db_branch.getPullURL()) | 286 | source_branch_transport = get_transport(db_branch.getInternalBzrUrl()) |
580 | 289 | source_branch_transport.mkdir('backup.bzr') | 287 | source_branch_transport.mkdir('backup.bzr') |
581 | 290 | source_branch_transport.clone('.bzr').copy_tree_to_transport( | 288 | source_branch_transport.clone('.bzr').copy_tree_to_transport( |
582 | 291 | source_branch_transport.clone('backup.bzr')) | 289 | source_branch_transport.clone('backup.bzr')) |
583 | @@ -354,7 +352,7 @@ | |||
584 | 354 | 352 | ||
585 | 355 | def test_perform_diff_performs_diff(self): | 353 | def test_perform_diff_performs_diff(self): |
586 | 356 | """Ensure that a diff is generated when perform_diff is True.""" | 354 | """Ensure that a diff is generated when perform_diff is True.""" |
588 | 357 | self.useBzrBranches() | 355 | self.useBzrBranches(direct_database=True) |
589 | 358 | branch, tree = self.create_branch_and_tree() | 356 | branch, tree = self.create_branch_and_tree() |
590 | 359 | tree.bzrdir.root_transport.put_bytes('foo', 'bar\n') | 357 | tree.bzrdir.root_transport.put_bytes('foo', 'bar\n') |
591 | 360 | tree.add('foo') | 358 | tree.add('foo') |
592 | @@ -366,7 +364,7 @@ | |||
593 | 366 | 364 | ||
594 | 367 | def test_perform_diff_ignored_for_revno_0(self): | 365 | def test_perform_diff_ignored_for_revno_0(self): |
595 | 368 | """For the null revision, no diff is generated.""" | 366 | """For the null revision, no diff is generated.""" |
597 | 369 | self.useBzrBranches() | 367 | self.useBzrBranches(direct_database=True) |
598 | 370 | branch, tree = self.create_branch_and_tree() | 368 | branch, tree = self.create_branch_and_tree() |
599 | 371 | job = RevisionMailJob.create( | 369 | job = RevisionMailJob.create( |
600 | 372 | branch, 0, 'from@example.com', 'hello', True, 'subject') | 370 | branch, 0, 'from@example.com', 'hello', True, 'subject') |
601 | @@ -465,7 +463,7 @@ | |||
602 | 465 | 463 | ||
603 | 466 | def test_iterAddedMainline(self): | 464 | def test_iterAddedMainline(self): |
604 | 467 | """iterAddedMainline iterates through mainline revisions.""" | 465 | """iterAddedMainline iterates through mainline revisions.""" |
606 | 468 | self.useBzrBranches() | 466 | self.useBzrBranches(direct_database=True) |
607 | 469 | branch, tree = self.create3CommitsBranch() | 467 | branch, tree = self.create3CommitsBranch() |
608 | 470 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev2', '') | 468 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev2', '') |
609 | 471 | job.bzr_branch.lock_read() | 469 | job.bzr_branch.lock_read() |
610 | @@ -475,7 +473,7 @@ | |||
611 | 475 | 473 | ||
612 | 476 | def test_iterAddedNonMainline(self): | 474 | def test_iterAddedNonMainline(self): |
613 | 477 | """iterAddedMainline drops non-mainline revisions.""" | 475 | """iterAddedMainline drops non-mainline revisions.""" |
615 | 478 | self.useBzrBranches() | 476 | self.useBzrBranches(direct_database=True) |
616 | 479 | branch, tree = self.create3CommitsBranch() | 477 | branch, tree = self.create3CommitsBranch() |
617 | 480 | tree.pull(tree.branch, overwrite=True, stop_revision='rev2') | 478 | tree.pull(tree.branch, overwrite=True, stop_revision='rev2') |
618 | 481 | tree.add_parent_tree_id('rev3') | 479 | tree.add_parent_tree_id('rev3') |
619 | @@ -489,7 +487,7 @@ | |||
620 | 489 | 487 | ||
621 | 490 | def test_iterAddedMainline_order(self): | 488 | def test_iterAddedMainline_order(self): |
622 | 491 | """iterAddedMainline iterates in commit order.""" | 489 | """iterAddedMainline iterates in commit order.""" |
624 | 492 | self.useBzrBranches() | 490 | self.useBzrBranches(direct_database=True) |
625 | 493 | branch, tree = self.create3CommitsBranch() | 491 | branch, tree = self.create3CommitsBranch() |
626 | 494 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '') | 492 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '') |
627 | 495 | job.bzr_branch.lock_read() | 493 | job.bzr_branch.lock_read() |
628 | @@ -528,7 +526,7 @@ | |||
629 | 528 | that merges the others. | 526 | that merges the others. |
630 | 529 | :param include_ghost:If true, add revision 2c as a ghost revision. | 527 | :param include_ghost:If true, add revision 2c as a ghost revision. |
631 | 530 | """ | 528 | """ |
633 | 531 | self.useBzrBranches() | 529 | self.useBzrBranches(direct_database=True) |
634 | 532 | branch, tree = self.create_branch_and_tree() | 530 | branch, tree = self.create_branch_and_tree() |
635 | 533 | tree.branch.nick = 'nicholas' | 531 | tree.branch.nick = 'nicholas' |
636 | 534 | tree.commit('rev1') | 532 | tree.commit('rev1') |
637 | @@ -558,7 +556,7 @@ | |||
638 | 558 | 556 | ||
639 | 559 | def test_findRelatedBMP(self): | 557 | def test_findRelatedBMP(self): |
640 | 560 | """The related branch merge proposals can be identified.""" | 558 | """The related branch merge proposals can be identified.""" |
642 | 561 | self.useBzrBranches() | 559 | self.useBzrBranches(direct_database=True) |
643 | 562 | target_branch, tree = self.create_branch_and_tree('tree') | 560 | target_branch, tree = self.create_branch_and_tree('tree') |
644 | 563 | desired_proposal = self.factory.makeBranchMergeProposal( | 561 | desired_proposal = self.factory.makeBranchMergeProposal( |
645 | 564 | target_branch=target_branch) | 562 | target_branch=target_branch) |
646 | @@ -577,7 +575,7 @@ | |||
647 | 577 | """findRelatedBMP only returns the most recent proposal for any | 575 | """findRelatedBMP only returns the most recent proposal for any |
648 | 578 | particular source branch. | 576 | particular source branch. |
649 | 579 | """ | 577 | """ |
651 | 580 | self.useBzrBranches() | 578 | self.useBzrBranches(direct_database=True) |
652 | 581 | target_branch, tree = self.create_branch_and_tree('tree') | 579 | target_branch, tree = self.create_branch_and_tree('tree') |
653 | 582 | the_past = datetime.datetime(2009, 1, 1, tzinfo=pytz.UTC) | 580 | the_past = datetime.datetime(2009, 1, 1, tzinfo=pytz.UTC) |
654 | 583 | old_proposal = self.factory.makeBranchMergeProposal( | 581 | old_proposal = self.factory.makeBranchMergeProposal( |
655 | @@ -614,7 +612,7 @@ | |||
656 | 614 | 612 | ||
657 | 615 | def test_getRevisionMessage(self): | 613 | def test_getRevisionMessage(self): |
658 | 616 | """getRevisionMessage provides a correctly-formatted message.""" | 614 | """getRevisionMessage provides a correctly-formatted message.""" |
660 | 617 | self.useBzrBranches() | 615 | self.useBzrBranches(direct_database=True) |
661 | 618 | branch, tree = self.makeBranchWithCommit() | 616 | branch, tree = self.makeBranchWithCommit() |
662 | 619 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') | 617 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') |
663 | 620 | message = job.getRevisionMessage('rev1', 1) | 618 | message = job.getRevisionMessage('rev1', 1) |
664 | @@ -785,7 +783,7 @@ | |||
665 | 785 | 783 | ||
666 | 786 | def test_email_format(self): | 784 | def test_email_format(self): |
667 | 787 | """Contents of the email are as expected.""" | 785 | """Contents of the email are as expected.""" |
669 | 788 | self.useBzrBranches() | 786 | self.useBzrBranches(direct_database=True) |
670 | 789 | db_branch, tree = self.create_branch_and_tree() | 787 | db_branch, tree = self.create_branch_and_tree() |
671 | 790 | first_revision = 'rev-1' | 788 | first_revision = 'rev-1' |
672 | 791 | tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n') | 789 | tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n') |
673 | @@ -844,7 +842,7 @@ | |||
674 | 844 | 842 | ||
675 | 845 | def test_message_encoding(self): | 843 | def test_message_encoding(self): |
676 | 846 | """Test handling of non-ASCII commit messages.""" | 844 | """Test handling of non-ASCII commit messages.""" |
678 | 847 | self.useBzrBranches() | 845 | self.useBzrBranches(direct_database=True) |
679 | 848 | db_branch, tree = self.create_branch_and_tree() | 846 | db_branch, tree = self.create_branch_and_tree() |
680 | 849 | rev_id = 'rev-1' | 847 | rev_id = 'rev-1' |
681 | 850 | tree.commit( | 848 | tree.commit( |
682 | @@ -868,7 +866,7 @@ | |||
683 | 868 | 866 | ||
684 | 869 | def test_getMailerForRevision(self): | 867 | def test_getMailerForRevision(self): |
685 | 870 | """The mailer for the revision is as expected.""" | 868 | """The mailer for the revision is as expected.""" |
687 | 871 | self.useBzrBranches() | 869 | self.useBzrBranches(direct_database=True) |
688 | 872 | branch, tree = self.makeBranchWithCommit() | 870 | branch, tree = self.makeBranchWithCommit() |
689 | 873 | revision = tree.branch.repository.get_revision('rev1') | 871 | revision = tree.branch.repository.get_revision('rev1') |
690 | 874 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') | 872 | job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '') |
691 | @@ -881,7 +879,7 @@ | |||
692 | 881 | def test_only_nodiff_subscribers_means_no_diff_generated(self): | 879 | def test_only_nodiff_subscribers_means_no_diff_generated(self): |
693 | 882 | """No diff is generated when no subscribers need it.""" | 880 | """No diff is generated when no subscribers need it.""" |
694 | 883 | self.layer.switchDbUser('launchpad') | 881 | self.layer.switchDbUser('launchpad') |
696 | 884 | self.useBzrBranches() | 882 | self.useBzrBranches(direct_database=True) |
697 | 885 | branch, tree = self.create_branch_and_tree() | 883 | branch, tree = self.create_branch_and_tree() |
698 | 886 | subscriptions = branch.getSubscriptionsByLevel( | 884 | subscriptions = branch.getSubscriptionsByLevel( |
699 | 887 | [BranchSubscriptionNotificationLevel.FULL]) | 885 | [BranchSubscriptionNotificationLevel.FULL]) |
700 | @@ -911,7 +909,7 @@ | |||
701 | 911 | in which case an arbitrary unique string is used. | 909 | in which case an arbitrary unique string is used. |
702 | 912 | :returns: The revision of the first commit. | 910 | :returns: The revision of the first commit. |
703 | 913 | """ | 911 | """ |
705 | 914 | self.useBzrBranches() | 912 | self.useBzrBranches(direct_database=True) |
706 | 915 | self.branch, self.tree = self.create_branch_and_tree() | 913 | self.branch, self.tree = self.create_branch_and_tree() |
707 | 916 | return self._commitFilesToTree(files, 'First commit') | 914 | return self._commitFilesToTree(files, 'First commit') |
708 | 917 | 915 | ||
709 | 918 | 916 | ||
710 | === modified file 'lib/lp/code/model/tests/test_branchmergeproposaljobs.py' | |||
711 | --- lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-06 03:37:16 +0000 | |||
712 | +++ lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-27 02:24:35 +0000 | |||
713 | @@ -102,7 +102,7 @@ | |||
714 | 102 | 102 | ||
715 | 103 | def test_run_sends_email(self): | 103 | def test_run_sends_email(self): |
716 | 104 | """MergeProposalCreationJob.run sends an email.""" | 104 | """MergeProposalCreationJob.run sends an email.""" |
718 | 105 | self.useBzrBranches() | 105 | self.useBzrBranches(direct_database=True) |
719 | 106 | bmp = self.createProposalWithEmptyBranches() | 106 | bmp = self.createProposalWithEmptyBranches() |
720 | 107 | job = MergeProposalCreatedJob.create(bmp) | 107 | job = MergeProposalCreatedJob.create(bmp) |
721 | 108 | self.assertEqual([], pop_notifications()) | 108 | self.assertEqual([], pop_notifications()) |
722 | @@ -123,7 +123,7 @@ | |||
723 | 123 | 123 | ||
724 | 124 | def test_MergeProposalCreateJob_with_sourcepackage_branch(self): | 124 | def test_MergeProposalCreateJob_with_sourcepackage_branch(self): |
725 | 125 | """Jobs for merge proposals with sourcepackage branches work.""" | 125 | """Jobs for merge proposals with sourcepackage branches work.""" |
727 | 126 | self.useBzrBranches() | 126 | self.useBzrBranches(direct_database=True) |
728 | 127 | bmp = self.factory.makeBranchMergeProposal( | 127 | bmp = self.factory.makeBranchMergeProposal( |
729 | 128 | target_branch=self.factory.makePackageBranch()) | 128 | target_branch=self.factory.makePackageBranch()) |
730 | 129 | tree = self.create_branch_and_tree(db_branch=bmp.target_branch)[1] | 129 | tree = self.create_branch_and_tree(db_branch=bmp.target_branch)[1] |
731 | @@ -145,7 +145,7 @@ | |||
732 | 145 | verifyObject(IUpdatePreviewDiffJobSource, UpdatePreviewDiffJob) | 145 | verifyObject(IUpdatePreviewDiffJobSource, UpdatePreviewDiffJob) |
733 | 146 | 146 | ||
734 | 147 | def test_run(self): | 147 | def test_run(self): |
736 | 148 | self.useBzrBranches() | 148 | self.useBzrBranches(direct_database=True) |
737 | 149 | bmp = self.createExampleMerge()[0] | 149 | bmp = self.createExampleMerge()[0] |
738 | 150 | job = UpdatePreviewDiffJob.create(bmp) | 150 | job = UpdatePreviewDiffJob.create(bmp) |
739 | 151 | self.factory.makeRevisionsForBranch(bmp.source_branch, count=1) | 151 | self.factory.makeRevisionsForBranch(bmp.source_branch, count=1) |
740 | @@ -179,7 +179,7 @@ | |||
741 | 179 | email.get_payload(decode=True)) | 179 | email.get_payload(decode=True)) |
742 | 180 | 180 | ||
743 | 181 | def test_10_minute_lease(self): | 181 | def test_10_minute_lease(self): |
745 | 182 | self.useBzrBranches() | 182 | self.useBzrBranches(direct_database=True) |
746 | 183 | bmp = self.createExampleMerge()[0] | 183 | bmp = self.createExampleMerge()[0] |
747 | 184 | job = UpdatePreviewDiffJob.create(bmp) | 184 | job = UpdatePreviewDiffJob.create(bmp) |
748 | 185 | job.acquireLease() | 185 | job.acquireLease() |
749 | 186 | 186 | ||
750 | === modified file 'lib/lp/code/model/tests/test_diff.py' | |||
751 | --- lib/lp/code/model/tests/test_diff.py 2010-04-27 02:24:30 +0000 | |||
752 | +++ lib/lp/code/model/tests/test_diff.py 2010-04-27 02:24:35 +0000 | |||
753 | @@ -11,10 +11,12 @@ | |||
754 | 11 | import logging | 11 | import logging |
755 | 12 | from unittest import TestLoader | 12 | from unittest import TestLoader |
756 | 13 | 13 | ||
757 | 14 | from bzrlib.branch import Branch | ||
758 | 15 | from bzrlib import trace | 14 | from bzrlib import trace |
759 | 15 | |||
760 | 16 | import transaction | 16 | import transaction |
761 | 17 | 17 | ||
762 | 18 | from zope.security.proxy import removeSecurityProxy | ||
763 | 19 | |||
764 | 18 | from canonical.launchpad.interfaces.launchpad import NotFoundError | 20 | from canonical.launchpad.interfaces.launchpad import NotFoundError |
765 | 19 | from canonical.launchpad.webapp import canonical_url, errorlog | 21 | from canonical.launchpad.webapp import canonical_url, errorlog |
766 | 20 | from canonical.launchpad.webapp.testing import verifyObject | 22 | from canonical.launchpad.webapp.testing import verifyObject |
767 | @@ -44,7 +46,7 @@ | |||
768 | 44 | 46 | ||
769 | 45 | This will create or modify the file, as needed. | 47 | This will create or modify the file, as needed. |
770 | 46 | """ | 48 | """ |
772 | 47 | committer = DirectBranchCommit(branch) | 49 | committer = DirectBranchCommit(branch, no_race_check=True) |
773 | 48 | committer.writeFile(path, contents) | 50 | committer.writeFile(path, contents) |
774 | 49 | try: | 51 | try: |
775 | 50 | return committer.commit('committing') | 52 | return committer.commit('committing') |
776 | @@ -53,7 +55,7 @@ | |||
777 | 53 | 55 | ||
778 | 54 | def createExampleMerge(self): | 56 | def createExampleMerge(self): |
779 | 55 | """Create a merge proposal with conflicts and updates.""" | 57 | """Create a merge proposal with conflicts and updates.""" |
781 | 56 | self.useBzrBranches() | 58 | self.useBzrBranches(direct_database=True) |
782 | 57 | bmp = self.factory.makeBranchMergeProposal() | 59 | bmp = self.factory.makeBranchMergeProposal() |
783 | 58 | # Make the branches of the merge proposal look good as far as the | 60 | # Make the branches of the merge proposal look good as far as the |
784 | 59 | # model is concerned. | 61 | # model is concerned. |
785 | @@ -81,7 +83,7 @@ | |||
786 | 81 | 83 | ||
787 | 82 | def preparePrerequisiteMerge(self, bmp=None): | 84 | def preparePrerequisiteMerge(self, bmp=None): |
788 | 83 | """Prepare a merge scenario with a prerequisite branch.""" | 85 | """Prepare a merge scenario with a prerequisite branch.""" |
790 | 84 | self.useBzrBranches() | 86 | self.useBzrBranches(direct_database=True) |
791 | 85 | if bmp is None: | 87 | if bmp is None: |
792 | 86 | target = self.factory.makeBranch() | 88 | target = self.factory.makeBranch() |
793 | 87 | prerequisite = self.factory.makeBranch() | 89 | prerequisite = self.factory.makeBranch() |
794 | @@ -159,8 +161,8 @@ | |||
795 | 159 | def test_mergePreviewFromBranches(self): | 161 | def test_mergePreviewFromBranches(self): |
796 | 160 | # mergePreviewFromBranches generates the correct diff. | 162 | # mergePreviewFromBranches generates the correct diff. |
797 | 161 | bmp, source_rev_id, target_rev_id = self.createExampleMerge() | 163 | bmp, source_rev_id, target_rev_id = self.createExampleMerge() |
800 | 162 | source_branch = Branch.open(bmp.source_branch.warehouse_url) | 164 | source_branch = bmp.source_branch.getBzrBranch() |
801 | 163 | target_branch = Branch.open(bmp.target_branch.warehouse_url) | 165 | target_branch = bmp.target_branch.getBzrBranch() |
802 | 164 | diff, conflicts = Diff.mergePreviewFromBranches( | 166 | diff, conflicts = Diff.mergePreviewFromBranches( |
803 | 165 | source_branch, source_rev_id, target_branch) | 167 | source_branch, source_rev_id, target_branch) |
804 | 166 | transaction.commit() | 168 | transaction.commit() |
805 | @@ -280,7 +282,7 @@ | |||
806 | 280 | 282 | ||
807 | 281 | def test_acquire_existing(self): | 283 | def test_acquire_existing(self): |
808 | 282 | """Ensure that acquire returns the existing StaticDiff.""" | 284 | """Ensure that acquire returns the existing StaticDiff.""" |
810 | 283 | self.useBzrBranches() | 285 | self.useBzrBranches(direct_database=True) |
811 | 284 | branch, tree = self.create_branch_and_tree() | 286 | branch, tree = self.create_branch_and_tree() |
812 | 285 | tree.commit('First commit', rev_id='rev1') | 287 | tree.commit('First commit', rev_id='rev1') |
813 | 286 | diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository) | 288 | diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository) |
814 | @@ -289,7 +291,7 @@ | |||
815 | 289 | 291 | ||
816 | 290 | def test_acquire_existing_different_repo(self): | 292 | def test_acquire_existing_different_repo(self): |
817 | 291 | """The existing object is used even if the repository is different.""" | 293 | """The existing object is used even if the repository is different.""" |
819 | 292 | self.useBzrBranches() | 294 | self.useBzrBranches(direct_database=True) |
820 | 293 | branch1, tree1 = self.create_branch_and_tree('tree1') | 295 | branch1, tree1 = self.create_branch_and_tree('tree1') |
821 | 294 | tree1.commit('First commit', rev_id='rev1') | 296 | tree1.commit('First commit', rev_id='rev1') |
822 | 295 | branch2, tree2 = self.create_branch_and_tree('tree2') | 297 | branch2, tree2 = self.create_branch_and_tree('tree2') |
823 | @@ -300,7 +302,7 @@ | |||
824 | 300 | 302 | ||
825 | 301 | def test_acquire_nonexisting(self): | 303 | def test_acquire_nonexisting(self): |
826 | 302 | """A new object is created if there is no existant matching object.""" | 304 | """A new object is created if there is no existant matching object.""" |
828 | 303 | self.useBzrBranches() | 305 | self.useBzrBranches(direct_database=True) |
829 | 304 | branch, tree = self.create_branch_and_tree() | 306 | branch, tree = self.create_branch_and_tree() |
830 | 305 | tree.commit('First commit', rev_id='rev1') | 307 | tree.commit('First commit', rev_id='rev1') |
831 | 306 | tree.commit('Next commit', rev_id='rev2') | 308 | tree.commit('Next commit', rev_id='rev2') |
832 | @@ -428,7 +430,7 @@ | |||
833 | 428 | 430 | ||
834 | 429 | def test_fromPreviewDiff_with_no_conflicts(self): | 431 | def test_fromPreviewDiff_with_no_conflicts(self): |
835 | 430 | """Test fromPreviewDiff when no conflicts are present.""" | 432 | """Test fromPreviewDiff when no conflicts are present.""" |
837 | 431 | self.useBzrBranches() | 433 | self.useBzrBranches(direct_database=True) |
838 | 432 | bmp = self.factory.makeBranchMergeProposal() | 434 | bmp = self.factory.makeBranchMergeProposal() |
839 | 433 | bzr_target = self.createBzrBranch(bmp.target_branch) | 435 | bzr_target = self.createBzrBranch(bmp.target_branch) |
840 | 434 | self.commitFile(bmp.target_branch, 'foo', 'a\n') | 436 | self.commitFile(bmp.target_branch, 'foo', 'a\n') |
841 | 435 | 437 | ||
842 | === modified file 'lib/lp/code/scripts/tests/test_create_merge_proposals.py' | |||
843 | --- lib/lp/code/scripts/tests/test_create_merge_proposals.py 2010-04-01 05:08:47 +0000 | |||
844 | +++ lib/lp/code/scripts/tests/test_create_merge_proposals.py 2010-04-27 02:24:35 +0000 | |||
845 | @@ -70,22 +70,16 @@ | |||
846 | 70 | 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n' | 70 | 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n' |
847 | 71 | 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr) | 71 | 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr) |
848 | 72 | self.assertEqual('', stdout) | 72 | self.assertEqual('', stdout) |
849 | 73 | # The hosted location should be populated, not the mirror. | ||
850 | 74 | bmp = branch.landing_candidates[0] | 73 | bmp = branch.landing_candidates[0] |
856 | 75 | self.assertRaises( | 74 | local_source = bmp.source_branch.getBzrBranch() |
857 | 76 | bzr_errors.NotBranchError, Branch.open, | 75 | # The branch has the correct last revision. |
853 | 77 | bmp.source_branch.warehouse_url) | ||
854 | 78 | local_source = Branch.open(bmp.source_branch.getPullURL()) | ||
855 | 79 | # The hosted branch has the correct last revision. | ||
858 | 80 | self.assertEqual( | 76 | self.assertEqual( |
859 | 81 | source.branch.last_revision(), local_source.last_revision()) | 77 | source.branch.last_revision(), local_source.last_revision()) |
860 | 82 | # A mirror should be scheduled. | ||
861 | 83 | self.assertIsNot(None, bmp.source_branch.next_mirror_time) | ||
862 | 84 | 78 | ||
863 | 85 | def disabled_test_merge_directive_with_bundle(self): | 79 | def disabled_test_merge_directive_with_bundle(self): |
864 | 86 | """Merge directives with bundles generate branches.""" | 80 | """Merge directives with bundles generate branches.""" |
865 | 87 | # XXX TimPenhey 2009-04-01 bug 352800 | 81 | # XXX TimPenhey 2009-04-01 bug 352800 |
867 | 88 | self.useBzrBranches(real_server=True) | 82 | self.useBzrBranches() |
868 | 89 | branch, tree = self.create_branch_and_tree() | 83 | branch, tree = self.create_branch_and_tree() |
869 | 90 | source = self.createJob(branch, tree) | 84 | source = self.createJob(branch, tree) |
870 | 91 | self.jobOutputCheck(branch, source) | 85 | self.jobOutputCheck(branch, source) |
871 | @@ -93,7 +87,7 @@ | |||
872 | 93 | def disabled_test_merge_directive_with_project(self): | 87 | def disabled_test_merge_directive_with_project(self): |
873 | 94 | """Bundles are handled when the target branch has a project.""" | 88 | """Bundles are handled when the target branch has a project.""" |
874 | 95 | # XXX TimPenhey 2009-04-01 bug 352800 | 89 | # XXX TimPenhey 2009-04-01 bug 352800 |
876 | 96 | self.useBzrBranches(real_server=True) | 90 | self.useBzrBranches() |
877 | 97 | product = self.factory.makeProduct(project=self.factory.makeProject()) | 91 | product = self.factory.makeProduct(project=self.factory.makeProject()) |
878 | 98 | branch, tree = self.create_branch_and_tree(product=product) | 92 | branch, tree = self.create_branch_and_tree(product=product) |
879 | 99 | source = self.createJob(branch, tree) | 93 | source = self.createJob(branch, tree) |
880 | 100 | 94 | ||
881 | === modified file 'lib/lp/code/scripts/tests/test_scan_branches.py' | |||
882 | --- lib/lp/code/scripts/tests/test_scan_branches.py 2010-04-01 04:29:46 +0000 | |||
883 | +++ lib/lp/code/scripts/tests/test_scan_branches.py 2010-04-27 02:24:35 +0000 | |||
884 | @@ -26,8 +26,7 @@ | |||
885 | 26 | 26 | ||
886 | 27 | def make_branch_with_commits_and_scan_job(self, db_branch): | 27 | def make_branch_with_commits_and_scan_job(self, db_branch): |
887 | 28 | """Create a branch from a db_branch, make commits and a scan job.""" | 28 | """Create a branch from a db_branch, make commits and a scan job.""" |
890 | 29 | target, target_tree = self.create_branch_and_tree( | 29 | target, target_tree = self.create_branch_and_tree(db_branch=db_branch) |
889 | 30 | db_branch=db_branch) | ||
891 | 31 | target_tree.commit('First commit', rev_id='rev1') | 30 | target_tree.commit('First commit', rev_id='rev1') |
892 | 32 | target_tree.commit('Second commit', rev_id='rev2') | 31 | target_tree.commit('Second commit', rev_id='rev2') |
893 | 33 | target_tree.commit('Third commit', rev_id='rev3') | 32 | target_tree.commit('Third commit', rev_id='rev3') |
894 | @@ -45,7 +44,7 @@ | |||
895 | 45 | 44 | ||
896 | 46 | def test_scan_branch(self): | 45 | def test_scan_branch(self): |
897 | 47 | """Test that scan branches adds revisions to the database.""" | 46 | """Test that scan branches adds revisions to the database.""" |
899 | 48 | self.useBzrBranches(real_server=True) | 47 | self.useBzrBranches() |
900 | 49 | 48 | ||
901 | 50 | db_branch = self.factory.makeAnyBranch() | 49 | db_branch = self.factory.makeAnyBranch() |
902 | 51 | self.make_branch_with_commits_and_scan_job(db_branch) | 50 | self.make_branch_with_commits_and_scan_job(db_branch) |
903 | @@ -70,7 +69,7 @@ | |||
904 | 70 | 69 | ||
905 | 71 | def test_scan_packagebranch(self): | 70 | def test_scan_packagebranch(self): |
906 | 72 | """Test that scan_branches can scan package branches.""" | 71 | """Test that scan_branches can scan package branches.""" |
908 | 73 | self.useBzrBranches(real_server=True) | 72 | self.useBzrBranches() |
909 | 74 | 73 | ||
910 | 75 | db_branch = self.factory.makePackageBranch() | 74 | db_branch = self.factory.makePackageBranch() |
911 | 76 | self.make_branch_with_commits_and_scan_job(db_branch) | 75 | self.make_branch_with_commits_and_scan_job(db_branch) |
912 | 77 | 76 | ||
913 | === modified file 'lib/lp/code/scripts/tests/test_upgrade_branches.py' | |||
914 | --- lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-04-01 04:37:30 +0000 | |||
915 | +++ lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-04-27 02:24:35 +0000 | |||
916 | @@ -22,9 +22,8 @@ | |||
917 | 22 | 22 | ||
918 | 23 | def test_upgrade_branches(self): | 23 | def test_upgrade_branches(self): |
919 | 24 | """Test that upgrade_branches upgrades branches.""" | 24 | """Test that upgrade_branches upgrades branches.""" |
923 | 25 | self.useBzrBranches(real_server=True) | 25 | self.useBzrBranches() |
924 | 26 | target, target_tree = self.create_branch_and_tree( | 26 | target, target_tree = self.create_branch_and_tree(format='knit') |
922 | 27 | hosted=True, format='knit') | ||
925 | 28 | target.branch_format = BranchFormat.BZR_BRANCH_5 | 27 | target.branch_format = BranchFormat.BZR_BRANCH_5 |
926 | 29 | target.repository_format = RepositoryFormat.BZR_KNIT_1 | 28 | target.repository_format = RepositoryFormat.BZR_KNIT_1 |
927 | 30 | 29 | ||
928 | @@ -49,10 +48,10 @@ | |||
929 | 49 | 48 | ||
930 | 50 | def test_upgrade_branches_packagebranch(self): | 49 | def test_upgrade_branches_packagebranch(self): |
931 | 51 | """Test that upgrade_branches can upgrade package branches.""" | 50 | """Test that upgrade_branches can upgrade package branches.""" |
933 | 52 | self.useBzrBranches(real_server=True) | 51 | self.useBzrBranches() |
934 | 53 | package_branch = self.factory.makePackageBranch() | 52 | package_branch = self.factory.makePackageBranch() |
935 | 54 | target, target_tree = self.create_branch_and_tree( | 53 | target, target_tree = self.create_branch_and_tree( |
937 | 55 | db_branch=package_branch, hosted=True, format='knit') | 54 | db_branch=package_branch, format='knit') |
938 | 56 | target.branch_format = BranchFormat.BZR_BRANCH_5 | 55 | target.branch_format = BranchFormat.BZR_BRANCH_5 |
939 | 57 | target.repository_format = RepositoryFormat.BZR_KNIT_1 | 56 | target.repository_format = RepositoryFormat.BZR_KNIT_1 |
940 | 58 | 57 | ||
941 | 59 | 58 | ||
942 | === modified file 'lib/lp/codehosting/inmemory.py' | |||
943 | --- lib/lp/codehosting/inmemory.py 2010-04-27 02:24:30 +0000 | |||
944 | +++ lib/lp/codehosting/inmemory.py 2010-04-27 02:24:35 +0000 | |||
945 | @@ -433,7 +433,7 @@ | |||
946 | 433 | if branch is None: | 433 | if branch is None: |
947 | 434 | branch = self.makeBranch(product=product) | 434 | branch = self.makeBranch(product=product) |
948 | 435 | product.development_focus.branch = branch | 435 | product.development_focus.branch = branch |
950 | 436 | branch.last_mirrored = 'rev1' | 436 | branch.last_mirrored_id = 'rev1' |
951 | 437 | return branch | 437 | return branch |
952 | 438 | 438 | ||
953 | 439 | def enableDefaultStackingForPackage(self, package, branch): | 439 | def enableDefaultStackingForPackage(self, package, branch): |
954 | @@ -445,7 +445,7 @@ | |||
955 | 445 | """ | 445 | """ |
956 | 446 | package.development_version.setBranch( | 446 | package.development_version.setBranch( |
957 | 447 | PackagePublishingPocket.RELEASE, branch, branch.owner) | 447 | PackagePublishingPocket.RELEASE, branch, branch.owner) |
959 | 448 | branch.last_mirrored = 'rev1' | 448 | branch.last_mirrored_id = 'rev1' |
960 | 449 | return branch | 449 | return branch |
961 | 450 | 450 | ||
962 | 451 | 451 | ||
963 | 452 | 452 | ||
964 | === modified file 'lib/lp/codehosting/scanner/bzrsync.py' | |||
965 | --- lib/lp/codehosting/scanner/bzrsync.py 2010-04-27 02:24:30 +0000 | |||
966 | +++ lib/lp/codehosting/scanner/bzrsync.py 2010-04-27 02:24:35 +0000 | |||
967 | @@ -79,8 +79,7 @@ | |||
968 | 79 | """Synchronize the database with a Bazaar branch, handling locking. | 79 | """Synchronize the database with a Bazaar branch, handling locking. |
969 | 80 | """ | 80 | """ |
970 | 81 | if bzr_branch is None: | 81 | if bzr_branch is None: |
973 | 82 | bzr_branch = BranchMirrorer(WarehouseBranchPolicy()).open( | 82 | bzr_branch = self.db_branch.getBzrBranch() |
972 | 83 | self.db_branch.warehouse_url) | ||
974 | 84 | bzr_branch.lock_read() | 83 | bzr_branch.lock_read() |
975 | 85 | try: | 84 | try: |
976 | 86 | self.syncBranch(bzr_branch) | 85 | self.syncBranch(bzr_branch) |
977 | 87 | 86 | ||
978 | === modified file 'lib/lp/codehosting/tests/test_branchdistro.py' | |||
979 | --- lib/lp/codehosting/tests/test_branchdistro.py 2010-04-27 02:24:30 +0000 | |||
980 | +++ lib/lp/codehosting/tests/test_branchdistro.py 2010-04-27 02:24:35 +0000 | |||
981 | @@ -108,7 +108,7 @@ | |||
982 | 108 | 108 | ||
983 | 109 | def setUp(self): | 109 | def setUp(self): |
984 | 110 | TestCaseWithFactory.setUp(self) | 110 | TestCaseWithFactory.setUp(self) |
986 | 111 | self.useBzrBranches(real_server=True, direct_database=True) | 111 | self.useBzrBranches(direct_database=True) |
987 | 112 | 112 | ||
988 | 113 | def makeOfficialPackageBranch(self, distroseries=None): | 113 | def makeOfficialPackageBranch(self, distroseries=None): |
989 | 114 | """Make an official package branch with an underlying bzr branch.""" | 114 | """Make an official package branch with an underlying bzr branch.""" |
990 | 115 | 115 | ||
991 | === modified file 'lib/lp/codehosting/tests/test_jobs.py' | |||
992 | --- lib/lp/codehosting/tests/test_jobs.py 2009-06-30 16:56:07 +0000 | |||
993 | +++ lib/lp/codehosting/tests/test_jobs.py 2010-04-27 02:24:35 +0000 | |||
994 | @@ -25,7 +25,7 @@ | |||
995 | 25 | 25 | ||
996 | 26 | def test_runJob_generates_diff(self): | 26 | def test_runJob_generates_diff(self): |
997 | 27 | """Ensure that a diff is actually generated in this environment.""" | 27 | """Ensure that a diff is actually generated in this environment.""" |
999 | 28 | self.useBzrBranches() | 28 | self.useBzrBranches(direct_database=True) |
1000 | 29 | branch, tree = self.create_branch_and_tree() | 29 | branch, tree = self.create_branch_and_tree() |
1001 | 30 | branch.subscribe(branch.registrant, | 30 | branch.subscribe(branch.registrant, |
1002 | 31 | BranchSubscriptionNotificationLevel.FULL, | 31 | BranchSubscriptionNotificationLevel.FULL, |
1003 | 32 | 32 | ||
1004 | === modified file 'lib/lp/codehosting/vfs/__init__.py' | |||
1005 | --- lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:30 +0000 | |||
1006 | +++ lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:35 +0000 | |||
1007 | @@ -10,6 +10,7 @@ | |||
1008 | 10 | 'BranchFileSystemClient', | 10 | 'BranchFileSystemClient', |
1009 | 11 | 'get_lp_server', | 11 | 'get_lp_server', |
1010 | 12 | 'get_multi_server', | 12 | 'get_multi_server', |
1011 | 13 | 'get_ro_server', | ||
1012 | 13 | 'get_rw_server', | 14 | 'get_rw_server', |
1013 | 14 | 'get_scanner_server', | 15 | 'get_scanner_server', |
1014 | 15 | 'LaunchpadServer', | 16 | 'LaunchpadServer', |
1015 | @@ -18,7 +19,7 @@ | |||
1016 | 18 | 19 | ||
1017 | 19 | from lp.codehosting.vfs.branchfs import ( | 20 | from lp.codehosting.vfs.branchfs import ( |
1018 | 20 | AsyncLaunchpadTransport, branch_id_to_path, get_lp_server, | 21 | AsyncLaunchpadTransport, branch_id_to_path, get_lp_server, |
1021 | 21 | get_multi_server, get_rw_server, get_scanner_server, LaunchpadServer, | 22 | get_multi_server, get_ro_server, get_rw_server, get_scanner_server, |
1022 | 22 | make_branch_mirrorer) | 23 | LaunchpadServer, make_branch_mirrorer) |
1023 | 23 | from lp.codehosting.vfs.branchfsclient import ( | 24 | from lp.codehosting.vfs.branchfsclient import ( |
1024 | 24 | BlockingProxy,BranchFileSystemClient) | 25 | BlockingProxy,BranchFileSystemClient) |
1025 | 25 | 26 | ||
1026 | === modified file 'lib/lp/codehosting/vfs/branchfs.py' | |||
1027 | --- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:30 +0000 | |||
1028 | +++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:35 +0000 | |||
1029 | @@ -55,6 +55,7 @@ | |||
1030 | 55 | 'DirectDatabaseLaunchpadServer', | 55 | 'DirectDatabaseLaunchpadServer', |
1031 | 56 | 'get_lp_server', | 56 | 'get_lp_server', |
1032 | 57 | 'get_multi_server', | 57 | 'get_multi_server', |
1033 | 58 | 'get_ro_server', | ||
1034 | 58 | 'get_rw_server', | 59 | 'get_rw_server', |
1035 | 59 | 'get_scanner_server', | 60 | 'get_scanner_server', |
1036 | 60 | 'make_branch_mirrorer', | 61 | 'make_branch_mirrorer', |
1037 | @@ -167,15 +168,16 @@ | |||
1038 | 167 | return absolute_path.endswith('/.bzr/branch/lock/held') | 168 | return absolute_path.endswith('/.bzr/branch/lock/held') |
1039 | 168 | 169 | ||
1040 | 169 | 170 | ||
1042 | 170 | def get_scanner_server(): | 171 | def get_ro_server(): |
1043 | 171 | """Get a Launchpad internal server for scanning branches.""" | 172 | """Get a Launchpad internal server for scanning branches.""" |
1044 | 172 | proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) | 173 | proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) |
1045 | 173 | codehosting_endpoint = BlockingProxy(proxy) | 174 | codehosting_endpoint = BlockingProxy(proxy) |
1046 | 174 | branch_transport = get_readonly_transport( | 175 | branch_transport = get_readonly_transport( |
1047 | 175 | get_transport(config.codehosting.internal_branch_by_id_root)) | 176 | get_transport(config.codehosting.internal_branch_by_id_root)) |
1048 | 176 | return LaunchpadInternalServer( | 177 | return LaunchpadInternalServer( |
1050 | 177 | 'lp-mirrored:///', codehosting_endpoint, branch_transport) | 178 | 'lp-internal:///', codehosting_endpoint, branch_transport) |
1051 | 178 | 179 | ||
1052 | 180 | get_scanner_server = get_ro_server | ||
1053 | 179 | 181 | ||
1054 | 180 | def get_rw_server(direct_database=False): | 182 | def get_rw_server(direct_database=False): |
1055 | 181 | """Get a server that can write to the Launchpad branch vfs. | 183 | """Get a server that can write to the Launchpad branch vfs. |
1056 | 182 | 184 | ||
1057 | === modified file 'lib/lp/testing/__init__.py' | |||
1058 | --- lib/lp/testing/__init__.py 2010-04-27 02:24:30 +0000 | |||
1059 | +++ lib/lp/testing/__init__.py 2010-04-27 02:24:35 +0000 | |||
1060 | @@ -412,6 +412,7 @@ | |||
1061 | 412 | from lp.testing.factory import LaunchpadObjectFactory | 412 | from lp.testing.factory import LaunchpadObjectFactory |
1062 | 413 | self.factory = LaunchpadObjectFactory() | 413 | self.factory = LaunchpadObjectFactory() |
1063 | 414 | self.direct_database_server = False | 414 | self.direct_database_server = False |
1064 | 415 | self._use_bzr_branch_called = False | ||
1065 | 415 | 416 | ||
1066 | 416 | def getUserBrowser(self, url=None, user=None, password='test'): | 417 | def getUserBrowser(self, url=None, user=None, password='test'): |
1067 | 417 | """Return a Browser logged in as a fresh user, maybe opened at `url`. | 418 | """Return a Browser logged in as a fresh user, maybe opened at `url`. |
1068 | @@ -478,9 +479,10 @@ | |||
1069 | 478 | :param db_branch: The database branch to create the branch for. | 479 | :param db_branch: The database branch to create the branch for. |
1070 | 479 | :param parent: If supplied, the bzr branch to use as a parent. | 480 | :param parent: If supplied, the bzr branch to use as a parent. |
1071 | 480 | """ | 481 | """ |
1073 | 481 | bzr_branch = self.createBranchAtURL(db_branch.warehouse_url) | 482 | bzr_branch = self.createBranchAtURL(db_branch.getInternalBzrUrl()) |
1074 | 482 | if parent: | 483 | if parent: |
1075 | 483 | bzr_branch.pull(parent) | 484 | bzr_branch.pull(parent) |
1076 | 485 | removeSecurityProxy(db_branch).last_scanned_id = bzr_branch.last_revision() | ||
1077 | 484 | return bzr_branch | 486 | return bzr_branch |
1078 | 485 | 487 | ||
1079 | 486 | @staticmethod | 488 | @staticmethod |
1080 | @@ -537,6 +539,11 @@ | |||
1081 | 537 | :param direct_database: If true, translate branch locations by | 539 | :param direct_database: If true, translate branch locations by |
1082 | 538 | directly querying the database, not the internal XML-RPC server. | 540 | directly querying the database, not the internal XML-RPC server. |
1083 | 539 | """ | 541 | """ |
1084 | 542 | if self._use_bzr_branch_called: | ||
1085 | 543 | if direct_database != self.direct_database_server: | ||
1086 | 544 | raise AssertionError("XXX") | ||
1087 | 545 | return | ||
1088 | 546 | self._use_bzr_branch_called = True | ||
1089 | 540 | self.useTempBzrHome() | 547 | self.useTempBzrHome() |
1090 | 541 | self.direct_database_server = direct_database | 548 | self.direct_database_server = direct_database |
1091 | 542 | server = get_rw_server(direct_database=direct_database) | 549 | server = get_rw_server(direct_database=direct_database) |
1092 | 543 | 550 | ||
1093 | === modified file 'lib/lp/testing/factory.py' | |||
1094 | --- lib/lp/testing/factory.py 2010-04-27 02:24:30 +0000 | |||
1095 | +++ lib/lp/testing/factory.py 2010-04-27 02:24:35 +0000 | |||
1096 | @@ -2284,8 +2284,8 @@ | |||
1097 | 2284 | md = MergeDirective2.from_objects( | 2284 | md = MergeDirective2.from_objects( |
1098 | 2285 | source_branch.repository, source_branch.last_revision(), | 2285 | source_branch.repository, source_branch.last_revision(), |
1099 | 2286 | public_branch=source_branch.get_public_branch(), | 2286 | public_branch=source_branch.get_public_branch(), |
1102 | 2287 | target_branch=target_branch.warehouse_url, | 2287 | target_branch=target_branch.getInternalBzrUrl(), |
1103 | 2288 | local_target_branch=target_branch.warehouse_url, time=0, | 2288 | local_target_branch=target_branch.getInternalBzrUrl(), time=0, |
1104 | 2289 | timezone=0) | 2289 | timezone=0) |
1105 | 2290 | email = None | 2290 | email = None |
1106 | 2291 | if sender is not None: | 2291 | if sender is not None: |
1107 | 2292 | 2292 | ||
1108 | === modified file 'lib/lp/translations/tests/test_translationtemplatesbuildjob.py' | |||
1109 | --- lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2010-04-27 02:24:30 +0000 | |||
1110 | +++ lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2010-04-27 02:24:35 +0000 | |||
1111 | @@ -149,7 +149,7 @@ | |||
1112 | 149 | def _makeTranslationBranch(self, fake_pottery_compatible=None): | 149 | def _makeTranslationBranch(self, fake_pottery_compatible=None): |
1113 | 150 | """Create a branch that provides translations for a productseries.""" | 150 | """Create a branch that provides translations for a productseries.""" |
1114 | 151 | if fake_pottery_compatible is None: | 151 | if fake_pottery_compatible is None: |
1116 | 152 | self.useBzrBranches() | 152 | self.useBzrBranches(direct_database=True) |
1117 | 153 | branch, tree = self.create_branch_and_tree() | 153 | branch, tree = self.create_branch_and_tree() |
1118 | 154 | else: | 154 | else: |
1119 | 155 | branch = self.factory.makeAnyBranch() | 155 | branch = self.factory.makeAnyBranch() |
1120 | @@ -219,6 +219,7 @@ | |||
1121 | 219 | # If the feature is enabled, a TipChanged event for a branch that | 219 | # If the feature is enabled, a TipChanged event for a branch that |
1122 | 220 | # generates templates will schedule a templates build. | 220 | # generates templates will schedule a templates build. |
1123 | 221 | branch = self._makeTranslationBranch() | 221 | branch = self._makeTranslationBranch() |
1124 | 222 | removeSecurityProxy(branch).last_scanned_id = 'null:' | ||
1125 | 222 | commit = DirectBranchCommit(branch) | 223 | commit = DirectBranchCommit(branch) |
1126 | 223 | commit.writeFile('POTFILES.in', 'foo') | 224 | commit.writeFile('POTFILES.in', 'foo') |
1127 | 224 | commit.commit('message') | 225 | commit.commit('message') |
I know that it is not worth it now, but in code/model/ tests/test_ branchjob. py you could database= True.
lib/lp/
have just overridden the inherited useBzrBranches method
to make it always specify direct_
It may be an interesting count, but which is used more? database= True or False?
direct_
lib/lp/ testing/ __init_ _.py "XXX")
- you still have: raise AssertionError(
removeSecurityP roxy(branch) .last_scanned_ id = 'null:'
- is there a bzrlib constant we can use here?
And yes, it was a pretty boring branch to review. Great
to see a consistent use of getInternalBzrUrl and getBzrBranch.