[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#638058: PTS: better integration with patch-tracker.d.o



Package: qa.debian.org
Severity: wishlist
User: qa.debian.org@packages.debian.org
Usertags: pts

Hi.

Some days ago I proposed a few patches for the PTS to show links to
patch-tracker.d.o. After discussing a bit this with some people (mostly
zack and hertzog), I propose here an enhanced version of that.

I already got in touch with seanius and proposed a few patches to export
a summary of the patches used within each package in a JSON formatted
file. These patches are still waiting for review, but I'm confident that
they'll eventually be accepted.

The patch I'm attaching here uses such information to how, for each
version of the package, the number of patches and a star ('*') if the
package also conveys modification outside the debian/ dir in the
.diff.gz/.debian.tar.gz patch.

The code still has one very dirty hack (a hardcoded dictionary for
converting release name from lenny,squeeze,wheezey to
oldstable,stable,testing). I'm not sure about how to fix it, suggestions
welcome. Moreover, it lacks of the infrastructure to actually download
from patch-tracker.d.o the JSON file that has to be processed (after
all, that file doesn't exist yet!).

Comments/suggestions welcome.

Thanks, Gio.
-- 
Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.mascellani@jabber.org / giovanni@elabor.homelinux.org

From 7357222e631ac0484445e3c334bf497967a61493 Mon Sep 17 00:00:00 2001
From: Giovanni Mascellani <mascellani@poisson.phc.unipi.it>
Date: Fri, 29 Jul 2011 23:47:46 +0200
Subject: [PATCH] Better patch-tracker.d.o integration in PTS.

---
 pts/www/bin/other_to_xml.py |   43 +++++++++++++++++++++++++++-
 pts/www/xsl/pts.xsl         |   64 ++++++++++++-------------------------------
 2 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/pts/www/bin/other_to_xml.py b/pts/www/bin/other_to_xml.py
index 2d6f2a5..0c14e43 100755
--- a/pts/www/bin/other_to_xml.py
+++ b/pts/www/bin/other_to_xml.py
@@ -10,7 +10,7 @@
 # This file is distributed under the terms of the General Public License
 # version 2 or (at your option) any later version.
 
-import os.path, sys, string, re, email, common, cPickle, yaml
+import os.path, sys, string, re, email, common, cPickle, yaml, json
 import xml.dom
 
 try:
@@ -313,6 +313,15 @@ piuparts = read_piuparts(os.path.join(dir, "piuparts-sid.txt"))
 
 new_queue = read_NEW(os.path.join(dir, "new.822"))
 
+with open(os.path.join(dir, "patch_tracker.json")) as patch_tracker_file:
+    patch_tracker_array = json.load(patch_tracker_file)
+    patch_tracker = {}
+    for record in patch_tracker_array:
+        if record['package'] not in patch_tracker:
+            patch_tracker[record['package']] = {}
+        patch_tracker[record['package']][record['suite']] = record
+del patch_tracker_array
+
 # read QA lintian info
 lintian = read_lintian_info(os.path.join(dir, "lintian.qa-list.txt"))
 
@@ -325,7 +334,6 @@ try:
     f.close()
 except:
     pass # Silent failure
-
 # read info gathered from watch file scanner
 data = yaml.load(file(os.path.join(dir, "dehs.yaml")), yaml.CLoader)
 dehs = {}
@@ -633,6 +641,37 @@ while 1:
         root_elt.setAttribute('security', '0')
         sec_sig = '0'
 
+    # FIXME bad hack
+    codenames_resolver = {'lenny': 'oldstable',
+                          'squeeze': 'stable',
+                          'wheezy': 'testing',
+                          'sid': 'unstable',
+                          'experimental': 'experimental'}
+    suites_order = ['oldstable', 'stable', 'testing', 'unstable', 'experimental']
+    suites_order_lookup = dict(map(lambda (a, b): (b, a), enumerate(suites_order)))
+
+    # Add patch_tracker data
+    if pkg in patch_tracker:
+        elt = doc.createElement("patch-tracker")
+        root_elt.setAttribute("patch-tracker", "yes")
+        suites = patch_tracker[pkg].items()
+        suites.sort(key=lambda (a, b): suites_order_lookup[codenames_resolver[a]])
+        for suite, suite_data in suites:
+            version, nondebian, patch_num = suite_data['version'], \
+                sum(suite_data['nondebian']) > 0, len(suite_data['patches'])
+            elt2 = doc.createElement("package")
+            elt2.setAttribute("suite", codenames_resolver[suite])
+            elt2.setAttribute("version", version)
+            elt2.setAttribute("patch-number", str(patch_num))
+            if nondebian:
+	            elt2.setAttribute("nondebian-modifications", "yes")
+            else:
+	            elt2.setAttribute("nondebian-modifications", "no")
+            elt.appendChild(elt2)
+        root_elt.appendChild(elt)
+    else:
+        root_elt.setAttribute("patch-tracker", "no")
+
     # TODO: try to do that signature checking before the creation of XML DOM
     # Build the sig and check if anything changed
     sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, dehs_sig,
diff --git a/pts/www/xsl/pts.xsl b/pts/www/xsl/pts.xsl
index 0607fe5..071235f 100644
--- a/pts/www/xsl/pts.xsl
+++ b/pts/www/xsl/pts.xsl
@@ -869,13 +869,10 @@ other-to-%xx, especially % to %25... Fortunately, that's rare -->
 
 <xsl:template name="output-patch-tracker-version">
   <xsl:param name="suite" select="''" />
+  <xsl:param name="version" select="''" />
+  <xsl:param name="patch-number" select="''" />
+  <xsl:param name="nondebian-modifications" select="''" />
   <xsl:param name="link" select="'yes'" />
-  <xsl:variable name="version">
-    <span class="srcversion" title="{$suite}">
-      <xsl:value-of select="document(concat('../base/', $dir, '/', $suite,
-			    '.xml'))/source/version"/>
-    </span>
-  </xsl:variable>
   <xsl:choose>
     <xsl:when test="$link='yes'">
       <a href="http://patch-tracker.debian.org/package/{$package}/{$version}";>
