From 138d8addb6cb753b2a03b0c4b865869fd78db7c0 Mon Sep 17 00:00:00 2001 From: Sean Finney Date: Tue, 24 Jun 2008 21:53:32 +0200 Subject: 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. --- pagehandler.py | 4 ++++ patchtracker/Patch.py | 27 ++++++++++++++++++++++----- templates/package_vers.tmpl | 12 ++++++++++++ templates/patch_view.tmpl | 2 +- 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/pagehandler.py b/pagehandler.py index 0528291..7452880 100755 --- a/pagehandler.py +++ b/pagehandler.py @@ -35,6 +35,10 @@ class CmdHandler: elif patchtype == "nondebian": self.patchname = "direct (non packaging) changes" self.content = dh.nondebiandir() + elif patchtype == "misc": + patchfile = args[5] + self.patchname = "direct changes for "+patchfile + self.content = dh.filterdiff(include=patchfile) else: self.error("unhandled patch type '%s'"%(patchtype)) self.pkgname = pkgname 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): diff --git a/templates/package_vers.tmpl b/templates/package_vers.tmpl index e1f6350..bc393f1 100755 --- a/templates/package_vers.tmpl +++ b/templates/package_vers.tmpl @@ -76,8 +76,20 @@ debian specific patch information for $src.name / $suite inserted deleted modified + view download +#for $insd,$deld,$modd,$f in $diffhandler.nondebiandir.diffstat.stats + + $f$insd$deld$modd + + view + + + download + + +#end for #end if diff --git a/templates/patch_view.tmpl b/templates/patch_view.tmpl index ae1e64c..380bde5 100644 --- a/templates/patch_view.tmpl +++ b/templates/patch_view.tmpl @@ -12,7 +12,7 @@ Patch information for $package / $version / $name

Summary


-$escape($patch.diffstat)
+$escape($str($patch.diffstat))
   
-- cgit v1.2.3