[MERGE] print info after init and init-repo

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jul 16 07:13:58 BST 2008


>>>>> "Marius" == Marius Kruger <amanic at gmail.com> writes:

    Marius> hi
    Marius> I changed `bzr init` and `bzr init-repo` to print out
    Marius> the same as `bzr info` if it completed successfully
    Marius> (and if we're not in quiet mode)

    Marius> I managed to get the tests to pass again (modelled after the info and pull
    Marius> tests),
    Marius> but I'm concerned about:
    Marius> 1) In <bzrlib/tests/commands/test_init.py> and
    Marius> <bzrlib/tests/commands/test_init.py>
    Marius>    I had to do the following:
    Marius> -        self.assertEquals(1, len(self.connections))
    Marius> +        self.assertEquals(2, len(self.connections))
    Marius>    I'm not sure if this sort of thing is acceptable or how to properly fix
    Marius> it,

It is not. The purpose of the test is to check that a single
connection to the server is used, for performance reasons but
also because the user will be prompted for its password again
otherwise.


    Marius>    but I found it in one other place:
    Marius>    bzrlib/tests/commands/test_branch.py:42:        self.assertEquals(2,
    Marius> len(self.connections)

This one is different because it really connect to two different
branches (the test name is test_branch_remote_remote...).

    Marius> 2) I might be leaking threads (probably because of 1),
    Marius>    but I'm not sure how to fix it:
    Marius> $ ./bzr --no-plugins selftest TestInit
    Marius> testing: /stuph/projects/bzr/bzr.repo/bzr.work/bzr
    Marius>    /stuph/projects/bzr/bzr.repo/bzr.work/bzrlib (1.6b3 python2.5.2)
    Marius> ----------------------------------------------------------------------
    Marius> Ran 11 tests in 0.858s

    Marius> OK
    Marius> tests passed
    Marius> bzrlib.tests.commands.test_init.TestInit.test_init is leaking threads among
    Marius> 2 leaking tests

The thread leak detection is pretty crude and its purpose is to
establish that there are *some* tests leaking, but it's not
precise enough to tell you exactly which.

It's there as a reminder.

<snip/>

    Marius> # Bazaar merge directive format 2 (Bazaar 0.90)
    Marius> # revision_id: amanic at gmail.com-20080713161536-gkuyj05s28qpaj8c
    Marius> # target_branch: ../bzr.dev
    Marius> # testament_sha1: 2540bb88a9fd2af4afa105d729834f7c23f60b8f
    Marius> # timestamp: 2008-07-13 18:23:26 +0200
    Marius> # base_revision_id: pqm at pqm.ubuntu.com-20080709135859-wq3r1d1fjcafelgw
    Marius> # 
    Marius> # Begin patch
    Marius> === modified file 'bzrlib/builtins.py'
    Marius> --- bzrlib/builtins.py	2008-07-09 05:31:15 +0000
    Marius> +++ bzrlib/builtins.py	2008-07-13 08:43:42 +0000
    Marius> @@ -1378,6 +1378,10 @@
    Marius>              except errors.UpgradeRequired:
    Marius>                  raise errors.BzrCommandError('This branch format cannot be set'
    Marius>                      ' to append-revisions-only.  Try --experimental-branch6')
    Marius> +        if not is_quiet():
    Marius> +            from bzrlib.info import show_bzrdir_info
    Marius> +            show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
    Marius> +                verbose=0, outfile=self.outf)

I think using open_containing_from_transport(to_transport)
instead of open_containing(location), will make the test pass
again.

Alternatively you can do open_containing(location, possible_transports=[to_transport]).

By using 'location' you force bzrdir to create a new transport,
breaking the existing relation between location and to_transport,
defeating the connection sharing mechanism.

    Marius>  class cmd_init_repository(Command):
    Marius> @@ -1429,6 +1433,10 @@
    Marius>          newdir = format.initialize_on_transport(to_transport)
    Marius>          repo = newdir.create_repository(shared=True)
    Marius>          repo.set_make_working_trees(not no_trees)
    Marius> +        if not is_quiet():
    Marius> +            from bzrlib.info import show_bzrdir_info
    Marius> +            show_bzrdir_info(bzrdir.BzrDir.open_containing(location)[0],
    Marius> +                verbose=0, outfile=self.outf)
 
 
Same here.

<snip/>

    Marius> +from bzrlib import tests
    Marius>  from bzrlib.builtins import cmd_init
    Marius>  from bzrlib.tests.transport_util import TestCaseWithConnectionHookedTransport
 
    Marius> @@ -27,6 +28,8 @@
 
    Marius>      def test_init(self):
    Marius>          cmd = cmd_init()
    Marius> +        # We don't care about the ouput but 'outf' should be defined
    Marius> +        cmd.outf = tests.StringIOWrapper()
    Marius>          cmd.run(self.get_url())
    Marius> -        self.assertEquals(1, len(self.connections))
    Marius> +        self.assertEquals(2, len(self.connections))
 
As explained above, you're breaking the purpose of the test here :)

    Marius> === modified file 'bzrlib/tests/commands/test_init_repository.py'
    Marius> --- bzrlib/tests/commands/test_init_repository.py	2007-09-11 14:47:02 +0000
    Marius> +++ bzrlib/tests/commands/test_init_repository.py	2008-07-13 16:15:36 +0000
    Marius> @@ -15,6 +15,7 @@
    Marius>  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
    Marius> +from bzrlib import tests
    Marius>  from bzrlib.builtins import cmd_init_repository
    Marius>  from bzrlib.tests.transport_util import TestCaseWithConnectionHookedTransport
 
    Marius> @@ -27,6 +28,8 @@
 
    Marius>      def test_init_repository(self):
    Marius>          cmd = cmd_init_repository()
    Marius> +        # We don't care about the ouput but 'outf' should be defined
    Marius> +        cmd.outf = tests.StringIOWrapper()
    Marius>          cmd.run(self.get_url())
    Marius> -        self.assertEquals(1, len(self.connections))
    Marius> +        self.assertEquals(2, len(self.connections))
 
Same here.

     Vincent



More information about the bazaar mailing list