13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
from bzrlib import (
166
def test_get_file_text(self):
167
work_tree = self.make_branch_and_tree('wt')
168
tree = self.get_tree_no_parents_abc_content_2(work_tree)
170
self.addCleanup(tree.unlock)
171
# test read by file-id
172
self.assertEqual('foobar\n', tree.get_file_text('a-id'))
174
self.assertEqual('foobar\n', tree.get_file_text('a-id', path='a'))
176
def test_get_file_lines(self):
177
work_tree = self.make_branch_and_tree('wt')
178
tree = self.get_tree_no_parents_abc_content_2(work_tree)
180
self.addCleanup(tree.unlock)
181
# test read by file-id
182
self.assertEqual(['foobar\n'], tree.get_file_lines('a-id'))
184
self.assertEqual(['foobar\n'], tree.get_file_lines('a-id', path='a'))
186
def test_get_file_lines_multi_line_breaks(self):
187
work_tree = self.make_branch_and_tree('wt')
188
self.build_tree_contents([('wt/foobar', 'a\rb\nc\r\nd')])
189
work_tree.add('foobar', 'foobar-id')
190
tree = self._convert_tree(work_tree)
192
self.addCleanup(tree.unlock)
193
self.assertEqual(['a\rb\n', 'c\r\n', 'd'],
194
tree.get_file_lines('foobar-id'))
167
197
class TestExtractFilesBytes(TestCaseWithTree):