Merge lp:~mwhudson/launchpad/no-hosted-area-fix-useBzrBranch-users into lp:launchpad/db-devel

Proposed by Michael Hudson-Doyle
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
Reviewer Review Type Date Requested Status
Tim Penhey (community) conditional Approve
Review via email: mp+24096@code.launchpad.net

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

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

I know that it is not worth it now, but in
lib/lp/code/model/tests/test_branchjob.py you could
have just overridden the inherited useBzrBranches method
to make it always specify direct_database=True.

It may be an interesting count, but which is used more?
direct_database=True or False?

lib/lp/testing/__init__.py
 - you still have: raise AssertionError("XXX")

removeSecurityProxy(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.

review: Approve (conditional)
Revision history for this message
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/code/model/tests/test_branchjob.py you could
> have just overridden the inherited useBzrBranches method
> to make it always specify direct_database=True.

Yeah, this aspect of things does smell a bit doesn't it?

> It may be an interesting count, but which is used more?
> direct_database=True or False?

It seems 43 of 64 calls use direct_database=True -- quite a lot!

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/testing/__init__.py
> - you still have: raise AssertionError("XXX")
>
> removeSecurityProxy(branch).last_scanned_id = 'null:'
> - 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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/buildd/tests/test_generate_translation_templates.py'
--- lib/canonical/buildd/tests/test_generate_translation_templates.py 2010-03-18 13:27:47 +0000
+++ lib/canonical/buildd/tests/test_generate_translation_templates.py 2010-04-27 02:24:35 +0000
@@ -57,7 +57,7 @@
5757
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.
59 """59 """
60 db_branch, tree = self.create_branch_and_tree(hosted=True)60 db_branch, tree = self.create_branch_and_tree()
61 populist = DirectBranchCommit(db_branch)61 populist = DirectBranchCommit(db_branch)
62 last_revision = populist.bzrbranch.last_revision()62 last_revision = populist.bzrbranch.last_revision()
63 db_branch.last_scanned_id = populist.last_scanned_id = last_revision63 db_branch.last_scanned_id = populist.last_scanned_id = last_revision
@@ -71,13 +71,13 @@
7171
72 def test_getBranch_bzr(self):72 def test_getBranch_bzr(self):
73 # _getBranch can retrieve branch contents from a branch URL.73 # _getBranch can retrieve branch contents from a branch URL.
74 self.useBzrBranches()74 self.useBzrBranches(direct_database=True)
75 marker_text = "Ceci n'est pas cet branch."75 marker_text = "Ceci n'est pas cet branch."
76 branch = self._createBranch({'marker.txt': marker_text})76 branch = self._createBranch({'marker.txt': marker_text})
77 branch_url = branch.getPullURL()
7877
79 generator = GenerateTranslationTemplates(78 generator = GenerateTranslationTemplates(
80 branch_url, self.result_name, self.makeTemporaryDirectory())79 branch.getInternalBzrUrl(), self.result_name,
80 self.makeTemporaryDirectory())
81 generator.branch_dir = self.makeTemporaryDirectory()81 generator.branch_dir = self.makeTemporaryDirectory()
82 generator._getBranch()82 generator._getBranch()
8383
8484
=== added directory 'lib/canonical/launchpad/apidoc'
=== modified file 'lib/canonical/launchpad/scripts/tests/test_garbo.py'
--- lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-14 13:14:00 +0000
+++ lib/canonical/launchpad/scripts/tests/test_garbo.py 2010-04-27 02:24:35 +0000
@@ -448,7 +448,6 @@
448448
449 def test_BranchJobPruner(self):449 def test_BranchJobPruner(self):
450 # Garbo should remove jobs completed over 30 days ago.450 # Garbo should remove jobs completed over 30 days ago.
451 self.useBzrBranches()
452 LaunchpadZopelessLayer.switchDbUser('testadmin')451 LaunchpadZopelessLayer.switchDbUser('testadmin')
453 store = IMasterStore(Job)452 store = IMasterStore(Job)
454453
@@ -478,7 +477,6 @@
478 def test_BranchJobPruner_doesnt_prune_recent_jobs(self):477 def test_BranchJobPruner_doesnt_prune_recent_jobs(self):
479 # Check to make sure the garbo doesn't remove jobs that aren't more478 # Check to make sure the garbo doesn't remove jobs that aren't more
480 # than thirty days old.479 # than thirty days old.
481 self.useBzrBranches()
482 LaunchpadZopelessLayer.switchDbUser('testadmin')480 LaunchpadZopelessLayer.switchDbUser('testadmin')
483 store = IMasterStore(Job)481 store = IMasterStore(Job)
484482
485483
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-04-27 02:24:30 +0000
+++ lib/lp/code/configure.zcml 2010-04-27 02:24:35 +0000
@@ -471,7 +471,6 @@
471 last_scanned471 last_scanned
472 last_scanned_id472 last_scanned_id
473 revision_count473 revision_count
474 warehouse_url
475 bug_branches474 bug_branches
476 linked_bugs475 linked_bugs
477 linkBug476 linkBug
@@ -519,6 +518,7 @@
519 getNotificationRecipients518 getNotificationRecipients
520 getScannerData519 getScannerData
521 getPullURL520 getPullURL
521 getInternalBzrUrl
522 getBzrBranch522 getBzrBranch
523 requestMirror523 requestMirror
524 startMirroring524 startMirroring
525525
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/interfaces/branch.py 2010-04-27 02:24:35 +0000
@@ -596,12 +596,6 @@
596596
597 stacked_on = Attribute('Stacked-on branch')597 stacked_on = Attribute('Stacked-on branch')
598598
599 warehouse_url = Attribute(
600 "URL for accessing the branch by ID. "
601 "This is for in-datacentre services only and allows such services to "
602 "be unaffected during branch renames. "
603 "See doc/bazaar for more information about the branch warehouse.")
604
605 # Bug attributes599 # Bug attributes
606 bug_branches = CollectionField(600 bug_branches = CollectionField(
607 title=_("The bug-branch link objects that link this branch "601 title=_("The bug-branch link objects that link this branch "
@@ -1076,7 +1070,15 @@
1076 the corresponding BranchRevision rows for this branch.1070 the corresponding BranchRevision rows for this branch.
1077 """1071 """
10781072
1079 def getBzrBranch(self):1073 def getInternalBzrUrl():
1074 """Get the internal URL for this branch.
1075
1076 It's generally better to use `getBzrBranch` to open the branch
1077 directly, as that method is safe against the branch unexpectedly being
1078 a branch reference or stacked on something mischievous.
1079 """
1080
1081 def getBzrBranch():
1080 """Return the BzrBranch for this database Branch.1082 """Return the BzrBranch for this database Branch.
10811083
1082 You can only call this if a server returned by `get_ro_server` or1084 You can only call this if a server returned by `get_ro_server` or
10831085
=== modified file 'lib/lp/code/interfaces/branchtarget.py'
--- lib/lp/code/interfaces/branchtarget.py 2010-04-13 11:05:58 +0000
+++ lib/lp/code/interfaces/branchtarget.py 2010-04-27 02:24:35 +0000
@@ -34,7 +34,9 @@
34 Branches that are *not* suitable include:34 Branches that are *not* suitable include:
35 - remote branches35 - remote branches
36 - branches the user cannot see36 - branches the user cannot see
37 - branches that have not yet been successfully processed by the puller.37 - branches that have no last revision information set (hosted branches
38 where a push hasn't completed or a mirrored branch that hasn't been
39 mirrored, etc).
3840
39 If the given branch is not suitable, return None. For convenience, also41 If the given branch is not suitable, return None. For convenience, also
40 returns None if passed None. Otherwise, return the branch.42 returns None if passed None. Otherwise, return the branch.
@@ -47,7 +49,7 @@
47 return None49 return None
48 if branch_type == BranchType.REMOTE:50 if branch_type == BranchType.REMOTE:
49 return None51 return None
50 if branch.last_mirrored is None:52 if branch.last_mirrored_id is None:
51 return None53 return None
52 return branch54 return branch
5355
5456
=== modified file 'lib/lp/code/mail/codehandler.py'
--- lib/lp/code/mail/codehandler.py 2010-03-18 20:53:36 +0000
+++ lib/lp/code/mail/codehandler.py 2010-04-27 02:24:35 +0000
@@ -21,7 +21,6 @@
2121
22from zope.component import getUtility22from zope.component import getUtility
23from zope.interface import implements23from zope.interface import implements
24from zope.security.proxy import removeSecurityProxy
2524
26from lp.codehosting.bzrutils import is_branch_stackable25from lp.codehosting.bzrutils import is_branch_stackable
27from lp.codehosting.vfs import get_lp_server26from lp.codehosting.vfs import get_lp_server
@@ -495,7 +494,7 @@
495 # source branch - one that has *no* Bazaar data. Together these494 # source branch - one that has *no* Bazaar data. Together these
496 # prevent users from using Launchpad disk space at a rate that is495 # prevent users from using Launchpad disk space at a rate that is
497 # disproportionately greater than data uploaded.496 # disproportionately greater than data uploaded.
498 mirrored_bzr_target = removeSecurityProxy(db_target).getBzrBranch()497 mirrored_bzr_target = db_target.getBzrBranch()
499 if not is_branch_stackable(mirrored_bzr_target):498 if not is_branch_stackable(mirrored_bzr_target):
500 return db_source499 return db_source
501 assert db_source.branch_type == BranchType.HOSTED, (500 assert db_source.branch_type == BranchType.HOSTED, (
502501
=== modified file 'lib/lp/code/mail/tests/test_codehandler.py'
--- lib/lp/code/mail/tests/test_codehandler.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/mail/tests/test_codehandler.py 2010-04-27 02:24:35 +0000
@@ -848,13 +848,6 @@
848 transaction.commit()848 transaction.commit()
849 LaunchpadZopelessLayer.switchDbUser(user)849 LaunchpadZopelessLayer.switchDbUser(user)
850850
851 def _mirror(self, db_branch, bzr_branch):
852 # Ensure the directories containing the mirror branch exist.
853 transport = get_transport(db_branch.warehouse_url)
854 lp_mirror = BzrDir.create_branch_convenience(db_branch.warehouse_url)
855 self.addCleanup(transport.delete_tree, '.')
856 lp_mirror.pull(bzr_branch)
857
858 def _createTargetSourceAndBundle(self, format=None):851 def _createTargetSourceAndBundle(self, format=None):
859 """Create a merge directive with a bundle and associated branches.852 """Create a merge directive with a bundle and associated branches.
860853
@@ -909,7 +902,7 @@
909 # branch that is created is an empty hosted branch. The new branch902 # branch that is created is an empty hosted branch. The new branch
910 # will not have a mirror requested as there are no revisions, and903 # will not have a mirror requested as there are no revisions, and
911 # there is no branch created in the hosted area.904 # there is no branch created in the hosted area.
912 self.useBzrBranches(real_server=True)905 self.useBzrBranches()
913 branch, source, message = self._createTargetSourceAndBundle(906 branch, source, message = self._createTargetSourceAndBundle(
914 format="pack-0.92")907 format="pack-0.92")
915 bmp = self._processMergeDirective(message)908 bmp = self._processMergeDirective(message)
@@ -921,7 +914,7 @@
921 # mirrored, the source branch that is created is an empty hosted914 # mirrored, the source branch that is created is an empty hosted
922 # branch. The new branch will not have a mirror requested as there915 # branch. The new branch will not have a mirror requested as there
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.
924 self.useBzrBranches(real_server=True)917 self.useBzrBranches()
925 branch, source, message = self._createTargetSourceAndBundle(918 branch, source, message = self._createTargetSourceAndBundle(
926 format="1.9")919 format="1.9")
927 # Mark the target branch as "unmirrored", at least as far as the db is920 # Mark the target branch as "unmirrored", at least as far as the db is
@@ -936,7 +929,7 @@
936 # branch that is created is a hosted branch stacked on the target929 # branch that is created is a hosted branch stacked on the target
937 # branch. The source branch will have the revisions from the bundle,930 # branch. The source branch will have the revisions from the bundle,
938 # and a mirror will have been triggered.931 # and a mirror will have been triggered.
939 self.useBzrBranches(real_server=True)932 self.useBzrBranches()
940 branch, source, message = self._createTargetSourceAndBundle(933 branch, source, message = self._createTargetSourceAndBundle(
941 format="1.9")934 format="1.9")
942 bmp = self._processMergeDirective(message)935 bmp = self._processMergeDirective(message)
@@ -946,24 +939,10 @@
946 self.assertEqual(939 self.assertEqual(
947 source.last_revision(), source_bzr_branch.last_revision())940 source.last_revision(), source_bzr_branch.last_revision())
948941
949 def test_correct_area(self):
950 # When a branch is created for a merge directive, it is created in the
951 # hosted area (getPullURL) not the mirrored area (warehouse_url).
952 self.useBzrBranches(real_server=True)
953 branch, source, message = self._createTargetSourceAndBundle(
954 format="1.9")
955 bmp = self._processMergeDirective(message)
956 # The hosted location should be populated (open succeeds).
957 self._openBazaarBranchAsClient(bmp.source_branch)
958 # Not the mirror (open raises).
959 self.assertRaises(
960 bzr_errors.NotBranchError, Branch.open,
961 bmp.source_branch.warehouse_url)
962
963 def test_branch_stacked(self):942 def test_branch_stacked(self):
964 # When a branch is created for a merge directive, it is created943 # When a branch is created for a merge directive, it is created
965 # stacked on the target branch.944 # stacked on the target branch.
966 self.useBzrBranches(real_server=True)945 self.useBzrBranches()
967 branch, source, message = self._createTargetSourceAndBundle(946 branch, source, message = self._createTargetSourceAndBundle(
968 format="1.9")947 format="1.9")
969 bmp = self._processMergeDirective(message)948 bmp = self._processMergeDirective(message)
@@ -983,7 +962,7 @@
983 def test_source_not_newer(self):962 def test_source_not_newer(self):
984 # The source branch is created correctly when the source is not newer963 # The source branch is created correctly when the source is not newer
985 # than the target, instead of raising DivergedBranches.964 # than the target, instead of raising DivergedBranches.
986 self.useBzrBranches(real_server=True)965 self.useBzrBranches()
987 branch, source, message = self._createTargetSourceAndBundle(966 branch, source, message = self._createTargetSourceAndBundle(
988 format="1.9")967 format="1.9")
989 target_tree = WorkingTree.open('.')968 target_tree = WorkingTree.open('.')
@@ -998,20 +977,16 @@
998 db_target_branch, target_tree = self.create_branch_and_tree(977 db_target_branch, target_tree = self.create_branch_and_tree(
999 'target', format=target_format)978 'target', format=target_format)
1000 target_tree.branch.set_public_branch(db_target_branch.bzr_identity)979 target_tree.branch.set_public_branch(db_target_branch.bzr_identity)
1001 target_tree.commit('rev1')980 revid = target_tree.commit('rev1')
1002 # Make sure that the created branch has been mirrored.
1003 db_target_branch.startMirroring()
1004 removeSecurityProxy(db_target_branch).branchChanged(981 removeSecurityProxy(db_target_branch).branchChanged(
1005 '', 'rev1', None, None, None)982 '', revid, None, None, None)
1006983
1007 db_source_branch, source_tree = self.create_branch_and_tree(984 db_source_branch, source_tree = self.create_branch_and_tree(
1008 'lpsource', db_target_branch.product, hosted=True,985 'lpsource', db_target_branch.product, format=source_format)
1009 format=source_format)
1010 # The branch is not scheduled to be mirrorred.986 # The branch is not scheduled to be mirrorred.
1011 self.assertIs(db_source_branch.next_mirror_time, None)987 self.assertIs(db_source_branch.next_mirror_time, None)
1012 source_tree.pull(target_tree.branch)988 source_tree.pull(target_tree.branch)
1013 source_tree.commit('rev2', rev_id='rev2')989 source_tree.commit('rev2', rev_id='rev2')
1014 self._mirror(db_source_branch, source_tree.branch)
1015 # bundle_tree is effectively behaving like a local copy of990 # bundle_tree is effectively behaving like a local copy of
1016 # db_source_branch, and is used to create the merge directive.991 # db_source_branch, and is used to create the merge directive.
1017 bundle_tree = source_tree.bzrdir.sprout('source').open_workingtree()992 bundle_tree = source_tree.bzrdir.sprout('source').open_workingtree()
@@ -1030,41 +1005,34 @@
1030 def test_existing_stacked_branch(self):1005 def test_existing_stacked_branch(self):
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,
1032 # and the source branch is stacked.1007 # and the source branch is stacked.
1033 self.useBzrBranches(real_server=True)1008 self.useBzrBranches()
1034 lp_source, message = self._createPreexistingSourceAndMessage(1009 lp_source, message = self._createPreexistingSourceAndMessage(
1035 target_format="1.9", source_format="1.9", set_stacked=True)1010 target_format="1.9", source_format="1.9", set_stacked=True)
1036 bmp = self._processMergeDirective(message)1011 bmp = self._processMergeDirective(message)
1037 # The branch merge proposal should use the existing db branch.1012 # The branch merge proposal should use the existing db branch.
1038 self.assertEqual(lp_source, bmp.source_branch)1013 self.assertEqual(lp_source, bmp.source_branch)
1039 # Now the branch is now scheduled to be mirrorred.1014 bzr_branch = self._openBazaarBranchAsClient(bmp.source_branch)
1040 self.assertIsNot(None, lp_source.next_mirror_time)1015 # The branch has been updated.
1041 mirror = removeSecurityProxy(bmp.source_branch).getBzrBranch()1016 self.assertEqual('rev3', bzr_branch.last_revision())
1042 # The mirrored copy of the branch has not been updated.
1043 self.assertEqual('rev2', mirror.last_revision())
1044 hosted = self._openBazaarBranchAsClient(bmp.source_branch)
1045 # The hosted copy of the branch has been updated.
1046 self.assertEqual('rev3', hosted.last_revision())
10471017
1048 def test_existing_unstacked_branch(self):1018 def test_existing_unstacked_branch(self):
1049 # Even if the source and target are stackable, if the source is not1019 # Even if the source and target are stackable, if the source is not
1050 # stacked, we don't support stacking something that wasn't stacked1020 # stacked, we don't support stacking something that wasn't stacked
1051 # before (yet).1021 # before (yet).
1052 self.useBzrBranches(real_server=True)1022 self.useBzrBranches()
1053 lp_source, message = self._createPreexistingSourceAndMessage(1023 lp_source, message = self._createPreexistingSourceAndMessage(
1054 target_format="1.9", source_format="1.9")1024 target_format="1.9", source_format="1.9")
1055 bmp = self._processMergeDirective(message)1025 bmp = self._processMergeDirective(message)
1056 # The branch merge proposal should use the existing db branch.1026 # The branch merge proposal should use the existing db branch.
1057 self.assertEqual(lp_source, bmp.source_branch)1027 self.assertEqual(lp_source, bmp.source_branch)
1058 # Now the branch is not scheduled to be mirrorred.1028 bzr_branch = self._openBazaarBranchAsClient(bmp.source_branch)
1059 self.assertIs(None, lp_source.next_mirror_time)
1060 hosted = self._openBazaarBranchAsClient(bmp.source_branch)
1061 # The hosted copy of the branch has not been updated.1029 # The hosted copy of the branch has not been updated.
1062 self.assertEqual('rev2', hosted.last_revision())1030 self.assertEqual('rev2', bzr_branch.last_revision())
10631031
1064 def test_existing_branch_nonstackable_target(self):1032 def test_existing_branch_nonstackable_target(self):
1065 # If the target branch is not stackable, then we don't pull any1033 # If the target branch is not stackable, then we don't pull any
1066 # revisions.1034 # revisions.
1067 self.useBzrBranches(real_server=True)1035 self.useBzrBranches()
1068 lp_source, message = self._createPreexistingSourceAndMessage(1036 lp_source, message = self._createPreexistingSourceAndMessage(
1069 target_format="pack-0.92", source_format="1.9")1037 target_format="pack-0.92", source_format="1.9")
1070 bmp = self._processMergeDirective(message)1038 bmp = self._processMergeDirective(message)
@@ -1079,7 +1047,7 @@
1079 def test_existing_branch_nonstackable_source(self):1047 def test_existing_branch_nonstackable_source(self):
1080 # If the source branch is not stackable, then we don't pull any1048 # If the source branch is not stackable, then we don't pull any
1081 # revisions.1049 # revisions.
1082 self.useBzrBranches(real_server=True)1050 self.useBzrBranches()
1083 lp_source, message = self._createPreexistingSourceAndMessage(1051 lp_source, message = self._createPreexistingSourceAndMessage(
1084 target_format="1.9", source_format="pack-0.92")1052 target_format="1.9", source_format="pack-0.92")
1085 bmp = self._processMergeDirective(message)1053 bmp = self._processMergeDirective(message)
@@ -1093,7 +1061,7 @@
10931061
1094 def test_forbidden_target(self):1062 def test_forbidden_target(self):
1095 """Specifying a branch in a forbidden target generates email."""1063 """Specifying a branch in a forbidden target generates email."""
1096 self.useBzrBranches(real_server=True)1064 self.useBzrBranches()
1097 branch, source, message = self._createTargetSourceAndBundle(1065 branch, source, message = self._createTargetSourceAndBundle(
1098 format="pack-0.92")1066 format="pack-0.92")
1099 branch.product.setBranchVisibilityTeamPolicy(1067 branch.product.setBranchVisibilityTeamPolicy(
11001068
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/branch.py 2010-04-27 02:24:35 +0000
@@ -460,14 +460,13 @@
460 "Private branch %s has no public URL." % self.unique_name)460 "Private branch %s has no public URL." % self.unique_name)
461 return compose_public_url(scheme, self.unique_name)461 return compose_public_url(scheme, self.unique_name)
462462
463 @property463 def getInternalBzrUrl(self):
464 def warehouse_url(self):
465 """See `IBranch`."""464 """See `IBranch`."""
466 return 'lp-mirrored:///%s' % self.unique_name465 return 'lp-internal:///' + self.unique_name
467466
468 def getBzrBranch(self):467 def getBzrBranch(self):
469 """See `IBranch`."""468 """See `IBranch`."""
470 return safe_open('lp-internal', 'lp-internal:///' + self.unique_name)469 return safe_open('lp-internal', self.getInternalBzrUrl())
471470
472 @property471 @property
473 def displayname(self):472 def displayname(self):
474473
=== modified file 'lib/lp/code/model/branchjob.py'
--- lib/lp/code/model/branchjob.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/branchjob.py 2010-04-27 02:24:35 +0000
@@ -51,8 +51,8 @@
51from lp.code.model.diff import StaticDiff51from lp.code.model.diff import StaticDiff
52from lp.code.model.revision import RevisionSet52from lp.code.model.revision import RevisionSet
53from lp.codehosting.scanner.bzrsync import BzrSync53from lp.codehosting.scanner.bzrsync import BzrSync
54from lp.codehosting.vfs import (branch_id_to_path, get_multi_server,54from lp.codehosting.vfs import (
55 get_scanner_server)55 branch_id_to_path, get_rw_server, get_ro_server)
56from lp.services.job.model.job import Job56from lp.services.job.model.job import Job
57from lp.services.job.interfaces.job import JobStatus57from lp.services.job.interfaces.job import JobStatus
58from lp.services.job.runner import BaseRunnableJob58from lp.services.job.runner import BaseRunnableJob
@@ -284,7 +284,7 @@
284 def contextManager(cls):284 def contextManager(cls):
285 """See `IBranchScanJobSource`."""285 """See `IBranchScanJobSource`."""
286 errorlog.globalErrorUtility.configure('branchscanner')286 errorlog.globalErrorUtility.configure('branchscanner')
287 cls.server = get_scanner_server()287 cls.server = get_ro_server()
288 cls.server.start_server()288 cls.server.start_server()
289 yield289 yield
290 cls.server.stop_server()290 cls.server.stop_server()
@@ -313,7 +313,7 @@
313 def contextManager():313 def contextManager():
314 """See `IBranchUpgradeJobSource`."""314 """See `IBranchUpgradeJobSource`."""
315 errorlog.globalErrorUtility.configure('upgrade_branches')315 errorlog.globalErrorUtility.configure('upgrade_branches')
316 server = get_multi_server(write_hosted=True)316 server = get_rw_server()
317 server.start_server()317 server.start_server()
318 yield318 yield
319 server.stop_server()319 server.stop_server()
@@ -325,7 +325,8 @@
325 try:325 try:
326 upgrade_transport = get_transport(upgrade_branch_path)326 upgrade_transport = get_transport(upgrade_branch_path)
327 upgrade_transport.mkdir('.bzr')327 upgrade_transport.mkdir('.bzr')
328 source_branch_transport = get_transport(self.branch.getPullURL())328 source_branch_transport = get_transport(
329 self.branch.getInternalBzrUrl())
329 source_branch_transport.clone('.bzr').copy_tree_to_transport(330 source_branch_transport.clone('.bzr').copy_tree_to_transport(
330 upgrade_transport.clone('.bzr'))331 upgrade_transport.clone('.bzr'))
331 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)332 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)
332333
=== modified file 'lib/lp/code/model/branchmergeproposaljob.py'
--- lib/lp/code/model/branchmergeproposaljob.py 2010-04-06 03:37:16 +0000
+++ lib/lp/code/model/branchmergeproposaljob.py 2010-04-27 02:24:35 +0000
@@ -69,7 +69,7 @@
69from lp.code.mail.codereviewcomment import CodeReviewCommentMailer69from lp.code.mail.codereviewcomment import CodeReviewCommentMailer
70from lp.code.model.branchmergeproposal import BranchMergeProposal70from lp.code.model.branchmergeproposal import BranchMergeProposal
71from lp.code.model.diff import PreviewDiff71from lp.code.model.diff import PreviewDiff
72from lp.codehosting.vfs import get_multi_server, get_scanner_server72from lp.codehosting.vfs import get_ro_server, get_rw_server
73from lp.registry.interfaces.person import IPersonSet73from lp.registry.interfaces.person import IPersonSet
74from lp.services.job.model.job import Job74from lp.services.job.model.job import Job
75from lp.services.job.interfaces.job import JobStatus75from lp.services.job.interfaces.job import JobStatus
@@ -322,7 +322,7 @@
322 def contextManager():322 def contextManager():
323 """See `IUpdatePreviewDiffJobSource`."""323 """See `IUpdatePreviewDiffJobSource`."""
324 errorlog.globalErrorUtility.configure('update_preview_diffs')324 errorlog.globalErrorUtility.configure('update_preview_diffs')
325 server = get_scanner_server()325 server = get_ro_server()
326 server.start_server()326 server.start_server()
327 yield327 yield
328 server.stop_server()328 server.stop_server()
@@ -403,7 +403,7 @@
403 raise AssertionError('No principal found for %s' % email_addr)403 raise AssertionError('No principal found for %s' % email_addr)
404 setupInteraction(principal, email_addr)404 setupInteraction(principal, email_addr)
405405
406 server = get_multi_server(write_hosted=True)406 server = get_rw_server()
407 server.start_server()407 server.start_server()
408 try:408 try:
409 return CodeHandler().processMergeProposal(message)409 return CodeHandler().processMergeProposal(message)
@@ -635,7 +635,7 @@
635 def contextManager():635 def contextManager():
636 """See `IJobSource`."""636 """See `IJobSource`."""
637 errorlog.globalErrorUtility.configure('merge_proposal_jobs')637 errorlog.globalErrorUtility.configure('merge_proposal_jobs')
638 server = get_scanner_server()638 server = get_ro_server()
639 server.start_server()639 server.start_server()
640 yield640 yield
641 server.stop_server()641 server.stop_server()
642642
=== modified file 'lib/lp/code/model/diff.py'
--- lib/lp/code/model/diff.py 2010-02-17 19:10:51 +0000
+++ lib/lp/code/model/diff.py 2010-04-27 02:24:35 +0000
@@ -322,16 +322,15 @@
322 :param bmp: The `BranchMergeProposal` to generate a `PreviewDiff` for.322 :param bmp: The `BranchMergeProposal` to generate a `PreviewDiff` for.
323 :return: A `PreviewDiff`.323 :return: A `PreviewDiff`.
324 """324 """
325 source_branch = Branch.open(bmp.source_branch.warehouse_url)325 source_branch = bmp.source_branch.getBzrBranch()
326 source_revision = source_branch.last_revision()326 source_revision = source_branch.last_revision()
327 target_branch = Branch.open(bmp.target_branch.warehouse_url)327 target_branch = bmp.target_branch.getBzrBranch()
328 target_revision = target_branch.last_revision()328 target_revision = target_branch.last_revision()
329 preview = cls()329 preview = cls()
330 preview.source_revision_id = source_revision.decode('utf-8')330 preview.source_revision_id = source_revision.decode('utf-8')
331 preview.target_revision_id = target_revision.decode('utf-8')331 preview.target_revision_id = target_revision.decode('utf-8')
332 if bmp.prerequisite_branch is not None:332 if bmp.prerequisite_branch is not None:
333 prerequisite_branch = Branch.open(333 prerequisite_branch = bmp.prerequisite_branch.getBzrBranch()
334 bmp.prerequisite_branch.warehouse_url)
335 else:334 else:
336 prerequisite_branch = None335 prerequisite_branch = None
337 preview.diff, conflicts = Diff.mergePreviewFromBranches(336 preview.diff, conflicts = Diff.mergePreviewFromBranches(
338337
=== modified file 'lib/lp/code/model/directbranchcommit.py'
--- lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:35 +0000
@@ -47,7 +47,7 @@
47 is_locked = False47 is_locked = False
48 commit_builder = None48 commit_builder = None
4949
50 def __init__(self, db_branch, committer=None):50 def __init__(self, db_branch, committer=None, no_race_check=False):
51 """Create context for direct commit to branch.51 """Create context for direct commit to branch.
5252
53 Before constructing a `DirectBranchCommit`, set up a server that53 Before constructing a `DirectBranchCommit`, set up a server that
@@ -66,6 +66,8 @@
6666
67 :param db_branch: a Launchpad `Branch` object.67 :param db_branch: a Launchpad `Branch` object.
68 :param committer: the `Person` writing to the branch.68 :param committer: the `Person` writing to the branch.
69 :param no_race_check: don't check for other commits before committing
70 our changes, for use in tests.
69 """71 """
70 self.db_branch = db_branch72 self.db_branch = db_branch
7173
@@ -75,6 +77,8 @@
75 committer = db_branch.owner77 committer = db_branch.owner
76 self.committer = committer78 self.committer = committer
7779
80 self.no_race_check = no_race_check
81
78 # Directories we create on the branch, and their ids.82 # Directories we create on the branch, and their ids.
79 self.path_ids = {}83 self.path_ids = {}
8084
@@ -155,6 +159,8 @@
155 If it does, raise `ConcurrentUpdateError`.159 If it does, raise `ConcurrentUpdateError`.
156 """160 """
157 assert self.is_locked, "Getting revision on un-locked branch."161 assert self.is_locked, "Getting revision on un-locked branch."
162 if self.no_race_check:
163 return
158 last_revision = self.bzrbranch.last_revision()164 last_revision = self.bzrbranch.last_revision()
159 if last_revision != self.last_scanned_id:165 if last_revision != self.last_scanned_id:
160 raise ConcurrentUpdateError(166 raise ConcurrentUpdateError(
161167
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-04-27 02:24:35 +0000
@@ -2370,7 +2370,7 @@
23702370
2371 def setUp(self):2371 def setUp(self):
2372 TestCaseWithFactory.setUp(self)2372 TestCaseWithFactory.setUp(self)
2373 self.useBzrBranches(real_server=True, direct_database=True)2373 self.useBzrBranches(direct_database=True)
23742374
2375 def test_simple(self):2375 def test_simple(self):
2376 # safe_open returns the underlying bzr branch of a database branch in2376 # safe_open returns the underlying bzr branch of a database branch in
23772377
=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/tests/test_branchjob.py 2010-04-27 02:24:35 +0000
@@ -100,7 +100,7 @@
100100
101 def test_run_revision_ids(self):101 def test_run_revision_ids(self):
102 """Ensure that run calculates revision ids."""102 """Ensure that run calculates revision ids."""
103 self.useBzrBranches()103 self.useBzrBranches(direct_database=True)
104 branch, tree = self.create_branch_and_tree()104 branch, tree = self.create_branch_and_tree()
105 tree.commit('First commit', rev_id='rev1')105 tree.commit('First commit', rev_id='rev1')
106 job = BranchDiffJob.create(branch, '0', '1')106 job = BranchDiffJob.create(branch, '0', '1')
@@ -110,7 +110,7 @@
110110
111 def test_run_diff_content(self):111 def test_run_diff_content(self):
112 """Ensure that run generates expected diff."""112 """Ensure that run generates expected diff."""
113 self.useBzrBranches()113 self.useBzrBranches(direct_database=True)
114114
115 tree_location = tempfile.mkdtemp()115 tree_location = tempfile.mkdtemp()
116 self.addCleanup(lambda: shutil.rmtree(tree_location)) 116 self.addCleanup(lambda: shutil.rmtree(tree_location))
@@ -134,7 +134,7 @@
134134
135 def test_run_is_idempotent(self):135 def test_run_is_idempotent(self):
136 """Ensure running an equivalent job emits the same diff."""136 """Ensure running an equivalent job emits the same diff."""
137 self.useBzrBranches()137 self.useBzrBranches(direct_database=True)
138 branch, tree = self.create_branch_and_tree()138 branch, tree = self.create_branch_and_tree()
139 tree.commit('First commit')139 tree.commit('First commit')
140 job1 = BranchDiffJob.create(branch, '0', '1')140 job1 = BranchDiffJob.create(branch, '0', '1')
@@ -149,7 +149,7 @@
149 This diff contains an add of a file called hello.txt, with contents149 This diff contains an add of a file called hello.txt, with contents
150 "Hello World\n".150 "Hello World\n".
151 """151 """
152 self.useBzrBranches()152 self.useBzrBranches(direct_database=True)
153 branch, tree = self.create_branch_and_tree()153 branch, tree = self.create_branch_and_tree()
154 first_revision = 'rev-1'154 first_revision = 'rev-1'
155 tree_transport = tree.bzrdir.root_transport155 tree_transport = tree.bzrdir.root_transport
@@ -197,7 +197,7 @@
197197
198 def test_run(self):198 def test_run(self):
199 """Ensure the job scans the branch."""199 """Ensure the job scans the branch."""
200 self.useBzrBranches()200 self.useBzrBranches(direct_database=True)
201201
202 db_branch, bzr_tree = self.create_branch_and_tree()202 db_branch, bzr_tree = self.create_branch_and_tree()
203 bzr_tree.commit('First commit', rev_id='rev1')203 bzr_tree.commit('First commit', rev_id='rev1')
@@ -249,9 +249,8 @@
249249
250 def test_upgrades_branch(self):250 def test_upgrades_branch(self):
251 """Ensure that a branch with an outdated format is upgraded."""251 """Ensure that a branch with an outdated format is upgraded."""
252 self.useBzrBranches()252 self.useBzrBranches(direct_database=True)
253 db_branch, tree = self.create_branch_and_tree(253 db_branch, tree = self.create_branch_and_tree(format='knit')
254 hosted=True, format='knit')
255 db_branch.branch_format = BranchFormat.BZR_BRANCH_5254 db_branch.branch_format = BranchFormat.BZR_BRANCH_5
256 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1255 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1
257 self.assertEqual(256 self.assertEqual(
@@ -278,14 +277,13 @@
278 def test_existing_bzr_backup(self):277 def test_existing_bzr_backup(self):
279 # If the target branch already has a backup.bzr dir, the upgrade copy278 # If the target branch already has a backup.bzr dir, the upgrade copy
280 # should remove it.279 # should remove it.
281 self.useBzrBranches()280 self.useBzrBranches(direct_database=True)
282 db_branch, tree = self.create_branch_and_tree(281 db_branch, tree = self.create_branch_and_tree(format='knit')
283 hosted=True, format='knit')
284 db_branch.branch_format = BranchFormat.BZR_BRANCH_5282 db_branch.branch_format = BranchFormat.BZR_BRANCH_5
285 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1283 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1
286284
287 # Add a fake backup.bzr dir285 # Add a fake backup.bzr dir
288 source_branch_transport = get_transport(db_branch.getPullURL())286 source_branch_transport = get_transport(db_branch.getInternalBzrUrl())
289 source_branch_transport.mkdir('backup.bzr')287 source_branch_transport.mkdir('backup.bzr')
290 source_branch_transport.clone('.bzr').copy_tree_to_transport(288 source_branch_transport.clone('.bzr').copy_tree_to_transport(
291 source_branch_transport.clone('backup.bzr'))289 source_branch_transport.clone('backup.bzr'))
@@ -354,7 +352,7 @@
354352
355 def test_perform_diff_performs_diff(self):353 def test_perform_diff_performs_diff(self):
356 """Ensure that a diff is generated when perform_diff is True."""354 """Ensure that a diff is generated when perform_diff is True."""
357 self.useBzrBranches()355 self.useBzrBranches(direct_database=True)
358 branch, tree = self.create_branch_and_tree()356 branch, tree = self.create_branch_and_tree()
359 tree.bzrdir.root_transport.put_bytes('foo', 'bar\n')357 tree.bzrdir.root_transport.put_bytes('foo', 'bar\n')
360 tree.add('foo')358 tree.add('foo')
@@ -366,7 +364,7 @@
366364
367 def test_perform_diff_ignored_for_revno_0(self):365 def test_perform_diff_ignored_for_revno_0(self):
368 """For the null revision, no diff is generated."""366 """For the null revision, no diff is generated."""
369 self.useBzrBranches()367 self.useBzrBranches(direct_database=True)
370 branch, tree = self.create_branch_and_tree()368 branch, tree = self.create_branch_and_tree()
371 job = RevisionMailJob.create(369 job = RevisionMailJob.create(
372 branch, 0, 'from@example.com', 'hello', True, 'subject')370 branch, 0, 'from@example.com', 'hello', True, 'subject')
@@ -465,7 +463,7 @@
465463
466 def test_iterAddedMainline(self):464 def test_iterAddedMainline(self):
467 """iterAddedMainline iterates through mainline revisions."""465 """iterAddedMainline iterates through mainline revisions."""
468 self.useBzrBranches()466 self.useBzrBranches(direct_database=True)
469 branch, tree = self.create3CommitsBranch()467 branch, tree = self.create3CommitsBranch()
470 job = RevisionsAddedJob.create(branch, 'rev1', 'rev2', '')468 job = RevisionsAddedJob.create(branch, 'rev1', 'rev2', '')
471 job.bzr_branch.lock_read()469 job.bzr_branch.lock_read()
@@ -475,7 +473,7 @@
475473
476 def test_iterAddedNonMainline(self):474 def test_iterAddedNonMainline(self):
477 """iterAddedMainline drops non-mainline revisions."""475 """iterAddedMainline drops non-mainline revisions."""
478 self.useBzrBranches()476 self.useBzrBranches(direct_database=True)
479 branch, tree = self.create3CommitsBranch()477 branch, tree = self.create3CommitsBranch()
480 tree.pull(tree.branch, overwrite=True, stop_revision='rev2')478 tree.pull(tree.branch, overwrite=True, stop_revision='rev2')
481 tree.add_parent_tree_id('rev3')479 tree.add_parent_tree_id('rev3')
@@ -489,7 +487,7 @@
489487
490 def test_iterAddedMainline_order(self):488 def test_iterAddedMainline_order(self):
491 """iterAddedMainline iterates in commit order."""489 """iterAddedMainline iterates in commit order."""
492 self.useBzrBranches()490 self.useBzrBranches(direct_database=True)
493 branch, tree = self.create3CommitsBranch()491 branch, tree = self.create3CommitsBranch()
494 job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '')492 job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '')
495 job.bzr_branch.lock_read()493 job.bzr_branch.lock_read()
@@ -528,7 +526,7 @@
528 that merges the others.526 that merges the others.
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.
530 """528 """
531 self.useBzrBranches()529 self.useBzrBranches(direct_database=True)
532 branch, tree = self.create_branch_and_tree()530 branch, tree = self.create_branch_and_tree()
533 tree.branch.nick = 'nicholas'531 tree.branch.nick = 'nicholas'
534 tree.commit('rev1')532 tree.commit('rev1')
@@ -558,7 +556,7 @@
558556
559 def test_findRelatedBMP(self):557 def test_findRelatedBMP(self):
560 """The related branch merge proposals can be identified."""558 """The related branch merge proposals can be identified."""
561 self.useBzrBranches()559 self.useBzrBranches(direct_database=True)
562 target_branch, tree = self.create_branch_and_tree('tree')560 target_branch, tree = self.create_branch_and_tree('tree')
563 desired_proposal = self.factory.makeBranchMergeProposal(561 desired_proposal = self.factory.makeBranchMergeProposal(
564 target_branch=target_branch)562 target_branch=target_branch)
@@ -577,7 +575,7 @@
577 """findRelatedBMP only returns the most recent proposal for any575 """findRelatedBMP only returns the most recent proposal for any
578 particular source branch.576 particular source branch.
579 """577 """
580 self.useBzrBranches()578 self.useBzrBranches(direct_database=True)
581 target_branch, tree = self.create_branch_and_tree('tree')579 target_branch, tree = self.create_branch_and_tree('tree')
582 the_past = datetime.datetime(2009, 1, 1, tzinfo=pytz.UTC)580 the_past = datetime.datetime(2009, 1, 1, tzinfo=pytz.UTC)
583 old_proposal = self.factory.makeBranchMergeProposal(581 old_proposal = self.factory.makeBranchMergeProposal(
@@ -614,7 +612,7 @@
614612
615 def test_getRevisionMessage(self):613 def test_getRevisionMessage(self):
616 """getRevisionMessage provides a correctly-formatted message."""614 """getRevisionMessage provides a correctly-formatted message."""
617 self.useBzrBranches()615 self.useBzrBranches(direct_database=True)
618 branch, tree = self.makeBranchWithCommit()616 branch, tree = self.makeBranchWithCommit()
619 job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '')617 job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '')
620 message = job.getRevisionMessage('rev1', 1)618 message = job.getRevisionMessage('rev1', 1)
@@ -785,7 +783,7 @@
785783
786 def test_email_format(self):784 def test_email_format(self):
787 """Contents of the email are as expected."""785 """Contents of the email are as expected."""
788 self.useBzrBranches()786 self.useBzrBranches(direct_database=True)
789 db_branch, tree = self.create_branch_and_tree()787 db_branch, tree = self.create_branch_and_tree()
790 first_revision = 'rev-1'788 first_revision = 'rev-1'
791 tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n')789 tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n')
@@ -844,7 +842,7 @@
844842
845 def test_message_encoding(self):843 def test_message_encoding(self):
846 """Test handling of non-ASCII commit messages."""844 """Test handling of non-ASCII commit messages."""
847 self.useBzrBranches()845 self.useBzrBranches(direct_database=True)
848 db_branch, tree = self.create_branch_and_tree()846 db_branch, tree = self.create_branch_and_tree()
849 rev_id = 'rev-1'847 rev_id = 'rev-1'
850 tree.commit(848 tree.commit(
@@ -868,7 +866,7 @@
868866
869 def test_getMailerForRevision(self):867 def test_getMailerForRevision(self):
870 """The mailer for the revision is as expected."""868 """The mailer for the revision is as expected."""
871 self.useBzrBranches()869 self.useBzrBranches(direct_database=True)
872 branch, tree = self.makeBranchWithCommit()870 branch, tree = self.makeBranchWithCommit()
873 revision = tree.branch.repository.get_revision('rev1')871 revision = tree.branch.repository.get_revision('rev1')
874 job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '')872 job = RevisionsAddedJob.create(branch, 'rev1', 'rev1', '')
@@ -881,7 +879,7 @@
881 def test_only_nodiff_subscribers_means_no_diff_generated(self):879 def test_only_nodiff_subscribers_means_no_diff_generated(self):
882 """No diff is generated when no subscribers need it."""880 """No diff is generated when no subscribers need it."""
883 self.layer.switchDbUser('launchpad')881 self.layer.switchDbUser('launchpad')
884 self.useBzrBranches()882 self.useBzrBranches(direct_database=True)
885 branch, tree = self.create_branch_and_tree()883 branch, tree = self.create_branch_and_tree()
886 subscriptions = branch.getSubscriptionsByLevel(884 subscriptions = branch.getSubscriptionsByLevel(
887 [BranchSubscriptionNotificationLevel.FULL])885 [BranchSubscriptionNotificationLevel.FULL])
@@ -911,7 +909,7 @@
911 in which case an arbitrary unique string is used.909 in which case an arbitrary unique string is used.
912 :returns: The revision of the first commit.910 :returns: The revision of the first commit.
913 """911 """
914 self.useBzrBranches()912 self.useBzrBranches(direct_database=True)
915 self.branch, self.tree = self.create_branch_and_tree()913 self.branch, self.tree = self.create_branch_and_tree()
916 return self._commitFilesToTree(files, 'First commit')914 return self._commitFilesToTree(files, 'First commit')
917915
918916
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposaljobs.py'
--- lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-06 03:37:16 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-04-27 02:24:35 +0000
@@ -102,7 +102,7 @@
102102
103 def test_run_sends_email(self):103 def test_run_sends_email(self):
104 """MergeProposalCreationJob.run sends an email."""104 """MergeProposalCreationJob.run sends an email."""
105 self.useBzrBranches()105 self.useBzrBranches(direct_database=True)
106 bmp = self.createProposalWithEmptyBranches()106 bmp = self.createProposalWithEmptyBranches()
107 job = MergeProposalCreatedJob.create(bmp)107 job = MergeProposalCreatedJob.create(bmp)
108 self.assertEqual([], pop_notifications())108 self.assertEqual([], pop_notifications())
@@ -123,7 +123,7 @@
123123
124 def test_MergeProposalCreateJob_with_sourcepackage_branch(self):124 def test_MergeProposalCreateJob_with_sourcepackage_branch(self):
125 """Jobs for merge proposals with sourcepackage branches work."""125 """Jobs for merge proposals with sourcepackage branches work."""
126 self.useBzrBranches()126 self.useBzrBranches(direct_database=True)
127 bmp = self.factory.makeBranchMergeProposal(127 bmp = self.factory.makeBranchMergeProposal(
128 target_branch=self.factory.makePackageBranch())128 target_branch=self.factory.makePackageBranch())
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]
@@ -145,7 +145,7 @@
145 verifyObject(IUpdatePreviewDiffJobSource, UpdatePreviewDiffJob)145 verifyObject(IUpdatePreviewDiffJobSource, UpdatePreviewDiffJob)
146146
147 def test_run(self):147 def test_run(self):
148 self.useBzrBranches()148 self.useBzrBranches(direct_database=True)
149 bmp = self.createExampleMerge()[0]149 bmp = self.createExampleMerge()[0]
150 job = UpdatePreviewDiffJob.create(bmp)150 job = UpdatePreviewDiffJob.create(bmp)
151 self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)151 self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
@@ -179,7 +179,7 @@
179 email.get_payload(decode=True))179 email.get_payload(decode=True))
180180
181 def test_10_minute_lease(self):181 def test_10_minute_lease(self):
182 self.useBzrBranches()182 self.useBzrBranches(direct_database=True)
183 bmp = self.createExampleMerge()[0]183 bmp = self.createExampleMerge()[0]
184 job = UpdatePreviewDiffJob.create(bmp)184 job = UpdatePreviewDiffJob.create(bmp)
185 job.acquireLease()185 job.acquireLease()
186186
=== modified file 'lib/lp/code/model/tests/test_diff.py'
--- lib/lp/code/model/tests/test_diff.py 2010-04-27 02:24:30 +0000
+++ lib/lp/code/model/tests/test_diff.py 2010-04-27 02:24:35 +0000
@@ -11,10 +11,12 @@
11import logging11import logging
12from unittest import TestLoader12from unittest import TestLoader
1313
14from bzrlib.branch import Branch
15from bzrlib import trace14from bzrlib import trace
15
16import transaction16import transaction
1717
18from zope.security.proxy import removeSecurityProxy
19
18from canonical.launchpad.interfaces.launchpad import NotFoundError20from canonical.launchpad.interfaces.launchpad import NotFoundError
19from canonical.launchpad.webapp import canonical_url, errorlog21from canonical.launchpad.webapp import canonical_url, errorlog
20from canonical.launchpad.webapp.testing import verifyObject22from canonical.launchpad.webapp.testing import verifyObject
@@ -44,7 +46,7 @@
4446
45 This will create or modify the file, as needed.47 This will create or modify the file, as needed.
46 """48 """
47 committer = DirectBranchCommit(branch)49 committer = DirectBranchCommit(branch, no_race_check=True)
48 committer.writeFile(path, contents)50 committer.writeFile(path, contents)
49 try:51 try:
50 return committer.commit('committing')52 return committer.commit('committing')
@@ -53,7 +55,7 @@
5355
54 def createExampleMerge(self):56 def createExampleMerge(self):
55 """Create a merge proposal with conflicts and updates."""57 """Create a merge proposal with conflicts and updates."""
56 self.useBzrBranches()58 self.useBzrBranches(direct_database=True)
57 bmp = self.factory.makeBranchMergeProposal()59 bmp = self.factory.makeBranchMergeProposal()
58 # Make the branches of the merge proposal look good as far as the60 # Make the branches of the merge proposal look good as far as the
59 # model is concerned.61 # model is concerned.
@@ -81,7 +83,7 @@
8183
82 def preparePrerequisiteMerge(self, bmp=None):84 def preparePrerequisiteMerge(self, bmp=None):
83 """Prepare a merge scenario with a prerequisite branch."""85 """Prepare a merge scenario with a prerequisite branch."""
84 self.useBzrBranches()86 self.useBzrBranches(direct_database=True)
85 if bmp is None:87 if bmp is None:
86 target = self.factory.makeBranch()88 target = self.factory.makeBranch()
87 prerequisite = self.factory.makeBranch()89 prerequisite = self.factory.makeBranch()
@@ -159,8 +161,8 @@
159 def test_mergePreviewFromBranches(self):161 def test_mergePreviewFromBranches(self):
160 # mergePreviewFromBranches generates the correct diff.162 # mergePreviewFromBranches generates the correct diff.
161 bmp, source_rev_id, target_rev_id = self.createExampleMerge()163 bmp, source_rev_id, target_rev_id = self.createExampleMerge()
162 source_branch = Branch.open(bmp.source_branch.warehouse_url)164 source_branch = bmp.source_branch.getBzrBranch()
163 target_branch = Branch.open(bmp.target_branch.warehouse_url)165 target_branch = bmp.target_branch.getBzrBranch()
164 diff, conflicts = Diff.mergePreviewFromBranches(166 diff, conflicts = Diff.mergePreviewFromBranches(
165 source_branch, source_rev_id, target_branch)167 source_branch, source_rev_id, target_branch)
166 transaction.commit()168 transaction.commit()
@@ -280,7 +282,7 @@
280282
281 def test_acquire_existing(self):283 def test_acquire_existing(self):
282 """Ensure that acquire returns the existing StaticDiff."""284 """Ensure that acquire returns the existing StaticDiff."""
283 self.useBzrBranches()285 self.useBzrBranches(direct_database=True)
284 branch, tree = self.create_branch_and_tree()286 branch, tree = self.create_branch_and_tree()
285 tree.commit('First commit', rev_id='rev1')287 tree.commit('First commit', rev_id='rev1')
286 diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository)288 diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository)
@@ -289,7 +291,7 @@
289291
290 def test_acquire_existing_different_repo(self):292 def test_acquire_existing_different_repo(self):
291 """The existing object is used even if the repository is different."""293 """The existing object is used even if the repository is different."""
292 self.useBzrBranches()294 self.useBzrBranches(direct_database=True)
293 branch1, tree1 = self.create_branch_and_tree('tree1')295 branch1, tree1 = self.create_branch_and_tree('tree1')
294 tree1.commit('First commit', rev_id='rev1')296 tree1.commit('First commit', rev_id='rev1')
295 branch2, tree2 = self.create_branch_and_tree('tree2')297 branch2, tree2 = self.create_branch_and_tree('tree2')
@@ -300,7 +302,7 @@
300302
301 def test_acquire_nonexisting(self):303 def test_acquire_nonexisting(self):
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."""
303 self.useBzrBranches()305 self.useBzrBranches(direct_database=True)
304 branch, tree = self.create_branch_and_tree()306 branch, tree = self.create_branch_and_tree()
305 tree.commit('First commit', rev_id='rev1')307 tree.commit('First commit', rev_id='rev1')
306 tree.commit('Next commit', rev_id='rev2')308 tree.commit('Next commit', rev_id='rev2')
@@ -428,7 +430,7 @@
428430
429 def test_fromPreviewDiff_with_no_conflicts(self):431 def test_fromPreviewDiff_with_no_conflicts(self):
430 """Test fromPreviewDiff when no conflicts are present."""432 """Test fromPreviewDiff when no conflicts are present."""
431 self.useBzrBranches()433 self.useBzrBranches(direct_database=True)
432 bmp = self.factory.makeBranchMergeProposal()434 bmp = self.factory.makeBranchMergeProposal()
433 bzr_target = self.createBzrBranch(bmp.target_branch)435 bzr_target = self.createBzrBranch(bmp.target_branch)
434 self.commitFile(bmp.target_branch, 'foo', 'a\n')436 self.commitFile(bmp.target_branch, 'foo', 'a\n')
435437
=== modified file 'lib/lp/code/scripts/tests/test_create_merge_proposals.py'
--- lib/lp/code/scripts/tests/test_create_merge_proposals.py 2010-04-01 05:08:47 +0000
+++ lib/lp/code/scripts/tests/test_create_merge_proposals.py 2010-04-27 02:24:35 +0000
@@ -70,22 +70,16 @@
70 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n'70 'INFO Creating lockfile: /var/lock/launchpad-create_merge_proposals.lock\n'
71 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr)71 'INFO Ran 1 CreateMergeProposalJobs.\n', stderr)
72 self.assertEqual('', stdout)72 self.assertEqual('', stdout)
73 # The hosted location should be populated, not the mirror.
74 bmp = branch.landing_candidates[0]73 bmp = branch.landing_candidates[0]
75 self.assertRaises(74 local_source = bmp.source_branch.getBzrBranch()
76 bzr_errors.NotBranchError, Branch.open,75 # The branch has the correct last revision.
77 bmp.source_branch.warehouse_url)
78 local_source = Branch.open(bmp.source_branch.getPullURL())
79 # The hosted branch has the correct last revision.
80 self.assertEqual(76 self.assertEqual(
81 source.branch.last_revision(), local_source.last_revision())77 source.branch.last_revision(), local_source.last_revision())
82 # A mirror should be scheduled.
83 self.assertIsNot(None, bmp.source_branch.next_mirror_time)
8478
85 def disabled_test_merge_directive_with_bundle(self):79 def disabled_test_merge_directive_with_bundle(self):
86 """Merge directives with bundles generate branches."""80 """Merge directives with bundles generate branches."""
87 # XXX TimPenhey 2009-04-01 bug 35280081 # XXX TimPenhey 2009-04-01 bug 352800
88 self.useBzrBranches(real_server=True)82 self.useBzrBranches()
89 branch, tree = self.create_branch_and_tree()83 branch, tree = self.create_branch_and_tree()
90 source = self.createJob(branch, tree)84 source = self.createJob(branch, tree)
91 self.jobOutputCheck(branch, source)85 self.jobOutputCheck(branch, source)
@@ -93,7 +87,7 @@
93 def disabled_test_merge_directive_with_project(self):87 def disabled_test_merge_directive_with_project(self):
94 """Bundles are handled when the target branch has a project."""88 """Bundles are handled when the target branch has a project."""
95 # XXX TimPenhey 2009-04-01 bug 35280089 # XXX TimPenhey 2009-04-01 bug 352800
96 self.useBzrBranches(real_server=True)90 self.useBzrBranches()
97 product = self.factory.makeProduct(project=self.factory.makeProject())91 product = self.factory.makeProduct(project=self.factory.makeProject())
98 branch, tree = self.create_branch_and_tree(product=product)92 branch, tree = self.create_branch_and_tree(product=product)
99 source = self.createJob(branch, tree)93 source = self.createJob(branch, tree)
10094
=== modified file 'lib/lp/code/scripts/tests/test_scan_branches.py'
--- lib/lp/code/scripts/tests/test_scan_branches.py 2010-04-01 04:29:46 +0000
+++ lib/lp/code/scripts/tests/test_scan_branches.py 2010-04-27 02:24:35 +0000
@@ -26,8 +26,7 @@
2626
27 def make_branch_with_commits_and_scan_job(self, db_branch):27 def make_branch_with_commits_and_scan_job(self, db_branch):
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."""
29 target, target_tree = self.create_branch_and_tree(29 target, target_tree = self.create_branch_and_tree(db_branch=db_branch)
30 db_branch=db_branch)
31 target_tree.commit('First commit', rev_id='rev1')30 target_tree.commit('First commit', rev_id='rev1')
32 target_tree.commit('Second commit', rev_id='rev2')31 target_tree.commit('Second commit', rev_id='rev2')
33 target_tree.commit('Third commit', rev_id='rev3')32 target_tree.commit('Third commit', rev_id='rev3')
@@ -45,7 +44,7 @@
4544
46 def test_scan_branch(self):45 def test_scan_branch(self):
47 """Test that scan branches adds revisions to the database."""46 """Test that scan branches adds revisions to the database."""
48 self.useBzrBranches(real_server=True)47 self.useBzrBranches()
4948
50 db_branch = self.factory.makeAnyBranch()49 db_branch = self.factory.makeAnyBranch()
51 self.make_branch_with_commits_and_scan_job(db_branch)50 self.make_branch_with_commits_and_scan_job(db_branch)
@@ -70,7 +69,7 @@
7069
71 def test_scan_packagebranch(self):70 def test_scan_packagebranch(self):
72 """Test that scan_branches can scan package branches."""71 """Test that scan_branches can scan package branches."""
73 self.useBzrBranches(real_server=True)72 self.useBzrBranches()
7473
75 db_branch = self.factory.makePackageBranch()74 db_branch = self.factory.makePackageBranch()
76 self.make_branch_with_commits_and_scan_job(db_branch)75 self.make_branch_with_commits_and_scan_job(db_branch)
7776
=== modified file 'lib/lp/code/scripts/tests/test_upgrade_branches.py'
--- lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-04-01 04:37:30 +0000
+++ lib/lp/code/scripts/tests/test_upgrade_branches.py 2010-04-27 02:24:35 +0000
@@ -22,9 +22,8 @@
2222
23 def test_upgrade_branches(self):23 def test_upgrade_branches(self):
24 """Test that upgrade_branches upgrades branches."""24 """Test that upgrade_branches upgrades branches."""
25 self.useBzrBranches(real_server=True)25 self.useBzrBranches()
26 target, target_tree = self.create_branch_and_tree(26 target, target_tree = self.create_branch_and_tree(format='knit')
27 hosted=True, format='knit')
28 target.branch_format = BranchFormat.BZR_BRANCH_527 target.branch_format = BranchFormat.BZR_BRANCH_5
29 target.repository_format = RepositoryFormat.BZR_KNIT_128 target.repository_format = RepositoryFormat.BZR_KNIT_1
3029
@@ -49,10 +48,10 @@
4948
50 def test_upgrade_branches_packagebranch(self):49 def test_upgrade_branches_packagebranch(self):
51 """Test that upgrade_branches can upgrade package branches."""50 """Test that upgrade_branches can upgrade package branches."""
52 self.useBzrBranches(real_server=True)51 self.useBzrBranches()
53 package_branch = self.factory.makePackageBranch()52 package_branch = self.factory.makePackageBranch()
54 target, target_tree = self.create_branch_and_tree(53 target, target_tree = self.create_branch_and_tree(
55 db_branch=package_branch, hosted=True, format='knit')54 db_branch=package_branch, format='knit')
56 target.branch_format = BranchFormat.BZR_BRANCH_555 target.branch_format = BranchFormat.BZR_BRANCH_5
57 target.repository_format = RepositoryFormat.BZR_KNIT_156 target.repository_format = RepositoryFormat.BZR_KNIT_1
5857
5958
=== modified file 'lib/lp/codehosting/inmemory.py'
--- lib/lp/codehosting/inmemory.py 2010-04-27 02:24:30 +0000
+++ lib/lp/codehosting/inmemory.py 2010-04-27 02:24:35 +0000
@@ -433,7 +433,7 @@
433 if branch is None:433 if branch is None:
434 branch = self.makeBranch(product=product)434 branch = self.makeBranch(product=product)
435 product.development_focus.branch = branch435 product.development_focus.branch = branch
436 branch.last_mirrored = 'rev1'436 branch.last_mirrored_id = 'rev1'
437 return branch437 return branch
438438
439 def enableDefaultStackingForPackage(self, package, branch):439 def enableDefaultStackingForPackage(self, package, branch):
@@ -445,7 +445,7 @@
445 """445 """
446 package.development_version.setBranch(446 package.development_version.setBranch(
447 PackagePublishingPocket.RELEASE, branch, branch.owner)447 PackagePublishingPocket.RELEASE, branch, branch.owner)
448 branch.last_mirrored = 'rev1'448 branch.last_mirrored_id = 'rev1'
449 return branch449 return branch
450450
451451
452452
=== modified file 'lib/lp/codehosting/scanner/bzrsync.py'
--- lib/lp/codehosting/scanner/bzrsync.py 2010-04-27 02:24:30 +0000
+++ lib/lp/codehosting/scanner/bzrsync.py 2010-04-27 02:24:35 +0000
@@ -79,8 +79,7 @@
79 """Synchronize the database with a Bazaar branch, handling locking.79 """Synchronize the database with a Bazaar branch, handling locking.
80 """80 """
81 if bzr_branch is None:81 if bzr_branch is None:
82 bzr_branch = BranchMirrorer(WarehouseBranchPolicy()).open(82 bzr_branch = self.db_branch.getBzrBranch()
83 self.db_branch.warehouse_url)
84 bzr_branch.lock_read()83 bzr_branch.lock_read()
85 try:84 try:
86 self.syncBranch(bzr_branch)85 self.syncBranch(bzr_branch)
8786
=== modified file 'lib/lp/codehosting/tests/test_branchdistro.py'
--- lib/lp/codehosting/tests/test_branchdistro.py 2010-04-27 02:24:30 +0000
+++ lib/lp/codehosting/tests/test_branchdistro.py 2010-04-27 02:24:35 +0000
@@ -108,7 +108,7 @@
108108
109 def setUp(self):109 def setUp(self):
110 TestCaseWithFactory.setUp(self)110 TestCaseWithFactory.setUp(self)
111 self.useBzrBranches(real_server=True, direct_database=True)111 self.useBzrBranches(direct_database=True)
112112
113 def makeOfficialPackageBranch(self, distroseries=None):113 def makeOfficialPackageBranch(self, distroseries=None):
114 """Make an official package branch with an underlying bzr branch."""114 """Make an official package branch with an underlying bzr branch."""
115115
=== modified file 'lib/lp/codehosting/tests/test_jobs.py'
--- lib/lp/codehosting/tests/test_jobs.py 2009-06-30 16:56:07 +0000
+++ lib/lp/codehosting/tests/test_jobs.py 2010-04-27 02:24:35 +0000
@@ -25,7 +25,7 @@
2525
26 def test_runJob_generates_diff(self):26 def test_runJob_generates_diff(self):
27 """Ensure that a diff is actually generated in this environment."""27 """Ensure that a diff is actually generated in this environment."""
28 self.useBzrBranches()28 self.useBzrBranches(direct_database=True)
29 branch, tree = self.create_branch_and_tree()29 branch, tree = self.create_branch_and_tree()
30 branch.subscribe(branch.registrant,30 branch.subscribe(branch.registrant,
31 BranchSubscriptionNotificationLevel.FULL,31 BranchSubscriptionNotificationLevel.FULL,
3232
=== modified file 'lib/lp/codehosting/vfs/__init__.py'
--- lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:30 +0000
+++ lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:35 +0000
@@ -10,6 +10,7 @@
10 'BranchFileSystemClient',10 'BranchFileSystemClient',
11 'get_lp_server',11 'get_lp_server',
12 'get_multi_server',12 'get_multi_server',
13 'get_ro_server',
13 'get_rw_server',14 'get_rw_server',
14 'get_scanner_server',15 'get_scanner_server',
15 'LaunchpadServer',16 'LaunchpadServer',
@@ -18,7 +19,7 @@
1819
19from lp.codehosting.vfs.branchfs import (20from lp.codehosting.vfs.branchfs import (
20 AsyncLaunchpadTransport, branch_id_to_path, get_lp_server,21 AsyncLaunchpadTransport, branch_id_to_path, get_lp_server,
21 get_multi_server, get_rw_server, get_scanner_server, LaunchpadServer,22 get_multi_server, get_ro_server, get_rw_server, get_scanner_server,
22 make_branch_mirrorer)23 LaunchpadServer, make_branch_mirrorer)
23from lp.codehosting.vfs.branchfsclient import (24from lp.codehosting.vfs.branchfsclient import (
24 BlockingProxy,BranchFileSystemClient)25 BlockingProxy,BranchFileSystemClient)
2526
=== modified file 'lib/lp/codehosting/vfs/branchfs.py'
--- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:30 +0000
+++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:35 +0000
@@ -55,6 +55,7 @@
55 'DirectDatabaseLaunchpadServer',55 'DirectDatabaseLaunchpadServer',
56 'get_lp_server',56 'get_lp_server',
57 'get_multi_server',57 'get_multi_server',
58 'get_ro_server',
58 'get_rw_server',59 'get_rw_server',
59 'get_scanner_server',60 'get_scanner_server',
60 'make_branch_mirrorer',61 'make_branch_mirrorer',
@@ -167,15 +168,16 @@
167 return absolute_path.endswith('/.bzr/branch/lock/held')168 return absolute_path.endswith('/.bzr/branch/lock/held')
168169
169170
170def get_scanner_server():171def get_ro_server():
171 """Get a Launchpad internal server for scanning branches."""172 """Get a Launchpad internal server for scanning branches."""
172 proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)173 proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
173 codehosting_endpoint = BlockingProxy(proxy)174 codehosting_endpoint = BlockingProxy(proxy)
174 branch_transport = get_readonly_transport(175 branch_transport = get_readonly_transport(
175 get_transport(config.codehosting.internal_branch_by_id_root))176 get_transport(config.codehosting.internal_branch_by_id_root))
176 return LaunchpadInternalServer(177 return LaunchpadInternalServer(
177 'lp-mirrored:///', codehosting_endpoint, branch_transport)178 'lp-internal:///', codehosting_endpoint, branch_transport)
178179
180get_scanner_server = get_ro_server
179181
180def get_rw_server(direct_database=False):182def get_rw_server(direct_database=False):
181 """Get a server that can write to the Launchpad branch vfs.183 """Get a server that can write to the Launchpad branch vfs.
182184
=== modified file 'lib/lp/testing/__init__.py'
--- lib/lp/testing/__init__.py 2010-04-27 02:24:30 +0000
+++ lib/lp/testing/__init__.py 2010-04-27 02:24:35 +0000
@@ -412,6 +412,7 @@
412 from lp.testing.factory import LaunchpadObjectFactory412 from lp.testing.factory import LaunchpadObjectFactory
413 self.factory = LaunchpadObjectFactory()413 self.factory = LaunchpadObjectFactory()
414 self.direct_database_server = False414 self.direct_database_server = False
415 self._use_bzr_branch_called = False
415416
416 def getUserBrowser(self, url=None, user=None, password='test'):417 def getUserBrowser(self, url=None, user=None, password='test'):
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`.
@@ -478,9 +479,10 @@
478 :param db_branch: The database branch to create the branch for.479 :param db_branch: The database branch to create the branch for.
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.
480 """481 """
481 bzr_branch = self.createBranchAtURL(db_branch.warehouse_url)482 bzr_branch = self.createBranchAtURL(db_branch.getInternalBzrUrl())
482 if parent:483 if parent:
483 bzr_branch.pull(parent)484 bzr_branch.pull(parent)
485 removeSecurityProxy(db_branch).last_scanned_id = bzr_branch.last_revision()
484 return bzr_branch486 return bzr_branch
485487
486 @staticmethod488 @staticmethod
@@ -537,6 +539,11 @@
537 :param direct_database: If true, translate branch locations by539 :param direct_database: If true, translate branch locations by
538 directly querying the database, not the internal XML-RPC server.540 directly querying the database, not the internal XML-RPC server.
539 """541 """
542 if self._use_bzr_branch_called:
543 if direct_database != self.direct_database_server:
544 raise AssertionError("XXX")
545 return
546 self._use_bzr_branch_called = True
540 self.useTempBzrHome()547 self.useTempBzrHome()
541 self.direct_database_server = direct_database548 self.direct_database_server = direct_database
542 server = get_rw_server(direct_database=direct_database)549 server = get_rw_server(direct_database=direct_database)
543550
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-04-27 02:24:30 +0000
+++ lib/lp/testing/factory.py 2010-04-27 02:24:35 +0000
@@ -2284,8 +2284,8 @@
2284 md = MergeDirective2.from_objects(2284 md = MergeDirective2.from_objects(
2285 source_branch.repository, source_branch.last_revision(),2285 source_branch.repository, source_branch.last_revision(),
2286 public_branch=source_branch.get_public_branch(),2286 public_branch=source_branch.get_public_branch(),
2287 target_branch=target_branch.warehouse_url,2287 target_branch=target_branch.getInternalBzrUrl(),
2288 local_target_branch=target_branch.warehouse_url, time=0,2288 local_target_branch=target_branch.getInternalBzrUrl(), time=0,
2289 timezone=0)2289 timezone=0)
2290 email = None2290 email = None
2291 if sender is not None:2291 if sender is not None:
22922292
=== modified file 'lib/lp/translations/tests/test_translationtemplatesbuildjob.py'
--- lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2010-04-27 02:24:30 +0000
+++ lib/lp/translations/tests/test_translationtemplatesbuildjob.py 2010-04-27 02:24:35 +0000
@@ -149,7 +149,7 @@
149 def _makeTranslationBranch(self, fake_pottery_compatible=None):149 def _makeTranslationBranch(self, fake_pottery_compatible=None):
150 """Create a branch that provides translations for a productseries."""150 """Create a branch that provides translations for a productseries."""
151 if fake_pottery_compatible is None:151 if fake_pottery_compatible is None:
152 self.useBzrBranches()152 self.useBzrBranches(direct_database=True)
153 branch, tree = self.create_branch_and_tree()153 branch, tree = self.create_branch_and_tree()
154 else:154 else:
155 branch = self.factory.makeAnyBranch()155 branch = self.factory.makeAnyBranch()
@@ -219,6 +219,7 @@
219 # If the feature is enabled, a TipChanged event for a branch that219 # If the feature is enabled, a TipChanged event for a branch that
220 # generates templates will schedule a templates build.220 # generates templates will schedule a templates build.
221 branch = self._makeTranslationBranch()221 branch = self._makeTranslationBranch()
222 removeSecurityProxy(branch).last_scanned_id = 'null:'
222 commit = DirectBranchCommit(branch)223 commit = DirectBranchCommit(branch)
223 commit.writeFile('POTFILES.in', 'foo')224 commit.writeFile('POTFILES.in', 'foo')
224 commit.commit('message')225 commit.commit('message')

Subscribers

People subscribed via source and target branches

to status/vote changes: