Occasional AttributeError from Tree.get_file_by_path
Michael Gliwinski
Michael.Gliwinski at henderson-group.com
Tue Oct 26 13:36:52 BST 2010
On Monday 25 Oct 2010 17:06:36 John Arbash Meinel wrote:
> 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.
OK, I'll report it and submit a fix. Tree does have path2id, however I'm
getting lost here as all it does is:
return self._inventory.path2id(path)
the only difference is that path2id is decorated with @needs_read_lock
Still, if you agree this is right, I'll just do that.
> 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...
ATM it will fail as path2id will return None and get_file(None) throws an
error. Do you mean in case of a WorkingTree it shouldn't fail?
--
Michael Gliwinski
Henderson Group Information Services
9-11 Hightown Avenue, Newtownabby, BT36 4RT
Phone: 028 9034 3319
**********************************************************************************************
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to the email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing client engagement leter or contract.
If you have received this email in error please notify support at henderson-group.com
John Henderson (Holdings) Ltd
Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT.
Registered in Northern Ireland
Registration Number NI010588
Vat No.: 814 6399 12
*********************************************************************************
More information about the bazaar
mailing list