[MERGE][BUG #276436] Simple fix to WT.open()

John Arbash Meinel john at arbash-meinel.com
Wed Oct 1 14:59:54 BST 2008


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

Martin Pool wrote:
> On Wed, Oct 1, 2008 at 6:32 AM, John Arbash Meinel
> <john at arbash-meinel.com> wrote:
>> This is just a simple fix to WT.open() and some associated tests. I
>> added them to bzrlib.tests.test_workingtree.TestDefaultFormat, because I
>> was surprised that there was no direct tests for the "TestWorkingTree"
>> to test the static members.
>>
>> I had considered deprecating not passing an argument (as obviously it
>> isn't being used), but I decided to keep it for now.
> 
> Actually I think the existence of these methods is a bit questionable:
> they just loop back in to BzrDir which eventually calls back in to
> WorkingTree.   So they're not adding much value in functionality, and
> I think any arguable simplicity in the api is outweighed by the
> potential confusion of having too many ways to do the same thing.
> 
> Of course that I'm still happy you stopped them failing in this case.

I personally use WT.open quite often in TIMEIT scripts or in interactive
discourse.

I *do* think that WT.open() is more concise than
BzrDir.open().open_workingtree().


> 
>> +    def test_open(self):
>> +        tree = self.make_branch_and_tree('.')
>> +        open_direct = tree.open('.')
>> +        self.assertEqual(tree.basedir, open_direct.basedir)
>> +        open_no_args = tree.open()
>> +        self.assertEqual(tree.basedir, open_no_args.basedir)
>> +
>> +    def test_open_containing(self):
>> +        tree = self.make_branch_and_tree('.')
>> +        open_direct, relpath = tree.open_containing('.')
>> +        self.assertEqual(tree.basedir, open_direct.basedir)
>> +        self.assertEqual('', relpath)
>> +        open_no_args, relpath = tree.open_containing()
>> +        self.assertEqual(tree.basedir, open_no_args.basedir)
>> +        self.assertEqual('', relpath)
>> +        open_subdir, relpath = tree.open_containing('subdir')
>> +        self.assertEqual(tree.basedir, open_subdir.basedir)
>> +        self.assertEqual('subdir', relpath)
>> +
> 
> It seems a bit strange or misleading to call these static methods on
> an instance.  Are you trying to make sure you get possibly overridden
> versions or something?  I'd at least hope for a comment...
> 

No, I meant to call WT.open*. I'm not sure what I was thinking here.
I'll fix that.

But I'll note you didn't vote :)
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjjgloACgkQJdeBCYSNAAMaWQCeP9kI94ZkWIC6Zeyu07I2KiqK
+WQAoLr8DWkyobqqJv4lYKnyhGkQlF1V
=0+Ua
-----END PGP SIGNATURE-----



More information about the bazaar mailing list