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
=== modified file 'NEWS'
--- NEWS 2010-10-18 08:06:05 +0000
+++ NEWS 2010-10-26 18:34:47 +0000
@@ -38,6 +38,9 @@
38 installed.38 installed.
39 (Martin [gz], Gary van der Merwe, #632465)39 (Martin [gz], Gary van der Merwe, #632465)
4040
41* Fix occasional AttributeError from Tree.get_file_by_path
42 (Michael Gliwinski, #666897)
43
41Improvements44Improvements
42************45************
4346
4447
=== modified file 'bzrlib/tree.py'
--- bzrlib/tree.py 2010-05-25 17:27:52 +0000
+++ bzrlib/tree.py 2010-10-26 18:34:47 +0000
@@ -324,7 +324,7 @@
324 raise NotImplementedError(self.get_file_size)324 raise NotImplementedError(self.get_file_size)
325325
326 def get_file_by_path(self, path):326 def get_file_by_path(self, path):
327 return self.get_file(self._inventory.path2id(path), path)327 return self.get_file(self.path2id(path), path)
328328
329 def iter_files_bytes(self, desired_files):329 def iter_files_bytes(self, desired_files):
330 """Iterate through file contents.330 """Iterate through file contents.

Subscribers

People subscribed via source and target branches