[MERGE] migrate switch command into the core

Aaron Bentley aaron.bentley at utoronto.ca
Fri Nov 16 15:29:55 GMT 2007


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

bb:resubmit

Ian Clatworthy wrote:
> I've added their
> names to the NEWS item but removed their names from the file headers for
> the sake of standardising the copyright header.

I think you should be a bit less cavalier about this.  Socially, it's
just polite to explicitly ask someone before you reassign their
copyright.  Legally, I think you're required to.  Of course, I'm happy
to reassign my copyright.

I think you should also retain the 2006 copyright date, i.e. it should
read: "Copyright (C) 2006, 2007 Canonical Ltd."

> +def _update(tree, source_repository, to_branch):
> +    tree.lock_tree_write()
> +    try:
> +        if tree.last_revision() == tree.branch.last_revision():
> +            note("Tree is up to date.")
> +            return

^^^ something wacky here; if to_branch == tree.branch, why do we need both?

> +def set_branch_location(control, to_branch):
> +    """Set location value of a branch reference.
> +
> +    :param control: BzrDir containing the branch reference
> +    :param location: value to write to the branch reference location.
> +    """
> +    _check_switch_branch_format(control)
> +    branch_format = BranchFormat.find_format(control)

^^^ branch_format appears unused.

> +class TestSwitch(tests.TestCaseWithTransport):
> +
> +    def test_switch_moved(self):
> +        tree = self.make_branch_and_tree('branch-1')
> +        self.build_tree(['branch-1/file-1'])
> +        tree.add('file-1')
> +        tree.commit('rev1')
> +        checkout = tree.branch.create_checkout('checkout', lightweight=True)
> +        self.build_tree(['branch-1/file-2'])
> +        tree.add('file-2')
> +        tree.remove('file-1')
> +        tree.commit('rev2')
> +        os.rename('branch-1', 'branch-2')
> +        to_branch = branch.Branch.open('branch-2')
> +        self.build_tree(['checkout/file-3'])
> +        checkout.add('file-3')
> +        switch.switch(checkout.bzrdir, to_branch)
> +        self.failIfExists('checkout/file-1')
> +        self.failUnlessExists('checkout/file-2')
> +        self.failUnlessExists('checkout/file-3')
> +
> +    def test_switch_old(self):
> +        tree = self.make_branch_and_tree('branch-1')
> +        self.build_tree(['branch-1/file-1'])
> +        tree.add('file-1')
> +        tree.commit('rev1')
> +        to_branch = tree.bzrdir.sprout('branch-2').open_branch()
> +        self.build_tree(['branch-1/file-2'])
> +        tree.add('file-2')
> +        tree.remove('file-1')
> +        tree.commit('rev2')
> +        checkout = tree.branch.create_checkout('checkout', lightweight=True)
> +        self.build_tree(['checkout/file-3'])
> +        checkout.add('file-3')
> +        self.failIfExists('checkout/file-1')
> +        self.failUnlessExists('checkout/file-2')
> +        switch.switch(checkout.bzrdir, to_branch)
> +        self.failUnlessExists('checkout/file-1')
> +        self.failIfExists('checkout/file-2')
> +        self.failUnlessExists('checkout/file-3')
> +
> +    def test_switch_heavy_checkout(self):
> +        tree = self.make_branch_and_tree('branch-1')
> +        self.build_tree(['branch-1/file-1'])
> +        tree.add('file-1')
> +        tree.commit('rev1')
> +        tree.branch.create_checkout('checkout-1', lightweight=False)
> +        branch2 = self.make_branch('branch-2')
> +        err = self.assertRaises(errors.BzrCommandError,
> +                                switch.switch, tree.bzrdir, branch2)
> +        self.assertContainsRe(str(err),
> +            "The switch command can only be used on a lightweight checkout")

It would be nice to factor the fixture code out.

Also, we need at least one blackbox test.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHPbdz0F+nu1YWqI0RAr0yAJ94QXJudIKi4dtX3A2y63dBLNH2mwCdHorn
e0acmC3SuxzIOBxiTaM3lA0=
=gUa1
-----END PGP SIGNATURE-----



More information about the bazaar mailing list