/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/bundle/__init__.py

  • Committer: Martin
  • Date: 2009-11-09 00:39:44 UTC
  • mto: This revision was merged to the branch mainline in revision 4853.
  • Revision ID: gzlist@googlemail.com-20091109003944-f4qr8wyi8oy63dxm
Ensure files that are opened as potential bundles but turn out not to be get closed

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        except errors.TooManyRedirections:
73
73
            raise errors.NotABundle(transport.clone(filename).base)
74
74
 
75
 
        if _do_directive:
76
 
            from bzrlib.merge_directive import MergeDirective
77
 
            directive = MergeDirective.from_lines(f.readlines())
78
 
            return directive, transport
79
 
        else:
80
 
            return _serializer.read_bundle(f), transport
 
75
        bundle = None
 
76
        try:
 
77
            if _do_directive:
 
78
                from bzrlib.merge_directive import MergeDirective
 
79
                try:
 
80
                    return MergeDirective.from_lines(f.readlines()), transport
 
81
                except errors.NotAMergeDirective:
 
82
                    f.seek(0)
 
83
            bundle = _serializer.read_bundle(f)
 
84
        finally:
 
85
            if bundle is None:
 
86
                f.close()
 
87
        return bundle, transport
81
88
    except (errors.ConnectionReset, errors.ConnectionError), e:
82
89
        raise
83
90
    except (errors.TransportError, errors.PathError), e:
91
98
        # StubSFTPServer does fail during get() (because of prefetch)
92
99
        # so it has an opportunity to translate the error.
93
100
        raise errors.NotABundle(str(e))
94
 
    except errors.NotAMergeDirective:
95
 
        f.seek(0)
96
 
        return _serializer.read_bundle(f), transport