Rev 3977: (thumper) Refactor patch stat generation to make int values in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Feb 2 05:31:23 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3977
revision-id: pqm at pqm.ubuntu.com-20090202053119-adgabjjho5g49v76
parent: pqm at pqm.ubuntu.com-20090131231933-8o4phfvmuuizyyn6
parent: tim.penhey at canonical.com-20090128221627-mctkpl6un050cyfn
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-02-02 05:31:19 +0000
message:
  (thumper) Refactor patch stat generation to make int values
  	accessible.
modified:
  bzrlib/patches.py              patches.py-20050727183609-378c1cc5972ce908
  bzrlib/tests/test_patches.py   test_patches.py-20051231203844-f4974d20f6aea09c
    ------------------------------------------------------------
    revno: 3946.4.1
    revision-id: tim.penhey at canonical.com-20090128221627-mctkpl6un050cyfn
    parent: pqm at pqm.ubuntu.com-20090119130916-zr1sbw0hn7rbip3y
    committer: Tim Penhey <tim.penhey at canonical.com>
    branch nick: patch_stats
    timestamp: Thu 2009-01-29 11:16:27 +1300
    message:
      Extract out the counting of the stats values.
    modified:
      bzrlib/patches.py              patches.py-20050727183609-378c1cc5972ce908
      bzrlib/tests/test_patches.py   test_patches.py-20051231203844-f4974d20f6aea09c
=== modified file 'bzrlib/patches.py'
--- a/bzrlib/patches.py	2008-10-16 19:04:48 +0000
+++ b/bzrlib/patches.py	2009-01-28 22:16:27 +0000
@@ -275,8 +275,8 @@
     def get_header(self):
         return "--- %s\n+++ %s\n" % (self.oldname, self.newname)
 
-    def stats_str(self):
-        """Return a string of patch statistics"""
+    def stats_values(self):
+        """Calculate the number of inserts and removes."""
         removes = 0
         inserts = 0
         for hunk in self.hunks:
@@ -285,8 +285,12 @@
                      inserts+=1;
                 elif isinstance(line, RemoveLine):
                      removes+=1;
+        return (inserts, removes, len(self.hunks))
+
+    def stats_str(self):
+        """Return a string of patch statistics"""
         return "%i inserts, %i removes in %i hunks" % \
-            (inserts, removes, len(self.hunks))
+            self.stats_values()
 
     def pos_in_mod(self, position):
         newpos = position

=== modified file 'bzrlib/tests/test_patches.py'
--- a/bzrlib/tests/test_patches.py	2008-10-14 03:01:36 +0000
+++ b/bzrlib/tests/test_patches.py	2009-01-28 22:16:27 +0000
@@ -250,3 +250,8 @@
         for patch in patches:
             patch_files.append((patch.oldname, patch.newname))
         self.assertEqual(patch_files, filenames)
+
+    def testStatsValues(self):
+        """Test the added, removed and hunks values for stats_values."""
+        patch = parse_patch(self.datafile("diff"))
+        self.assertEqual((299, 407, 48), patch.stats_values())




More information about the bazaar-commits mailing list