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
1=== modified file '.bzrignore'
2--- .bzrignore 2010-02-23 21:48:53 +0000
3+++ .bzrignore 2010-03-05 19:48:30 +0000
4@@ -60,3 +60,4 @@
5 .testrepository
6 .memcache.pid
7 ./pipes
8+tags.new
9
10=== modified file 'lib/lp/code/model/branchjob.py'
11--- lib/lp/code/model/branchjob.py 2010-02-22 12:28:46 +0000
12+++ lib/lp/code/model/branchjob.py 2010-03-05 19:48:30 +0000
13@@ -274,7 +274,7 @@
14
15 @classmethod
16 def create(cls, branch):
17- """See `IBranchUpgradeJobSource`."""
18+ """See `IBranchScanJobSource`."""
19 branch_job = BranchJob(branch, BranchJobType.SCAN_BRANCH, {})
20 return cls(branch_job)
21
22@@ -345,6 +345,10 @@
23 source_branch_transport.copy_tree_to_transport(upgrade_transport)
24 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)
25
26+ # If there's already a backup.bzr, delete it.
27+ if upgrade_transport.has('backup.bzr'):
28+ upgrade_transport.delete_tree('backup.bzr')
29+
30 # Perform the upgrade.
31 upgrade(upgrade_branch.base)
32
33
34=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
35--- lib/lp/code/model/tests/test_branchjob.py 2010-02-23 22:08:43 +0000
36+++ lib/lp/code/model/tests/test_branchjob.py 2010-03-05 19:48:30 +0000
37@@ -17,6 +17,7 @@
38 from bzrlib.bzrdir import BzrDirMetaFormat1
39 from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack6
40 from bzrlib.revision import NULL_REVISION
41+from bzrlib.transport import get_transport
42 from canonical.testing import DatabaseFunctionalLayer, LaunchpadZopelessLayer
43 from sqlobject import SQLObjectNotFound
44 import transaction
45@@ -274,6 +275,27 @@
46 repository_format=RepositoryFormat.BZR_CHK_2A)
47 self.assertRaises(AssertionError, BranchUpgradeJob.create, branch)
48
49+ def test_existing_bzr_backup(self):
50+ # If the target branch already has a backup.bzr dir, the upgrade copy
51+ # should remove it.
52+ self.useBzrBranches()
53+ db_branch, tree = self.create_branch_and_tree(
54+ hosted=True, format='knit')
55+ db_branch.branch_format = BranchFormat.BZR_BRANCH_5
56+ db_branch.repository_format = RepositoryFormat.BZR_KNIT_1
57+
58+ # Add a fake backup.bzr dir
59+ source_branch_transport = get_transport(db_branch.getPullURL())
60+ source_branch_transport.mkdir('backup.bzr')
61+
62+ job = BranchUpgradeJob.create(db_branch)
63+ job.run()
64+
65+ new_branch = Branch.open(tree.branch.base)
66+ self.assertEqual(
67+ new_branch.repository._format.get_format_string(),
68+ 'Bazaar repository format 2a (needs bzr 1.16 or later)\n')
69+
70
71 class TestRevisionMailJob(TestCaseWithFactory):
72 """Tests for BranchDiffJob."""