summaryrefslogtreecommitdiff
path: root/patchtracker/Patch.py
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2008-06-24 21:53:32 +0200
committerSean Finney <seanius@debian.org>2008-06-24 21:53:32 +0200
commit138d8addb6cb753b2a03b0c4b865869fd78db7c0 (patch)
tree4f81cb4b2ceed96c6e9a79ca05491441cb13df9a /patchtracker/Patch.py
parentf78a89015f98a7b686c4097ed4a870a92636ba43 (diff)
downloadpatch-tracker-138d8addb6cb753b2a03b0c4b865869fd78db7c0.tar.gz
add support for displaying "direct" changes
i.e. changes made directly to files (not using any patching system and not underneath ./debian) also introduce new Diffstat class for mangling diff stats in various ways.
Diffstat (limited to 'patchtracker/Patch.py')
-rw-r--r--patchtracker/Patch.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/patchtracker/Patch.py b/patchtracker/Patch.py
index 2f604e1..4ec0594 100644
--- a/patchtracker/Patch.py
+++ b/patchtracker/Patch.py
@@ -3,6 +3,27 @@ import os
import errno
from glob import glob
+class Diffstat:
+ def __init__(self, patch):
+ self.patch = patch
+ i,o = os.popen2("diffstat")
+ i.write(str(patch))
+ i.close()
+ self.output = o.readlines()
+
+ def stats(self):
+ i,o = os.popen2("diffstat -t")
+ i.write(str(self.patch))
+ i.close()
+ o.readline()
+ return [l.split(",") for l in o.readlines()]
+
+ def summary(self):
+ return self.output[-1]
+
+ def __str__(self):
+ return "".join(self.output)
+
class Patch:
def __init__(self, fh, level=1):
self.p = fh.readlines()
@@ -15,11 +36,7 @@ class Patch:
return len(self.p)
def diffstat(self):
- i,o = os.popen2("diffstat")
- i.write(str(self))
- i.close()
- return o.read()
-
+ return Diffstat(self)
# XXX this entire __init__ stuff is way to ugly
class PatchSeries (list):