~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/patches.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-02-02 05:31:19 UTC
  • mfrom: (3946.4.1 patch_stats)
  • Revision ID: pqm@pqm.ubuntu.com-20090202053119-adgabjjho5g49v76
(thumper) Refactor patch stat generation to make int values
        accessible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
275
275
    def get_header(self):
276
276
        return "--- %s\n+++ %s\n" % (self.oldname, self.newname)
277
277
 
278
 
    def stats_str(self):
279
 
        """Return a string of patch statistics"""
 
278
    def stats_values(self):
 
279
        """Calculate the number of inserts and removes."""
280
280
        removes = 0
281
281
        inserts = 0
282
282
        for hunk in self.hunks:
285
285
                     inserts+=1;
286
286
                elif isinstance(line, RemoveLine):
287
287
                     removes+=1;
 
288
        return (inserts, removes, len(self.hunks))
 
289
 
 
290
    def stats_str(self):
 
291
        """Return a string of patch statistics"""
288
292
        return "%i inserts, %i removes in %i hunks" % \
289
 
            (inserts, removes, len(self.hunks))
 
293
            self.stats_values()
290
294
 
291
295
    def pos_in_mod(self, position):
292
296
        newpos = position