Occasional AttributeError from Tree.get_file_by_path
John Arbash Meinel
john at arbash-meinel.com
Mon Oct 25 17:06:36 BST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 10/25/2010 8:50 AM, Michael Gliwinski wrote:
> Hello all,
>
> Just wanted to check before submitting bug report. I'm encountering a strange
> issue in ``Tree.get_file_by_path`` which seems to be triggered by some
> modifications I'm attempting to the bzr-upload plugin.
>
> The main difference is that I'm passing a WorkingTree instance where the
> original code used a RevisionTree, still I can't see why that would make a
> difference. The code that triggers the problem is:
>
> ignore_file = self.tree.get_file_by_path('.bzrignore-upload')
>
> Where self.tree previously was a RevisionTree instance and now is a
> WorkingTree instance. Basically ``get_file_by_path`` implementation is AFAICS
> inherited from ``bzrlib.tree.Tree`` and does the following:
>
> return self.get_file(self._inventory.path2id(path), path)
>
> Now the problem is that in some cases (see below) the ``_inventory`` attribute
> seems to be None which ends up with AttributeError.
Just a bug. If we have to, we could use:
self.inventory.path2id()
because .inventory is a property that populates _inventory if it is
None, but the better fix is just:
self.get_file(self.path2id(path), path)
I'm not 100% sure if base Tree has .path2id, but it is the preferred
method everywhere else.
Also, WT.get_file_by_path should really be special cased, because it
easily thinks in terms of path. The only question is whether the command
should fail if the file isn't versioned...
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkzFqwwACgkQJdeBCYSNAAPKoQCfYm/vvusluQ/PMojf3L0gUwZu
+scAn2LsC0uUO8e992yBjPTEbxDJfVGT
=ckcP
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list