Merge lp:~rockstar/launchpad/bug-532290 into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/bug-532290
Merge into: lp:launchpad
Diff against target: 72 lines (+28/-1)
3 files modified
.bzrignore (+1/-0)
lib/lp/code/model/branchjob.py (+5/-1)
lib/lp/code/model/tests/test_branchjob.py (+22/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/bug-532290
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) rc Approve
Guilherme Salgado (community) code Approve
Review via email: mp+20772@code.launchpad.net

Description of the change

Hi there-

  This branch fixes bug #532290. Basically, when a branch is upgraded,
versions of Bazaar < 2.2 will copy the .bzr directory to backup.bzr, and then
do the upgrade. This means that if something gets borked, there's an automatic
backup.

  The bug was caused when you request a branch be upgraded that already had a
backup.bzr directory. When the branch is cloned, it clones that backup and
then can't upgrade because the backup is in the way.

  The fix is just to remove that backup.bzr from the cloned version previous to
upgrading the branch.

Cheers,
Paul

To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

As per discussion on IRC, just remove the pdb call and revert the wadl files from .bzrignore as Leonard has a better fix for that in one of his branches.

review: Approve (code)
Revision history for this message
Francis J. Lacoste (flacoste) wrote :

Land this on production-devel and then request its deployment on LPS.

review: Approve (rc)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '.bzrignore'
--- .bzrignore 2010-02-23 21:48:53 +0000
+++ .bzrignore 2010-03-05 19:48:30 +0000
@@ -60,3 +60,4 @@
60.testrepository60.testrepository
61.memcache.pid61.memcache.pid
62./pipes62./pipes
63tags.new
6364
=== modified file 'lib/lp/code/model/branchjob.py'
--- lib/lp/code/model/branchjob.py 2010-02-22 12:28:46 +0000
+++ lib/lp/code/model/branchjob.py 2010-03-05 19:48:30 +0000
@@ -274,7 +274,7 @@
274274
275 @classmethod275 @classmethod
276 def create(cls, branch):276 def create(cls, branch):
277 """See `IBranchUpgradeJobSource`."""277 """See `IBranchScanJobSource`."""
278 branch_job = BranchJob(branch, BranchJobType.SCAN_BRANCH, {})278 branch_job = BranchJob(branch, BranchJobType.SCAN_BRANCH, {})
279 return cls(branch_job)279 return cls(branch_job)
280280
@@ -345,6 +345,10 @@
345 source_branch_transport.copy_tree_to_transport(upgrade_transport)345 source_branch_transport.copy_tree_to_transport(upgrade_transport)
346 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)346 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)
347347
348 # If there's already a backup.bzr, delete it.
349 if upgrade_transport.has('backup.bzr'):
350 upgrade_transport.delete_tree('backup.bzr')
351
348 # Perform the upgrade.352 # Perform the upgrade.
349 upgrade(upgrade_branch.base)353 upgrade(upgrade_branch.base)
350354
351355
=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py 2010-02-23 22:08:43 +0000
+++ lib/lp/code/model/tests/test_branchjob.py 2010-03-05 19:48:30 +0000
@@ -17,6 +17,7 @@
17from bzrlib.bzrdir import BzrDirMetaFormat117from bzrlib.bzrdir import BzrDirMetaFormat1
18from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack618from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack6
19from bzrlib.revision import NULL_REVISION19from bzrlib.revision import NULL_REVISION
20from bzrlib.transport import get_transport
20from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer21from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
21from sqlobject import SQLObjectNotFound22from sqlobject import SQLObjectNotFound
22import transaction23import transaction
@@ -274,6 +275,27 @@
274 repository_format=RepositoryFormat.BZR_CHK_2A)275 repository_format=RepositoryFormat.BZR_CHK_2A)
275 self.assertRaises(AssertionError, BranchUpgradeJob.create, branch)276 self.assertRaises(AssertionError, BranchUpgradeJob.create, branch)
276277
278 def test_existing_bzr_backup(self):
279 # If the target branch already has a backup.bzr dir, the upgrade copy
280 # should remove it.
281 self.useBzrBranches()
282 db_branch, tree = self.create_branch_and_tree(
283 hosted=True, format='knit')
284 db_branch.branch_format = BranchFormat.BZR_BRANCH_5
285 db_branch.repository_format = RepositoryFormat.BZR_KNIT_1
286
287 # Add a fake backup.bzr dir
288 source_branch_transport = get_transport(db_branch.getPullURL())
289 source_branch_transport.mkdir('backup.bzr')
290
291 job = BranchUpgradeJob.create(db_branch)
292 job.run()
293
294 new_branch = Branch.open(tree.branch.base)
295 self.assertEqual(
296 new_branch.repository._format.get_format_string(),
297 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
298
277299
278class TestRevisionMailJob(TestCaseWithFactory):300class TestRevisionMailJob(TestCaseWithFactory):
279 """Tests for BranchDiffJob."""301 """Tests for BranchDiffJob."""