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
=== modified file 'lib/lp/code/model/branchjob.py'
--- lib/lp/code/model/branchjob.py 2010-03-06 06:28:18 +0000
+++ lib/lp/code/model/branchjob.py 2010-03-15 21:27:30 +0000
@@ -20,6 +20,7 @@
20import tempfile20import tempfile
2121
22from bzrlib.branch import Branch as BzrBranch22from bzrlib.branch import Branch as BzrBranch
23from bzrlib.errors import NoSuchFile
23from bzrlib.log import log_formatter, show_log24from bzrlib.log import log_formatter, show_log
24from bzrlib.diff import show_diff_trees25from bzrlib.diff import show_diff_trees
25from bzrlib.revision import NULL_REVISION26from bzrlib.revision import NULL_REVISION
@@ -324,14 +325,12 @@
324 upgrade_branch_path = tempfile.mkdtemp()325 upgrade_branch_path = tempfile.mkdtemp()
325 try:326 try:
326 upgrade_transport = get_transport(upgrade_branch_path)327 upgrade_transport = get_transport(upgrade_branch_path)
328 upgrade_transport.mkdir('.bzr')
327 source_branch_transport = get_transport(self.branch.getPullURL())329 source_branch_transport = get_transport(self.branch.getPullURL())
328 source_branch_transport.copy_tree_to_transport(upgrade_transport)330 source_branch_transport.clone('.bzr').copy_tree_to_transport(
331 upgrade_transport.clone('.bzr'))
329 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)332 upgrade_branch = BzrBranch.open_from_transport(upgrade_transport)
330333
331 # If there's already a backup.bzr, delete it.
332 if upgrade_transport.has('backup.bzr'):
333 upgrade_transport.delete_tree('backup.bzr')
334
335 # Perform the upgrade.334 # Perform the upgrade.
336 upgrade(upgrade_branch.base)335 upgrade(upgrade_branch.base)
337336
@@ -347,9 +346,14 @@
347 source_branch.unlock()346 source_branch.unlock()
348347
349 # Move the branch in the old format to backup.bzr348 # Move the branch in the old format to backup.bzr
350 upgrade_transport.delete_tree('backup.bzr')349 try:
350 source_branch_transport.delete_tree('backup.bzr')
351 except NoSuchFile:
352 pass
351 source_branch_transport.rename('.bzr', 'backup.bzr')353 source_branch_transport.rename('.bzr', 'backup.bzr')
352 upgrade_transport.copy_tree_to_transport(source_branch_transport)354 source_branch_transport.mkdir('.bzr')
355 upgrade_transport.clone('.bzr').copy_tree_to_transport(
356 source_branch_transport.clone('.bzr'))
353357
354 self.branch.requestMirror()358 self.branch.requestMirror()
355 finally:359 finally:
356360
=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py 2010-03-10 05:49:00 +0000
+++ lib/lp/code/model/tests/test_branchjob.py 2010-03-15 21:27:30 +0000
@@ -287,6 +287,8 @@
287 # Add a fake backup.bzr dir287 # Add a fake backup.bzr dir
288 source_branch_transport = get_transport(db_branch.getPullURL())288 source_branch_transport = get_transport(db_branch.getPullURL())
289 source_branch_transport.mkdir('backup.bzr')289 source_branch_transport.mkdir('backup.bzr')
290 source_branch_transport.clone('.bzr').copy_tree_to_transport(
291 source_branch_transport.clone('backup.bzr'))
290292
291 job = BranchUpgradeJob.create(db_branch)293 job = BranchUpgradeJob.create(db_branch)
292 job.run()294 job.run()