[PATCH] upgrade v6 branches without checkout files to metadir

John Arbash Meinel john at arbash-meinel.com
Mon Aug 14 17:48:33 BST 2006


David Allouche wrote:
> After squashing the list_dir quoting bug, I hit a second roadblock.
> 
> The v6 branches I was trying to upgrade had no checkout-related files.
> No inventory or pending-merges files. However, the metadir upgrade code
> required those files to be present.
> 
> This patch makes the metadir upgrade a bit smarter. If either inventory
> or pending-merges is missing from a v6 branch, it does not have working
> tree functionality, so the conversion result should not have a working
> tree. Since that may be a bit surprising, a note is displayed to the
> effect that no working tree was converted.
> 
> Note that I _really_ do not want my converted branches to have working
> trees, since I am upgrading via SFTP a branch that was created by
> pushing via SFTP, and I do not want the conversion result to be
> structurally different from a branch initially pushed in metadir format.
> 
> Please CC me in replies to this message.
> 
> 
> ------------------------------------------------------------------------
> 
> === modified file 'bzrlib/bzrdir.py'
> --- bzrlib/bzrdir.py	2006-05-19 07:57:09 +0000
> +++ bzrlib/bzrdir.py	2006-08-11 21:42:26 +0000
> @@ -1742,20 +1742,39 @@
>          for entry in branch_files:
>              self.move_entry('branch', entry)
>  
> -        self.step('Upgrading working tree')
> -        self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
> -        self.make_lock('checkout')
> -        self.put_format('checkout', bzrlib.workingtree.WorkingTreeFormat3())
> -        self.bzrdir.transport.delete_multi(self.garbage_inventories, self.pb)
>          checkout_files = [('pending-merges', True),
>                            ('inventory', True),
>                            ('stat-cache', False)]
> -        for entry in checkout_files:
> -            self.move_entry('checkout', entry)
> -        if last_revision is not None:
> -            self.bzrdir._control_files.put_utf8('checkout/last-revision',
> -                                                last_revision)
> -        self.bzrdir._control_files.put_utf8('branch-format', BzrDirMetaFormat1().get_format_string())
> +        # If a mandatory checkout file is not present, the branch does not have
> +        # a functional checkout. Do not create a checkout in the converted
> +        # branch.
> +        for name, mandatory in checkout_files:
> +            if mandatory and name not in bzrcontents:
> +                has_checkout = False
> +                break
> +        else:
> +            has_checkout = True
> +        if not has_checkout:
> +            self.pb.note('No working tree.')
> +            # If some checkout files are there, we may as well get rid of them.
> +            for name, mandatory in checkout_files:
> +                if name in bzrcontents:
> +                    self.bzrdir.transport.delete(name)
> +        else:
> +            self.step('Upgrading working tree')
> +            self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
> +            self.make_lock('checkout')
> +            self.put_format(
> +                'checkout', bzrlib.workingtree.WorkingTreeFormat3())
> +            self.bzrdir.transport.delete_multi(
> +                self.garbage_inventories, self.pb)
> +            for entry in checkout_files:
> +                self.move_entry('checkout', entry)
> +            if last_revision is not None:
> +                self.bzrdir._control_files.put_utf8(
> +                    'checkout/last-revision', last_revision)
> +        self.bzrdir._control_files.put_utf8(
> +            'branch-format', BzrDirMetaFormat1().get_format_string())
>          return BzrDir.open(self.bzrdir.root_transport.base)
>  
>      def make_lock(self, name):

^- Looks reasonable to me
> 
> === modified file 'bzrlib/tests/test_upgrade.py'
> --- bzrlib/tests/test_upgrade.py	2006-04-18 22:41:16 +0000
> +++ bzrlib/tests/test_upgrade.py	2006-08-11 21:45:48 +0000
> @@ -47,6 +47,8 @@
>  
>      def test_upgrade_simple(self):
>          """Upgrade simple v0.0.4 format to v6"""
> +        # XXX: Lying docstring, that upgrades to the default format, which is
> +        # currently knits version 1. -- David Allouche 2006-08-11

So why not fix the docstring to say 'Upgrade simple v0.0.4 to latest
version"?


v-- It seems a little silly to upgrade a v4 branch to a v6 branch, just
to update from a v6 to a meta. Rather than building a v6 from scratch.

> +    def test_upgrade_v6_to_meta_no_workingtree(self):
> +        # Some format6 branches do not have checkout files. Upgrading
> +        # such a branch to metadir must not setup a working tree.
> +        self.build_tree_contents(_upgrade1_template)
> +        upgrade('.', bzrdir.BzrDirFormat6())
> +        transport = get_transport('.')
> +        transport.delete_multi(['.bzr/pending-merges', '.bzr/inventory'])
> +        assert not transport.has('.bzr/stat-cache')
> +        # XXX: upgrade fails if a .bzr.backup is already present
> +        # -- David Allouche 2006-08-11
> +        transport.delete_tree('.bzr.backup')
> +        # At this point, we have a format6 branch without checkout files.
> +        upgrade('.', bzrdir.BzrDirMetaFormat1())

...

If we can give a good response to my concerns, it has my +1.

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060814/37d226d8/attachment.pgp 


More information about the bazaar mailing list