/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/bzr/groupcompress_repo.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
402
402
                     pb_offset):
403
403
        trace.mutter('repacking %d %s', len(keys), message)
404
404
        self.pb.update('repacking %s' % (message,), pb_offset)
405
 
        child_pb = ui.ui_factory.nested_progress_bar()
406
 
        try:
 
405
        with ui.ui_factory.nested_progress_bar() as child_pb:
407
406
            stream = vf_to_stream(source_vf, keys, message, child_pb)
408
407
            for _ in target_vf._insert_record_stream(stream,
409
408
                                                     random_id=True,
410
409
                                                     reuse_blocks=False):
411
410
                pass
412
 
        finally:
413
 
            child_pb.finished()
414
411
 
415
412
    def _copy_revision_texts(self):
416
413
        source_vf, target_vf = self._build_vfs('revision', True, False)
458
455
                     len(self._chk_id_roots), len(self._chk_p_id_roots),
459
456
                     len(total_keys))
460
457
        self.pb.update('repacking chk', 3)
461
 
        child_pb = ui.ui_factory.nested_progress_bar()
462
 
        try:
 
458
        with ui.ui_factory.nested_progress_bar() as child_pb:
463
459
            for stream in self._get_chk_streams(source_vf, total_keys,
464
460
                                                pb=child_pb):
465
461
                for _ in target_vf._insert_record_stream(stream,
466
462
                                                         random_id=True,
467
463
                                                         reuse_blocks=False):
468
464
                    pass
469
 
        finally:
470
 
            child_pb.finished()
471
465
 
472
466
    def _copy_text_texts(self):
473
467
        source_vf, target_vf = self._build_vfs('text', True, True)
619
613
        This is useful to get the side-effects of generating a stream.
620
614
        """
621
615
        self.pb.update('scanning %s' % (message,), pb_offset)
622
 
        child_pb = ui.ui_factory.nested_progress_bar()
623
 
        try:
 
616
        with ui.ui_factory.nested_progress_bar() as child_pb:
624
617
            list(vf_to_stream(source_vf, keys, message, child_pb))
625
 
        finally:
626
 
            child_pb.finished()
627
618
 
628
619
    def _copy_inventory_texts(self):
629
620
        source_vf, target_vf = self._build_vfs('inventory', True, True)
1025
1016
        rich_root = self.supports_rich_root()
1026
1017
        bytes_to_info = inventory.CHKInventory._bytes_to_utf8name_key
1027
1018
        file_id_revisions = {}
1028
 
        pb = ui.ui_factory.nested_progress_bar()
1029
 
        try:
 
1019
        with ui.ui_factory.nested_progress_bar() as pb:
1030
1020
            revision_keys = [(r,) for r in revision_ids]
1031
1021
            parent_keys = self._find_parent_keys_of_revisions(revision_keys)
1032
1022
            # TODO: instead of using _find_present_inventory_keys, change the
1058
1048
                        file_id_revisions[file_id].add(revision_id)
1059
1049
                    except KeyError:
1060
1050
                        file_id_revisions[file_id] = {revision_id}
1061
 
        finally:
1062
 
            pb.finished()
1063
1051
        return file_id_revisions
1064
1052
 
1065
1053
    def find_text_key_references(self):
1077
1065
        revision_keys = self.revisions.keys()
1078
1066
        result = {}
1079
1067
        rich_roots = self.supports_rich_root()
1080
 
        pb = ui.ui_factory.nested_progress_bar()
1081
 
        try:
 
1068
        with ui.ui_factory.nested_progress_bar() as pb:
1082
1069
            all_revs = self.all_revision_ids()
1083
1070
            total = len(all_revs)
1084
1071
            for pos, inv in enumerate(self.iter_inventories(all_revs)):
1091
1078
                    if entry.revision == inv.revision_id:
1092
1079
                        result[key] = True
1093
1080
            return result
1094
 
        finally:
1095
 
            pb.finished()
1096
1081
 
1097
1082
    def reconcile_canonicalize_chks(self):
1098
1083
        """Reconcile this repository to make sure all CHKs are in canonical