Merge lp:~rockstar/launchpad/branch-upgrade-copy-bzr into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/branch-upgrade-copy-bzr
Merge into: lp:launchpad
Diff against target: 59 lines (+13/-7)
2 files modified
lib/lp/code/model/branchjob.py (+11/-7)
lib/lp/code/model/tests/test_branchjob.py (+2/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/branch-upgrade-copy-bzr
Reviewer Review Type Date Requested Status
Francis J. Lacoste (community) release-critical Approve
Aaron Bentley (community) Approve
Review via email: mp+21399@code.launchpad.net

Description of the change

This branch makes it so the branch upgrade job just copies over the .bzr and
not worry about the backup.bzr dirs (which seem to cause no end to problems).
It fixes bug #539238 and I would like to get it cherry picked.

My one concern is that this could be tested better. I left the current test
there, and removed some code. If you have a better testing strategy, I'm all
ears.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve
Revision history for this message
Francis J. Lacoste (flacoste) :
review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/branchjob.py'
2--- lib/lp/code/model/branchjob.py 2010-03-06 06:28:18 +0000
3+++ lib/lp/code/model/branchjob.py 2010-03-15 21:27:30 +0000
4@@ -20,6 +20,7 @@
5 import tempfile
6
7 from bzrlib.branch import Branch as BzrBranch
8+from bzrlib.errors import NoSuchFile
9 from bzrlib.log import log_formatter, show_log
10 from bzrlib.diff import show_diff_trees
11 from bzrlib.revision import NULL_REVISION
12@@ -324,14 +325,12 @@
13 upgrade_branch_path = tempfile.mkdtemp()
14 try:
15 upgrade_transport = get_transport(upgrade_branch_path)
16+ upgrade_transport.mkdir('.bzr')
17 source_branch_transport = get_transport(self.branch.getPullURL())
18- source_branch_transport.copy_tree_to_transport(upgrade_transport)
19+ source_branch_transport.clone('.bzr').copy_tree_to_transport(
20+ upgrade_transport.clone('.bzr'))
21 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)
22
23- # If there's already a backup.bzr, delete it.
24- if upgrade_transport.has('backup.bzr'):
25- upgrade_transport.delete_tree('backup.bzr')
26-
27 # Perform the upgrade.
28 upgrade(upgrade_branch.base)
29
30@@ -347,9 +346,14 @@
31 source_branch.unlock()
32
33 # Move the branch in the old format to backup.bzr
34- upgrade_transport.delete_tree('backup.bzr')
35+ try:
36+ source_branch_transport.delete_tree('backup.bzr')
37+ except NoSuchFile:
38+ pass
39 source_branch_transport.rename('.bzr', 'backup.bzr')
40- upgrade_transport.copy_tree_to_transport(source_branch_transport)
41+ source_branch_transport.mkdir('.bzr')
42+ upgrade_transport.clone('.bzr').copy_tree_to_transport(
43+ source_branch_transport.clone('.bzr'))
44
45 self.branch.requestMirror()
46 finally:
47
48=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
49--- lib/lp/code/model/tests/test_branchjob.py 2010-03-10 05:49:00 +0000
50+++ lib/lp/code/model/tests/test_branchjob.py 2010-03-15 21:27:30 +0000
51@@ -287,6 +287,8 @@
52 # Add a fake backup.bzr dir
53 source_branch_transport = get_transport(db_branch.getPullURL())
54 source_branch_transport.mkdir('backup.bzr')
55+ source_branch_transport.clone('.bzr').copy_tree_to_transport(
56+ source_branch_transport.clone('backup.bzr'))
57
58 job = BranchUpgradeJob.create(db_branch)
59 job.run()