~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

(jam) Switch from Transport.get() to .get_bytes(),
        close open file handles.

Show diffs side-by-side

added added

removed removed

Lines of Context:
543
543
        else:
544
544
            parents = [last_rev]
545
545
        try:
546
 
            merges_file = self._transport.get('pending-merges')
 
546
            merges_bytes = self._transport.get_bytes('pending-merges')
547
547
        except errors.NoSuchFile:
548
548
            pass
549
549
        else:
550
 
            for l in merges_file.readlines():
 
550
            for l in osutils.split_lines(merges_bytes):
551
551
                revision_id = l.rstrip('\n')
552
552
                parents.append(revision_id)
553
553
        return parents
1844
1844
    def _reset_data(self):
1845
1845
        """Reset transient data that cannot be revalidated."""
1846
1846
        self._inventory_is_modified = False
1847
 
        result = self._deserialize(self._transport.get('inventory'))
 
1847
        f = self._transport.get('inventory')
 
1848
        try:
 
1849
            result = self._deserialize(f)
 
1850
        finally:
 
1851
            f.close()
1848
1852
        self._set_inventory(result, dirty=False)
1849
1853
 
1850
1854
    @needs_tree_write_lock
1926
1930
        # binary.
1927
1931
        if self._inventory_is_modified:
1928
1932
            raise errors.InventoryModified(self)
1929
 
        result = self._deserialize(self._transport.get('inventory'))
 
1933
        f = self._transport.get('inventory')
 
1934
        try:
 
1935
            result = self._deserialize(f)
 
1936
        finally:
 
1937
            f.close()
1930
1938
        self._set_inventory(result, dirty=False)
1931
1939
        return result
1932
1940
 
2770
2778
        """Return the format for the working tree object in a_bzrdir."""
2771
2779
        try:
2772
2780
            transport = a_bzrdir.get_workingtree_transport(None)
2773
 
            format_string = transport.get("format").read()
 
2781
            format_string = transport.get_bytes("format")
2774
2782
            return klass._formats[format_string]
2775
2783
        except errors.NoSuchFile:
2776
2784
            raise errors.NoWorkingTree(base=transport.base)