Merge lp:~jelmer/launchpad/auto-upgrade into lp:launchpad

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 13219
Proposed branch: lp:~jelmer/launchpad/auto-upgrade
Merge into: lp:launchpad
Diff against target: 198 lines (+78/-57)
3 files modified
lib/lp/code/browser/branch.py (+0/-2)
lib/lp/codehosting/codeimport/tests/test_worker.py (+46/-46)
lib/lp/codehosting/codeimport/worker.py (+32/-9)
To merge this branch: bzr merge lp:~jelmer/launchpad/auto-upgrade
Reviewer Review Type Date Requested Status
Benji York (community) code Approve
Review via email: mp+64398@code.launchpad.net

Commit message

[r=benji][bug=432217] Reintroduce automatic upgrades of code imports.

Description of the change

Reintroduce automatic upgrades of code imports.

Automatic upgrades of code imports were disabled in September 2009 because they were much too slow. In particular because the upgrade from knits to 2a was very slow and memory hogging.

Bazaar is now much faster at doing upgrades.

This branch also fixes the worker to no longer do the upgrade on the remote branch. Instead, the worker upgrades its local branch and then replaces the remote branch with that.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

This branch looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2011-05-27 21:12:25 +0000
+++ lib/lp/code/browser/branch.py 2011-06-13 12:40:06 +0000
@@ -118,7 +118,6 @@
118from lp.bugs.interfaces.bug import IBugSet118from lp.bugs.interfaces.bug import IBugSet
119from lp.bugs.interfaces.bugbranch import IBugBranch119from lp.bugs.interfaces.bugbranch import IBugBranch
120from lp.bugs.interfaces.bugtask import UNRESOLVED_BUGTASK_STATUSES120from lp.bugs.interfaces.bugtask import UNRESOLVED_BUGTASK_STATUSES
121from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJobSet
122from lp.code.browser.branchmergeproposal import (121from lp.code.browser.branchmergeproposal import (
123 latest_proposals_for_each_branch,122 latest_proposals_for_each_branch,
124 )123 )
@@ -126,7 +125,6 @@
126from lp.code.browser.decorations import DecoratedBranch125from lp.code.browser.decorations import DecoratedBranch
127from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin126from lp.code.browser.sourcepackagerecipelisting import HasRecipesMenuMixin
128from lp.code.enums import (127from lp.code.enums import (
129 BranchLifecycleStatus,
130 BranchType,128 BranchType,
131 CodeImportResultStatus,129 CodeImportResultStatus,
132 CodeImportReviewStatus,130 CodeImportReviewStatus,
133131
=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py 2011-06-01 15:52:13 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2011-06-13 12:40:06 +0000
@@ -29,7 +29,6 @@
29from bzrlib.tests import TestCaseWithTransport29from bzrlib.tests import TestCaseWithTransport
30from bzrlib import trace30from bzrlib import trace
31from bzrlib.transport import get_transport31from bzrlib.transport import get_transport
32from bzrlib.upgrade import upgrade
33from bzrlib.urlutils import (32from bzrlib.urlutils import (
34 join as urljoin,33 join as urljoin,
35 local_path_from_url,34 local_path_from_url,
@@ -204,51 +203,52 @@
204 self.arbitrary_branch_id, self.temp_dir, default_format, True)203 self.arbitrary_branch_id, self.temp_dir, default_format, True)
205 self.assertTrue(new_branch.bzrdir.has_workingtree())204 self.assertTrue(new_branch.bzrdir.has_workingtree())
206205
207 # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import206 def test_pullUpgradesFormat(self):
208 # branches disabled. Need an orderly upgrade process.207 # A branch should always be in the most up-to-date format before a
209 def disabled_test_pullUpgradesFormat(self):208 # pull is performed.
210 # A branch should always be in the most up-to-date format before a209 store = self.makeBranchStore()
211 # pull is performed.210 target_url = store._getMirrorURL(self.arbitrary_branch_id)
212 store = self.makeBranchStore()211 knit_format = format_registry.get('knit')()
213 target_url = store._getMirrorURL(self.arbitrary_branch_id)212 create_branch_with_one_revision(target_url, format=knit_format)
214 knit_format = format_registry.get('knit')()213 default_format = BzrDirFormat.get_default_format()
215 create_branch_with_one_revision(target_url, format=knit_format)214
216 default_format = BzrDirFormat.get_default_format()215 # The fetched branch is in the default format.
217216 new_branch = store.pull(
218 # The fetched branch is in the default format.217 self.arbitrary_branch_id, self.temp_dir, default_format)
219 new_tree = store.pull(218 self.assertEqual(
220 self.arbitrary_branch_id, self.temp_dir, default_format)219 default_format, new_branch.bzrdir._format)
221 self.assertEqual(220
222 default_format, new_tree.branch.bzrdir._format)221 def test_pushUpgradesFormat(self):
223222 # A branch should always be in the most up-to-date format before a
224 # In addition. the remote branch has been upgraded as well.223 # pull is performed.
225 new_branch = Branch.open(target_url)224 store = self.makeBranchStore()
226 self.assertEqual(225 target_url = store._getMirrorURL(self.arbitrary_branch_id)
227 default_format.get_branch_format(), new_branch._format)226 knit_format = format_registry.get('knit')()
228227 create_branch_with_one_revision(target_url, format=knit_format)
229 # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import228 default_format = BzrDirFormat.get_default_format()
230 # branches disabled. Need an orderly upgrade process.229
231 def disabled_test_pullUpgradesFormatWithBackupDirPresent(self):230 # The fetched branch is in the default format.
232 # pull can upgrade the remote branch even if there is a backup.bzr231 new_branch = store.pull(
233 # directory from a previous upgrade.232 self.arbitrary_branch_id, self.temp_dir, default_format)
234 store = self.makeBranchStore()233 self.assertEqual(
235 target_url = store._getMirrorURL(self.arbitrary_branch_id)234 default_format, new_branch.bzrdir._format)
236 knit_format = format_registry.get('knit')()235
237 create_branch_with_one_revision(target_url, format=knit_format)236 # The remote branch is still in the old format at this point.
238 upgrade(target_url, format_registry.get('dirstate-tags')())237 target_branch = Branch.open(target_url)
239 self.failUnless(get_transport(target_url).has('backup.bzr'))238 self.assertEqual(
240 default_format = BzrDirFormat.get_default_format()239 knit_format.get_branch_format(),
241240 target_branch._format)
242 # The fetched branch is in the default format.241
243 new_tree = store.pull(242 store.push(self.arbitrary_branch_id, new_branch, default_format)
244 self.arbitrary_branch_id, self.temp_dir, default_format)243
245 self.assertEqual(244 # The remote branch is now in the new format.
246 default_format, new_tree.branch.bzrdir._format)245 target_branch = Branch.open(target_url)
247246 self.assertEqual(
248 # In addition. the remote branch has been upgraded as well.247 default_format.get_branch_format(),
249 new_branch = Branch.open(target_url)248 target_branch._format)
250 self.assertEqual(249 self.assertEquals(
251 default_format.get_branch_format(), new_branch._format)250 target_branch.last_revision_info(),
251 new_branch.last_revision_info())
252252
253 def test_pushTwiceThenPull(self):253 def test_pushTwiceThenPull(self):
254 # We can push up a branch to the store twice and then pull it from the254 # We can push up a branch to the store twice and then pull it from the
255255
=== modified file 'lib/lp/codehosting/codeimport/worker.py'
--- lib/lp/codehosting/codeimport/worker.py 2011-06-01 15:59:45 +0000
+++ lib/lp/codehosting/codeimport/worker.py 2011-06-13 12:40:06 +0000
@@ -95,15 +95,6 @@
95 if needs_tree:95 if needs_tree:
96 local_branch.bzrdir.create_workingtree()96 local_branch.bzrdir.create_workingtree()
97 return local_branch97 return local_branch
98 # XXX Tim Penhey 2009-09-18 bug 432217 Automatic upgrade of import
99 # branches disabled. Need an orderly upgrade process.
100 if False and remote_bzr_dir.needs_format_conversion(
101 format=required_format):
102 try:
103 remote_bzr_dir.root_transport.delete_tree('backup.bzr')
104 except NoSuchFile:
105 pass
106 upgrade(remote_url, required_format)
107 # The proper thing to do here would be to call98 # The proper thing to do here would be to call
108 # "remote_bzr_dir.sprout()". But 2a fetch slowly checks which99 # "remote_bzr_dir.sprout()". But 2a fetch slowly checks which
109 # revisions are in the ancestry of the tip of the remote branch, which100 # revisions are in the ancestry of the tip of the remote branch, which
@@ -116,6 +107,13 @@
116 target_control.create_prefix()107 target_control.create_prefix()
117 remote_bzr_dir.transport.copy_tree_to_transport(target_control)108 remote_bzr_dir.transport.copy_tree_to_transport(target_control)
118 local_bzr_dir = BzrDir.open_from_transport(target)109 local_bzr_dir = BzrDir.open_from_transport(target)
110 if local_bzr_dir.needs_format_conversion(
111 format=required_format):
112 try:
113 local_bzr_dir.root_transport.delete_tree('backup.bzr')
114 except NoSuchFile:
115 pass
116 upgrade(target_path, required_format)
119 if needs_tree:117 if needs_tree:
120 local_bzr_dir.create_workingtree()118 local_bzr_dir.create_workingtree()
121 return local_bzr_dir.open_branch()119 return local_bzr_dir.open_branch()
@@ -133,11 +131,36 @@
133 except NotBranchError:131 except NotBranchError:
134 remote_branch = BzrDir.create_branch_and_repo(132 remote_branch = BzrDir.create_branch_and_repo(
135 target_url, format=required_format)133 target_url, format=required_format)
134 old_branch = None
135 else:
136 if remote_branch.bzrdir.needs_format_conversion(
137 required_format):
138 # For upgrades, push to a new branch in
139 # the new format. When done pushing,
140 # retire the old .bzr directory and rename
141 # the new one in place.
142 old_branch = remote_branch
143 upgrade_url = urljoin(target_url, "upgrade.bzr")
144 try:
145 remote_branch.bzrdir.root_transport.delete_tree(
146 'upgrade.bzr')
147 except NoSuchFile:
148 pass
149 remote_branch = BzrDir.create_branch_and_repo(
150 upgrade_url, format=required_format)
151 else:
152 old_branch = None
136 pull_result = remote_branch.pull(bzr_branch, overwrite=True)153 pull_result = remote_branch.pull(bzr_branch, overwrite=True)
137 # Because of the way we do incremental imports, there may be revisions154 # Because of the way we do incremental imports, there may be revisions
138 # in the branch's repo that are not in the ancestry of the branch tip.155 # in the branch's repo that are not in the ancestry of the branch tip.
139 # We need to transfer them too.156 # We need to transfer them too.
140 remote_branch.repository.fetch(bzr_branch.repository)157 remote_branch.repository.fetch(bzr_branch.repository)
158 if old_branch is not None:
159 # The format has changed; move the new format
160 # branch in place.
161 base_transport = old_branch.bzrdir.root_transport
162 old_branch.bzrdir.retire_bzrdir()
163 base_transport.rename("upgrade.bzr/.bzr", ".bzr")
141 return pull_result.old_revid != pull_result.new_revid164 return pull_result.old_revid != pull_result.new_revid
142165
143166