~vmiklos/bzr-fastimport/darcs

« back to all changes in this revision

Viewing changes to processors/info_processor.py

  • Committer: Ian Clatworthy
  • Date: 2009-12-08 06:29:47 UTC
  • mfrom: (260.1.1 fastimport-less-sticky)
  • Revision ID: ian.clatworthy@canonical.com-20091208062947-b7xr5g7dhxywtkaj
Merge John's improvements to info_processor.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
        # Dump statistics
80
80
        cmd_names = commands.COMMAND_NAMES
81
81
        fc_names = commands.FILE_COMMAND_NAMES
82
 
        cmd_values = [self.cmd_counts[c] for c in cmd_names]
83
 
        fc_values = [self.file_cmd_counts[c] for c in fc_names]
84
 
        self._dump_stats_group("Command counts", cmd_names, cmd_values, str)
85
 
        self._dump_stats_group("File command counts", fc_names, fc_values, str)
 
82
        self._dump_stats_group("Command counts",
 
83
            [(c, self.cmd_counts[c]) for c in cmd_names], str)
 
84
        self._dump_stats_group("File command counts", 
 
85
            [(c, self.file_cmd_counts[c]) for c in fc_names], str)
86
86
 
87
87
        # Commit stats
88
88
        if self.cmd_counts['commit']:
89
 
            p_names = []
90
 
            p_values = []
 
89
            p_items = []
91
90
            for i in xrange(0, self.max_parent_count + 1):
92
91
                if i in self.parent_counts:
93
92
                    count = self.parent_counts[i]
94
 
                    p_names.append("parents-%d" % i)
95
 
                    p_values.append(count)
 
93
                    p_items.append(("parents-%d" % i, count))
96
94
            merges_count = len(self.merges.keys())
97
 
            p_names.append('total revisions merged')
98
 
            p_values.append(merges_count)
 
95
            p_items.append(('total revisions merged', merges_count))
99
96
            flags = {
100
97
                'separate authors found': self.separate_authors_found,
101
98
                'executables': self.executables_found,
102
99
                'symlinks': self.symlinks_found,
103
100
                'blobs referenced by SHA': self.sha_blob_references,
104
101
                }
105
 
            self._dump_stats_group("Parent counts", p_names, p_values, str)
106
 
            self._dump_stats_group("Commit analysis", flags.keys(),
107
 
                flags.values(), _found)
 
102
            self._dump_stats_group("Parent counts", p_items, str)
 
103
            self._dump_stats_group("Commit analysis", flags.iteritems(), _found)
108
104
            heads = helpers.invert_dictset(self.cache_mgr.heads)
109
 
            self._dump_stats_group("Head analysis", heads.keys(),
110
 
                heads.values(), None, _iterable_as_config_list)
 
105
            self._dump_stats_group("Head analysis", heads.iteritems(), None,
 
106
                                    _iterable_as_config_list)
111
107
            # note("\t%d\t%s" % (len(self.committers), 'unique committers'))
112
 
            self._dump_stats_group("Merges", self.merges.keys(),
113
 
                self.merges.values(), None)
 
108
            self._dump_stats_group("Merges", self.merges.iteritems(), None)
114
109
            # We only show the rename old path and copy source paths when -vv
115
110
            # (verbose=2) is specified. The output here for mysql's data can't
116
111
            # be parsed currently so this bit of code needs more work anyhow ..
117
112
            if self.verbose >= 2:
118
113
                self._dump_stats_group("Rename old paths",
119
 
                    self.rename_old_paths.keys(),
120
 
                    self.rename_old_paths.values(), len,
 
114
                    self.rename_old_paths.iteritems(), len,
121
115
                    _iterable_as_config_list)
122
116
                self._dump_stats_group("Copy source paths",
123
 
                    self.copy_source_paths.keys(),
124
 
                    self.copy_source_paths.values(), len,
 
117
                    self.copy_source_paths.iteritems(), len,
125
118
                    _iterable_as_config_list)
126
119
 
127
120
        # Blob stats
129
122
            # In verbose mode, don't list every blob used
130
123
            if self.verbose:
131
124
                del self.blobs['used']
132
 
            self._dump_stats_group("Blob usage tracking", self.blobs.keys(),
133
 
                self.blobs.values(), len, _iterable_as_config_list)
 
125
            self._dump_stats_group("Blob usage tracking",
 
126
                self.blobs.iteritems(), len, _iterable_as_config_list)
134
127
        if self.blob_ref_counts:
135
128
            blobs_by_count = helpers.invert_dict(self.blob_ref_counts)
 
129
            blob_items = blobs_by_count.items()
 
130
            blob_items.sort()
136
131
            self._dump_stats_group("Blob reference counts",
137
 
                blobs_by_count.keys(),
138
 
                blobs_by_count.values(), len, _iterable_as_config_list)
 
132
                blob_items, len, _iterable_as_config_list)
139
133
 
140
134
        # Other stats
141
135
        if self.cmd_counts['reset']:
142
136
            reset_stats = {
143
137
                'lightweight tags': self.lightweight_tags,
144
138
                }
145
 
            self._dump_stats_group("Reset analysis", reset_stats.keys(),
146
 
                reset_stats.values())
 
139
            self._dump_stats_group("Reset analysis", reset_stats.iteritems())
147
140
 
148
 
    def _dump_stats_group(self, title, names, values, normal_formatter=None,
 
141
    def _dump_stats_group(self, title, items, normal_formatter=None,
149
142
        verbose_formatter=None):
150
143
        """Dump a statistics group.
151
144
        
158
151
        """
159
152
        if self.verbose:
160
153
            self.outf.write("[%s]\n" % (title,))
161
 
            for name, value in zip(names, values):
 
154
            for name, value in items:
162
155
                if verbose_formatter is not None:
163
156
                    value = verbose_formatter(value)
164
157
                if type(name) == str:
167
160
            self.outf.write("\n")
168
161
        else:
169
162
            self.outf.write("%s:\n" % (title,))
170
 
            for name, value in zip(names, values):
 
163
            for name, value in items:
171
164
                if normal_formatter is not None:
172
165
                    value = normal_formatter(value)
173
166
                self.outf.write("\t%s\t%s\n" % (value, name))