/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/plugins/repodebug/check_chk.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-06-06 22:22:47 UTC
  • mfrom: (7143.22.4 progressbar-context)
  • Revision ID: breezy.the.bot@gmail.com-20190606222247-muw4nwibuoh9b30u
Use contexts for progress bars where possible.

Merged from https://code.launchpad.net/~jelmer/brz/progressbar-context/+merge/358460

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
            r1 = revision[0].as_revision_id(branch)
60
60
            r2 = revision[1].as_revision_id(branch)
61
61
            inv_ids = g.find_unique_ancestors(r2, [r1])
62
 
        pb = ui.ui_factory.nested_progress_bar()
63
 
        self.add_cleanup(pb.finished)
64
 
        for idx, inv in enumerate(repo.iter_inventories(inv_ids)):
65
 
            pb.update('checking', idx, len(inv_ids))
66
 
            d = dict(inv.id_to_entry.iteritems())
67
 
            test_key = chk_map.CHKMap.from_dict(
68
 
                vf, d, maximum_size=inv.id_to_entry._root_node._maximum_size,
69
 
                key_width=inv.id_to_entry._root_node._key_width,
70
 
                search_key_func=inv.id_to_entry._search_key_func)
71
 
            if inv.id_to_entry.key() != test_key:
72
 
                trace.warning('Failed for id_to_entry inv: %s'
73
 
                              % (inv.revision_id,))
74
 
            pid = inv.parent_id_basename_to_file_id
75
 
            d = dict(pid.iteritems())
76
 
            test_key = chk_map.CHKMap.from_dict(
77
 
                vf, d, maximum_size=pid._root_node._maximum_size,
78
 
                key_width=pid._root_node._key_width,
79
 
                search_key_func=pid._search_key_func)
80
 
            if pid.key() != test_key:
81
 
                trace.warning('Failed for parent_id_to_basename inv: %s'
82
 
                              % (inv.revision_id,))
 
62
        with ui.ui_factory.nested_progress_bar() as pb:
 
63
            for idx, inv in enumerate(repo.iter_inventories(inv_ids)):
 
64
                pb.update('checking', idx, len(inv_ids))
 
65
                d = dict(inv.id_to_entry.iteritems())
 
66
                test_key = chk_map.CHKMap.from_dict(
 
67
                    vf, d, maximum_size=inv.id_to_entry._root_node._maximum_size,
 
68
                    key_width=inv.id_to_entry._root_node._key_width,
 
69
                    search_key_func=inv.id_to_entry._search_key_func)
 
70
                if inv.id_to_entry.key() != test_key:
 
71
                    trace.warning('Failed for id_to_entry inv: %s'
 
72
                                  % (inv.revision_id,))
 
73
                pid = inv.parent_id_basename_to_file_id
 
74
                d = dict(pid.iteritems())
 
75
                test_key = chk_map.CHKMap.from_dict(
 
76
                    vf, d, maximum_size=pid._root_node._maximum_size,
 
77
                    key_width=pid._root_node._key_width,
 
78
                    search_key_func=pid._search_key_func)
 
79
                if pid.key() != test_key:
 
80
                    trace.warning('Failed for parent_id_to_basename inv: %s'
 
81
                                  % (inv.revision_id,))