/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 breezy/git/transportgit.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-07-27 23:53:10 UTC
  • mfrom: (7356.1.10 exitstack)
  • Revision ID: breezy.the.bot@gmail.com-20190727235310-ccs69jhu4pq55qsi
Use contextlib.ExitStack rather than our homegrown OperationWithCleanups.

Merged from https://code.launchpad.net/~jelmer/brz/exitstack/+merge/369203

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
        del self._packed_refs[name]
234
234
        if name in self._peeled_refs:
235
235
            del self._peeled_refs[name]
236
 
        f = self.transport.open_write_stream("packed-refs")
237
 
        try:
 
236
        with self.transport.open_write_stream("packed-refs") as f:
238
237
            write_packed_refs(f, self._packed_refs, self._peeled_refs)
239
 
        finally:
240
 
            f.close()
241
238
 
242
239
    def set_symbolic_ref(self, name, other):
243
240
        """Make a ref point at another ref.
700
697
        p._filename = basename + ".pack"
701
698
        f.seek(0)
702
699
        self.pack_transport.put_file(basename + ".pack", f)
703
 
        idxfile = self.pack_transport.open_write_stream(basename + ".idx")
704
 
        try:
 
700
        with self.pack_transport.open_write_stream(basename + ".idx") as idxfile:
705
701
            write_pack_index_v2(idxfile, entries, p.get_stored_checksum())
706
 
        finally:
707
 
            idxfile.close()
708
702
        idxfile = self.pack_transport.get(basename + ".idx")
709
703
        idx = load_pack_index_file(basename + ".idx", idxfile)
710
704
        final_pack = Pack.from_objects(p, idx)
729
723
 
730
724
        pack_sha = p.index.objects_sha1()
731
725
 
732
 
        datafile = self.pack_transport.open_write_stream(
733
 
            "pack-%s.pack" % pack_sha.decode('ascii'))
734
 
        try:
 
726
        with self.pack_transport.open_write_stream(
 
727
                "pack-%s.pack" % pack_sha.decode('ascii')) as datafile:
735
728
            entries, data_sum = write_pack_objects(datafile, p.pack_tuples())
736
 
        finally:
737
 
            datafile.close()
738
729
        entries = sorted([(k, v[0], v[1]) for (k, v) in entries.items()])
739
 
        idxfile = self.pack_transport.open_write_stream(
740
 
            "pack-%s.idx" % pack_sha.decode('ascii'))
741
 
        try:
 
730
        with self.pack_transport.open_write_stream(
 
731
                "pack-%s.idx" % pack_sha.decode('ascii')) as idxfile:
742
732
            write_pack_index_v2(idxfile, entries, data_sum)
743
 
        finally:
744
 
            idxfile.close()
745
733
 
746
734
    def add_pack(self):
747
735
        """Add a new pack to this object store.