Merge lp:~tzeentch-gm/bzr/666897-get-file-by-path-attr-error into lp:bzr/2.2

Proposed by Michael Gliwinski
Status: Work in progress
Proposed branch: lp:~tzeentch-gm/bzr/666897-get-file-by-path-attr-error
Merge into: lp:bzr/2.2
Diff against target: 26 lines (+4/-1)
2 files modified
NEWS (+3/-0)
bzrlib/tree.py (+1/-1)
To merge this branch: bzr merge lp:~tzeentch-gm/bzr/666897-get-file-by-path-attr-error
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+39395@code.launchpad.net

Commit message

Use Tree.path2id rather than the same method on _inventory member

Description of the change

Just a small tweak to ``Tree.get_file_by_path`` to use path2id method instead of accessing _inventory directly. This prevents occasional AttributeError when _inventory is None (e.g. on WorkingTree 4+).

See bug #666897 and discusson on ML: https://lists.ubuntu.com/archives/bazaar/2010q4/070748.html

To post a comment you must log in.
Revision history for this message
Martin Pool (mbp) wrote :

It would be nice to have a test if you're seeing this error, but I think this is fairly clearly an improvement in its own right.

review: Approve
Revision history for this message
Michael Gliwinski (tzeentch-gm) wrote :

I know, I was thinking about it, but the thing is I can't substantiate the exact circumstances that cause that problem to pop up. The method is already used in tests in ``bzrlib.tests.blackbox.test_versioning.SubdirCommit`` but it does not fail.

Roughly has something to do with Tree subclass used (WorkingTree 4+ in this case) and possibly with that tree having uncomitted changes. If you have any ideas let me know and I can try things out.

Revision history for this message
Martin Packman (gz) wrote :

sent to pqm by email

Revision history for this message
Martin Packman (gz) wrote :

Whoops, I can't commit to 2.2 sorry.

Revision history for this message
Andrew Bennetts (spiv) wrote :

I'll be happy to send this to the 2.2 branch. First though I think we need you to execute the Canonical's Contributor Agreement: <http://www.canonical.com/contributors>.

Revision history for this message
John A Meinel (jameinel) wrote :

What is the status of the contributor agreement? Did Michael sign it? Did he refuse to sign it?

Revision history for this message
Vincent Ladeuil (vila) wrote :

@Michael, is there a problem with the contributor agreement ?

Revision history for this message
Vincent Ladeuil (vila) wrote :

Marking as WIP waiting for Michael feedback there :-/

Revision history for this message
John A Meinel (jameinel) wrote :

Still waiting on feedback? Should we just reject this? I didn't look at it directly, so I can probably just reproduce it from the description.

Unmerged revisions

5106. By Michael Gliwinski

Updated NEWS.

5105. By Michael Gliwinski

Changed ``Tree.get_file_by_path`` to use path2id method instead of accessing _inventory directly.

Fixes occasional problem with WorkingTree 4+ which re-implements path2id which doesn't use _inventory.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-10-18 08:06:05 +0000
3+++ NEWS 2010-10-26 18:34:47 +0000
4@@ -38,6 +38,9 @@
5 installed.
6 (Martin [gz], Gary van der Merwe, #632465)
7
8+* Fix occasional AttributeError from Tree.get_file_by_path
9+ (Michael Gliwinski, #666897)
10+
11 Improvements
12 ************
13
14
15=== modified file 'bzrlib/tree.py'
16--- bzrlib/tree.py 2010-05-25 17:27:52 +0000
17+++ bzrlib/tree.py 2010-10-26 18:34:47 +0000
18@@ -324,7 +324,7 @@
19 raise NotImplementedError(self.get_file_size)
20
21 def get_file_by_path(self, path):
22- return self.get_file(self._inventory.path2id(path), path)
23+ return self.get_file(self.path2id(path), path)
24
25 def iter_files_bytes(self, desired_files):
26 """Iterate through file contents.

Subscribers

People subscribed via source and target branches