Code review comment for lp:~rockstar/launchpad/branch-upgrade-out-of-place

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

 merge approve

All but fine now...

Paul Hummer wrote:

> === modified file 'lib/lp/code/model/branchjob.py'
> --- lib/lp/code/model/branchjob.py 2009-10-21 23:34:08 +0000
> +++ lib/lp/code/model/branchjob.py 2009-10-22 04:22:18 +0000
> @@ -257,28 +257,32 @@
> """See `IBranchUpgradeJob`."""
> # Set up the new branch structure
> upgrade_branch_path = tempfile.mkdtemp()
> - upgrade_transport = get_transport(upgrade_branch_path)
> - source_branch = self.branch.getBzrBranch()
> - source_branch_transport = source_branch.bzrdir.root_transport
> - source_branch_transport.copy_tree_to_transport(upgrade_transport)
> - upgrade_branch = BzrBranch.open(upgrade_transport.base)
> -
> - # Perform the upgrade.
> - upgrade(upgrade_branch.base, self.upgrade_format)
> -
> - # Re-open the branch, since its format has changed.
> - upgrade_branch = BzrBranch.open(upgrade_transport.base)
> - upgrade_branch.pull(source_branch)
> - upgrade_branch.fetch(source_branch)
> -
> - # Move the branch in the old format to backup.bzr
> - source_branch_transport.rename('.bzr', 'backup.bzr')
> - upgrade_transport.delete_tree('backup.bzr')
> - upgrade_transport.copy_tree_to_transport(source_branch_transport)
> -
> - # Clean up the temporary directory.
> - upgrade_transport.delete_tree('.bzr')
> - os.rmdir(upgrade_branch_path)
> + try:
> + upgrade_transport = get_transport(upgrade_branch_path)
> + source_branch_transport = get_transport(self.branch.getPullURL())
> + source_branch_transport.copy_tree_to_transport(upgrade_transport)
> + upgrade_branch = BzrBranch.open(upgrade_transport.base)
> +
> + # Perform the upgrade.
> + upgrade(upgrade_branch.base, self.upgrade_format)
> +
> + # Re-open the branch, since its format has changed.
> + upgrade_branch = BzrBranch.open_from_transport(
> + upgrade_transport)
> + source_branch = BzrBranch.open_from_transport(
> + source_branch_transport)
> +
> + source_branch.lock_write()
> + upgrade_branch.pull(source_branch)
> + upgrade_branch.fetch(source_branch)
> + source_branch.unlock()
> +
> + # Move the branch in the old format to backup.bzr
> + source_branch_transport.rename('.bzr', 'backup.bzr')
> + upgrade_transport.delete_tree('backup.bzr')

You don't need this line.

> + upgrade_transport.copy_tree_to_transport(source_branch_transport)
> + finally:
> + shutil.rmtree(upgrade_branch_path)
>
> @property
> def upgrade_format(self):

Cheers,
mwh
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrf4tAACgkQeTTOPm7A7kjE3gCfcqpSHwpQHkYyUFe6nBycGfSb
gdAAoILC14HcnXFuSv0kbBRrhRDD9StK
=zuVZ
-----END PGP SIGNATURE-----

review: Approve

« Back to merge proposal