/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 processors/info_processor.py

add heads analysis to info processor

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    )
24
24
from bzrlib.plugins.fastimport import (
25
25
    commands,
 
26
    helpers,
26
27
    processor,
27
28
    )
28
29
 
68
69
        self.blobs = {}
69
70
        for usage in ['new', 'used', 'multi', 'unknown']:
70
71
            self.blobs[usage] = set()
71
 
 
 
72
        # Head tracking: map of commit mark to ref
 
73
        self.heads = {}
72
74
 
73
75
    def post_process(self):
74
76
        # Dump statistics
97
99
            self._dump_stats_group("Parent counts", p_names, p_values, str)
98
100
            self._dump_stats_group("Commit analysis", flags.keys(),
99
101
                flags.values(), _found)
 
102
            heads = helpers.invert_dict(self.heads)
 
103
            self._dump_stats_group("Head analysis", heads.keys(),
 
104
                heads.values(), None, _iterable_as_config_list)
100
105
            # note("\t%d\t%s" % (len(self.committers), 'unique committers'))
101
106
 
102
107
        # Blob stats
105
110
            if self.verbose:
106
111
                del self.blobs['used']
107
112
            self._dump_stats_group("Blob usage tracking", self.blobs.keys(),
108
 
                self.blobs.values(), len, _set_as_config_list)
 
113
                self.blobs.values(), len, _iterable_as_config_list)
109
114
 
110
115
        # Other stats
111
116
        if self.cmd_counts['reset']:
173
178
                        self._track_blob(fc.dataref)
174
179
                    else:
175
180
                        self.sha_blob_references = True
 
181
        # Track the heads
 
182
        for parent in cmd.parents:
 
183
            try:
 
184
                del self.heads[parent]
 
185
            except KeyError:
 
186
                print "hmm - didn't find parent %s" % parent
 
187
                pass
 
188
        self.heads[":" + cmd.mark] = cmd.ref
 
189
            
176
190
 
177
191
    def reset_handler(self, cmd):
178
192
        """Process a ResetCommand."""
202
216
    """Format a found boolean as a string."""
203
217
    return ['no', 'found'][b]
204
218
 
205
 
def _set_as_config_list(s):
206
 
    """Format a set as a sequence of comma-separated strings.
 
219
def _iterable_as_config_list(s):
 
220
    """Format an iterable as a sequence of comma-separated strings.
207
221
    
208
222
    To match what ConfigObj expects, a single item list has a trailing comma.
209
223
    """