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

Bug#393462: PTS: please make VCS link also point to browsable copy



tags 393462 + patch
thanks

On Mon, Oct 16, 2006 at 03:34:37PM +0200, Thijs Kinkhorst wrote:
> The latest addition to the PTS, showing VCS repositories for packages,
> is a great addition. However, I'd like it even better if there was also
> a link to a web browsable copy of the repository.

The attached patch adds support for the 'XS-Vcs-Browser' field in
debian/control file. That field, already used by several packages in the
archive FWIW, has a value which is a URL pointing to a web browsable
version of the VCS repository. The other fields XS-Vcs-{SVN,Arch,...}
preserve the current semantics (i.e. a "string" describing where the
version controlled sources can be found; the string is meaningful for
the given versioning system).

In addition to that the patch also support multiple repositories to be
listed for the same source package (the former behaviour of that was to
keep only one of them). Still, only one XS-Vcs-Browser field is
supported, and IMO this is the right behaviour.

> There's currently also a link to the upstream website of the used
> vcs (e.g. http://subversion.tigris.org). I don't think that link is very
> useful (and if it's really needed, a link to the Debian package would be
> more logical). That link could then disappear to make room for the
> feature above.

The patch also removes that hyperlink, which I agree was useless. The
display format implemented by the patch is shown in the following
example (casted down to ASCII art):

  Version Control:         browser
                     raw: CVS, Subversion

With "browser" being an hyperlink to the browsable version (if any). The
"raw" line exists only if at least one XS-Vcs-XXX field (with XXX !=
"browser") exists. Each comma separated VCS system name is an hyperlink
pointing to the string given for the VCS system.

Cheers.

-- 
Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
(15:56:48)  Zack: e la demo dema ?    /\    All one has to do is hit the
(15:57:15)  Bac: no, la demo scema    \/    right keys at the right time
Index: xsl/pts.xsl
===================================================================
--- xsl/pts.xsl	(revision 1497)
+++ xsl/pts.xsl	(working copy)
@@ -95,25 +95,27 @@
   <xsl:if test="repository">
     <tr>
       <td class="labelcell">
-        <acronym title="Version Control System">VCS</acronym>
+        <xsl:text>Version Control</xsl:text>
       </td>
       <td class="contentcell">
-        <xsl:element name="a">
-          <xsl:attribute name="href">
-            <xsl:value-of select="repository/kind/@href" />
-          </xsl:attribute>
-          <xsl:value-of select="repository/kind"/>
-        </xsl:element>
-        <xsl:text> </xsl:text>
-        <xsl:element name="a">
-          <xsl:attribute name="href">
-            <xsl:value-of select="repository/url" />
-          </xsl:attribute>
-          <xsl:attribute name="title">
-            <xsl:value-of select="repository/url" />
-          </xsl:attribute>
-          <xsl:text>repository</xsl:text>
-        </xsl:element>
+        <xsl:if test="repository/vcs[@kind='browser']">
+          <a href="{repository/vcs[@kind='browser']/@url}">
+            <xsl:text>browser</xsl:text>
+          </a>
+          <br />
+        </xsl:if>
+        <xsl:if test="repository/vcs[@kind!='browser']">
+          <xsl:text>raw: </xsl:text>
+          <xsl:for-each select="repository/vcs[@kind!='browser']">
+            <xsl:sort select="@kind" />
+            <a href="{@url}">
+              <xsl:value-of select="@kind" />
+            </a>
+            <xsl:if test="position()!=last()">
+              <xsl:text>, </xsl:text>
+            </xsl:if>
+          </xsl:for-each>
+        </xsl:if>
       </td>
     </tr>
   </xsl:if>
Index: bin/sources_to_xml.py
===================================================================
--- bin/sources_to_xml.py	(revision 1497)
+++ bin/sources_to_xml.py	(working copy)
@@ -116,19 +116,20 @@
             else:
                 prefix_len = 4
             # e.g. tag[prefix_len:] would be 'svn' for 'x-vcs-svn'/'vcs-svn'
-            if vcs_table.has_key(tag[prefix_len:]):
+            # would be 'browser' for 'vcs-browser' (to be handled specially)
+            repos_elt = list(root.getElementsByTagName('repository'))
+            if repos_elt:   # reuse existing repository element
+                repos_elt = repos_elt[0] # invariant: at most 1 repository elt
+            else:   # create a new repository element
                 repos_elt = doc.createElement('repository')
                 root.appendChild(repos_elt)
-                kind_elt = doc.createElement('kind')
-                repos_elt.appendChild(kind_elt)
-                (name, vcsurl) = vcs_table[tag[prefix_len:]]
-                kind_elt.setAttribute('href', vcsurl)
-                name_txt = doc.createTextNode(name)
-                kind_elt.appendChild(name_txt)
-                url_elt = doc.createElement('url')
-                repos_elt.appendChild(url_elt)
-                url_txt = doc.createTextNode(m[tag])
-                url_elt.appendChild(url_txt)
+            vcs_elt = doc.createElement('vcs')
+            kind = tag[prefix_len:]
+            if vcs_table.has_key(kind):
+                kind = vcs_table[kind][0]
+            vcs_elt.setAttribute('kind', kind)
+            vcs_elt.setAttribute('url', m[tag])
+            repos_elt.appendChild(vcs_elt)
     # Print the DOM object to a file
     try:
         f = open("%s/%s/%s/%s.xml" % (odir, hash, package, dist), "w")

Attachment: signature.asc
Description: Digital signature


Reply to: