Merge lp:~jameinel/bzr/2.5.2-get_file_text-1046284 into lp:bzr/2.5

Proposed by John A Meinel
Status: Merged
Merged at revision: 6509
Proposed branch: lp:~jameinel/bzr/2.5.2-get_file_text-1046284
Merge into: lp:bzr/2.5
Diff against target: 46 lines (+18/-3)
2 files modified
bzrlib/workingtree_4.py (+14/-3)
doc/en/release-notes/bzr-2.5.txt (+4/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.5.2-get_file_text-1046284
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+123020@code.launchpad.net

Commit message

Fix bug #1046284. When iterating over iter_files_bytes, we should consume the content iterator before we proceed with the files iterator.

Description of the change

This is a quick fix for bug #1046284. It fixes get_file_text so that it consumes the content iterator before it consumes the outer iterator.

I don't have a specific test for it, because I'm working on bug #1046697 which has a bit bigger scope.

I'll see if I can get that branch up and working quickly for bzr-2.5 before we release bzr-2.5.2, but I don't think we have to block on getting all that working, rather than getting a fix out for users.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/workingtree_4.py'
2--- bzrlib/workingtree_4.py 2012-01-06 14:09:04 +0000
3+++ bzrlib/workingtree_4.py 2012-09-06 07:40:24 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2007-2011 Canonical Ltd
6+# Copyright (C) 2007-2012 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -1882,8 +1882,19 @@
11 return self.inventory[file_id].text_size
12
13 def get_file_text(self, file_id, path=None):
14- _, content = list(self.iter_files_bytes([(file_id, None)]))[0]
15- return ''.join(content)
16+ full_content = None
17+ for _, content in self.iter_files_bytes([(file_id, None)]):
18+ if full_content is not None:
19+ raise AssertionError('iter_files_bytes returned'
20+ ' too many entries')
21+ # For each entry returned by iter_files_bytes, we must consume the
22+ # content before we step the iterator.
23+ full_content = ''.join(content)
24+ del content
25+ if full_content is None:
26+ raise AssertionError('iter_files_bytes did not return'
27+ ' the requested data')
28+ return full_content
29
30 def get_reference_revision(self, file_id, path=None):
31 return self.inventory[file_id].reference_revision
32
33=== modified file 'doc/en/release-notes/bzr-2.5.txt'
34--- doc/en/release-notes/bzr-2.5.txt 2012-08-01 08:51:57 +0000
35+++ doc/en/release-notes/bzr-2.5.txt 2012-09-06 07:40:24 +0000
36@@ -35,6 +35,10 @@
37 * ``bzr config`` properly handles aliases and references in the
38 ``--directory`` parameter (Vincent Ladeuil, Wouter van Heyst, #947049)
39
40+* Lightweight checkouts of remote repositories had a bug with how they
41+ extracted texts from the repository. (Just an ordering constraint on how
42+ they consumed the stream.) (John Arbash Meinel, #1046284)
43+
44 * Revert use of --no-tty when gpg signing commits. (Jelmer Vernooij, #1014570)
45
46 Documentation

Subscribers

People subscribed via source and target branches