@@ -886,6 +883,10 @@ other-to-%xx, especially % to %25... Fortunately, that's rare -->
       <xsl:copy-of select="$version" />
     </xsl:otherwise>
   </xsl:choose>
+  <xsl:text> </xsl:text>(<xsl:copy-of select="$patch-number"/>
+  <xsl:choose>
+    <xsl:when test="$nondebian-modifications='yes'"><b>*</b></xsl:when>
+  </xsl:choose>)
 </xsl:template>
 
 <xsl:template name="patch-tracker">
@@ -898,46 +899,17 @@ other-to-%xx, especially % to %25... Fortunately, that's rare -->
 	</xsl:call-template></h2>
 
     <dl>
-      <xsl:if test="$hasoldstable">  
-	<dt title="old stable release">oldstable</dt>
-	<dd>
-	  <xsl:call-template name="output-patch-tracker-version">
-	    <xsl:with-param name="suite">oldstable</xsl:with-param>
-	  </xsl:call-template>
-	</dd>
-      </xsl:if>
-      <xsl:if test="$hasstable">  
-	<dt>stable</dt>
-	<dd>
-	  <xsl:call-template name="output-patch-tracker-version">
-	    <xsl:with-param name="suite">stable</xsl:with-param>
-	  </xsl:call-template>
-	</dd>
-      </xsl:if>
-      <xsl:if test="$hastesting">
-	<dt>testing</dt>
-	<dd>
-	  <xsl:call-template name="output-patch-tracker-version">
-	    <xsl:with-param name="suite">testing</xsl:with-param>
-	  </xsl:call-template>
-	</dd>
-      </xsl:if>
-      <xsl:if test="$hasunstable">
-	<dt>unstable</dt>
-	<dd>
-	  <xsl:call-template name="output-patch-tracker-version">
-	    <xsl:with-param name="suite">unstable</xsl:with-param>
-	  </xsl:call-template>
-	</dd>
-      </xsl:if>
-      <xsl:if test="$hasexperimental">
-	<dt title="experimental release">exp</dt>
-	<dd>
-	  <xsl:call-template name="output-patch-tracker-version">
-	    <xsl:with-param name="suite">experimental</xsl:with-param>
-	  </xsl:call-template>
-	</dd>
-      </xsl:if>
+      <xsl:for-each select="$other/patch-tracker/package">
+        <dt title="{@suite} release"><xsl:value-of select="@suite" /></dt>
+        <dd>
+          <xsl:call-template name="output-patch-tracker-version">
+            <xsl:with-param name="suite"><xsl:value-of select="@suite"/></xsl:with-param>
+            <xsl:with-param name="version"><xsl:value-of select="@version"/></xsl:with-param>
+            <xsl:with-param name="patch-number"><xsl:value-of select="@patch-number"/></xsl:with-param>
+            <xsl:with-param name="nondebian-modifications"><xsl:value-of select="@nondebian-modifications"/></xsl:with-param>
+          </xsl:call-template>
+        </dd>
+      </xsl:for-each>
     </dl>
   </div>
 </xsl:template>
-- 
1.7.5.4

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: