Login | Register
My pages Projects Community openCollabNet

Discussions > commits > websvn commit: r284 - in trunk: . include

websvn
Discussion topic

Back to topic list

websvn commit: r284 - in trunk: . include

Reply

Author tarmes
Full name Tim Armes
Date 2004-08-25 06:58:53 PDT
Message Author: tarmes
Date: Wed Aug 25 08:58:48 2004
New Revision: 284

Added:
   trunk/include/bugtraq.inc
Modified:
   trunk/changes.txt
   trunk/include/configclass.inc
   trunk/include/distconfig.inc
   trunk/include/svnlook.inc
   trunk/listing.php
   trunk/log.php
Log:
Initial implementation of bugtraq property parsing.

This implementation is based on code found in revision 1591 of TortoiseSVN. Note that the code doesn't quite match the specification proposal found at http://svn.collab.ne​t/repos/tortoisesvn/​trunk/doc/issuetrack​ers.txt in that the specification places a newline after the bugtraq:message whereas the code in TSVN (and thus here) expects bugtraq:message to be the very last line of the log message.


Modified: trunk/changes.txt
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/changes.txt?view=​diff&rev=284​&p1=trunk/changes.tx​t&r1=283&p2=​trunk/changes.txt​&r2=284
====================​====================​====================​==================
--- trunk/changes.txt (original)
+++ trunk/changes.txt Wed Aug 25 08:58:48 2004
@@ -14,6 +14,8 @@
      Peter Valdemar M�rch for this patch.
 NEW: Various configuration options may now be applied on a per project
      basis. Look in distconfig for instructions.
+NEW: Support for using 'bugtraq' properties when display log entries.
+ See http://svn.collab.ne​t/repos/tortoisesvn/​trunk/doc/issuetrack​ers.txt
 NEW: Traditional Chinese translation
      
 CHANGE: Style information removed from RSS feed

Added: trunk/include/bugtraq.inc
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/include/bugtraq.i​nc?view=auto&rev​=284
====================​====================​====================​==================
--- (empty file)
+++ trunk/include/bugtraq.inc Wed Aug 25 08:58:48 2004
@@ -0,0 +1,120 @@
+<?php
+
+// WebSVN - Subversion repository viewing via the web using PHP
+// Copyright (C) 2004 Tim Armes
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// --
+//
+// bugtraq.inc
+//
+// Functions for accessing the bugtraq properties and replacing issue IDs
+// with URLs.
+//
+// For more information about bugtraq, see
+// http://svn.collab.ne​t/repos/tortoisesvn/​trunk/doc/issuetrack​ers.txt
+
+class Bugtraq
+{
+ var $msgstring;
+ var $urlstring;
+
+ var $firstPart;
+ var $firstPartLen;
+ var $lastPart;
+ var $lastPartLen;
+
+ var $propsfound = false;
+
+ function Bugtraq($rep, $svnrep, $path)
+ {
+ global $config;
+
+ if ($rep->getBugtraq())
+ {
+ $pos = strrpos($path, "/");
+ $parent = substr($path, 0, $pos + 1);
+
+ while ((empty($this->msgstring) || empty($this->urlstring)) && (strpos($parent, "/") !== false))
+ {
+ if (empty($this->msgstring)) $this->msgstring = $svnrep->getProp​erty($parent, 'bugtraq:message');
+ if (empty($this->urlstring)) $this->urlstring = $svnrep->getProp​erty($parent, 'bugtraq:url');
+
+ $parent = substr($parent, 0, -1); // Remove the trailing slash
+ $pos = strrpos($parent, "/"); // Find the last trailing slash
+ $parent = substr($parent, 0, $pos + 1); // Find the previous parent directory
+ }
+
+ if (!empty($this->msgstring) && !empty($this->urlstring))
+ {
+ if (($bugidpos = strpos($this->msgstring, "%BUGID%")) !== false && strpos($this->urlstring, "%BUGID%") !== false)
+ {
+ // Get the textual parts of the message string for comparison purposes
+ $this->firstPart = substr($this->msgstring, 0, $bugidpos);
+ $this->firstPartLen = strlen($this->firstPart);
+ $this->lastPart = substr($this->msgstring, $bugidpos + 7);
+ $this->lastPartLen = strlen($this->lastPart);
+ }
+
+ $this->propsfound = true;
+ }
+ }
+ }
+
+ function replaceIDs($message)
+ {
+ if ($this->propsfound)
+ {
+ $logmsg = "";
+
+ // Just compare the last line
+ if ($offset = strrpos($message, "\n"))
+ {
+ $logmsg = substr($message, 0, $offset + 1);
+ $lastLine = substr($message, $offset + 1);
+ }
+ else
+ $lastLine = $message;
+
+ // Make sure that our line really is an issue tracker message
+ if (strncmp($lastLine, $this->firstPart, $this->firstPartLen) == 0 &&
+ strcmp(substr($lastLine, -$this->lastPartLen, $this->lastPartLen), $this->lastPart) == 0)
+ {
+ // Get the issues list
+ if ($this->lastPartLen > 0)
+ $issues = substr($lastLine, $this->firstPartLen, -$this->lastPartLen);
+ else
+ $issues = substr($lastLine, $this->firstPartLen);
+
+ // Add each reference to the first part of the line
+ $line = $this->firstPart;
+ while ($pos = strpos($issues, ","))
+ {
+ $issue = trim(substr($issues, 0, $pos));
+ $issues = substr($issues, $pos + 1);
+
+ $line .= "<a href=\"".str_replace("%BUGID%", $issue, $this->urlstring​)."\">$issue​</a>,";
+ }
+ $line .= "<a href=\"".str_replace("%BUGID%", $issues, $this->urlstring​)."\">$issues​</a>".$this-​>lastPart;
+
+ return $logmsg.$line;
+ }
+ }
+
+ return $message;
+ }
+}
+?>

Modified: trunk/include/configclass.inc
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/include/configcla​ss.inc?view=diff​&rev=284&p1=trun​k/include/configclas​s.inc&r1=283​&p2=trunk/include/co​nfigclass.inc&r2​=284
====================​====================​====================​==================
--- trunk/include/configclass.inc (original)
+++ trunk/include/configclass.inc Wed Aug 25 08:58:48 2004
@@ -41,11 +41,13 @@
    var $path;
    
    // Local configuration options must start off unset
+
    var $allowDownload;
    var $rss;
    var $spaces;
    var $ignoreSvnMimeTypes;
    var $ignoreWebSVNContentTypes;
+ var $bugtraq;
    
    function Repository($name, $path)
    {
@@ -157,6 +159,28 @@
          
       return $config->ignoreW​ebSVNContentTypes;
    }
+
+ // Issue Tracking
+
+ function useBugtraqProperties()
+ {
+ $this->bugtraq = true;
+ }
+
+ function ignoreBugtraqProperties()
+ {
+ $this->bugtraq = false;
+ }
+
+ function getBugtraq()
+ {
+ global $config;
+
+ if (isset($this->bugtraq))
+ return $this->bugtraq;
+
+ return $config->bugtraq;
+ }
 }
 
 // The general configuration class
@@ -182,7 +206,7 @@
    var $allowDownload = false;
    var $rss = true;
    var $spaces = 8;
- var $refRepositoriesByNumber = false;
+ var $bugtraq = false;
   
    var $templatePath = "./templates/Standard/";
 
@@ -548,5 +572,9 @@
       $this->ignoreWeb​SVNContentTypes = true;
    }
 
+ function useBugtraqProperties()
+ {
+ $this->bugtraq = true;
+ }
 }
 ?>

Modified: trunk/include/distconfig.inc
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/include/distconfi​g.inc?view=diff&​rev=284&p1=trunk​/include/distconfig.​inc&r1=283&p​2=trunk/include/dist​config.inc&r2=28​4
====================​====================​====================​==================
--- trunk/include/distconfig.inc (original)
+++ trunk/include/distconfig.inc Wed Aug 25 08:58:48 2004
@@ -203,6 +203,19 @@
 // $config->findRep​ository("myrep")-​>hideRSS(); // Specifically hide RSS links for 'myrep'
 // $config->findRep​ository("myrep")-​>showRSS(); // Specifically show RSS links for 'myrep'
 
+// --- BUGTRAQ ---
+
+// Uncomment this line if you wish to use bugtraq: properties to show links to your BugTracker
+// from the log messages.
+//
+// $config->useBugt​raqProperties();
+//
+// To change the global option for individual repositories, uncomment and replicate
+// the required line below (replacing 'myrep' for the name of the repository to be changed).
+
+// $config->findRep​ository("myrep")-​>useBugtraqPropertie​s(); // Specifically use bugtraq properties for 'myrep'
+// $config->findRep​ository("myrep")-​>ignoreBugtraqProper​ties(); // Specifically ignore bugtraq properties for 'myrep'
+
 // --- MISCELLANOUS ---
 
 // Uncomment this if you don't have the right to use it. Be warned that you may need it however!

Modified: trunk/include/svnlook.inc
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/include/svnlook.i​nc?view=diff&rev​=284&p1=trunk/in​clude/svnlook.inc​&r1=283&p2=trun​k/include/svnlook.in​c&r2=284
====================​====================​====================​==================
--- trunk/include/svnlook.inc (original)
+++ trunk/include/svnlook.inc Wed Aug 25 08:58:48 2004
@@ -521,7 +521,13 @@
       $revstr = _revStr($rev);
       
       $path = encodepath(str_repla​ce(DIRECTORY_SEPARAT​OR, "/", $this->repPath.$path));
- return implode("\n",runCom​mand($config->sv​n." propget $property $revstr ".quote("file:///".$path), true));
+ $ret = runCommand($config->svn." propget $property $revstr ".quote("file:///".$path), true);
+
+ // Remove the surplus newline
+ if (count($ret))
+ unset($ret[count($ret) - 1]);
+
+ return implode("\n", $ret);
    }
 
   function getHistory($path, $rev = 0)

Modified: trunk/listing.php
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/listing.php?view=​diff&rev=284​&p1=trunk/listing.ph​p&r1=283&p2=​trunk/listing.php​&r2=284
====================​====================​====================​==================
--- trunk/listing.php (original)
+++ trunk/listing.php Wed Aug 25 08:58:48 2004
@@ -27,6 +27,7 @@
 require_once("includ​e/svnlook.inc");
 require_once("includ​e/utils.inc");
 require_once("includ​e/template.inc");
+require_once("inclu​de/bugtraq.inc");
 
 function fileLink($path, $file, $returnjoin = false)
 {
@@ -211,10 +212,12 @@
 else
    $vars["goyoungestlink"] = "";
 
+$bugtraq = new Bugtraq($rep, $svnrep, $ppath);
+
 $vars["action"] = "";
 $vars["author"] = $log['author'];
 $vars["date"] = $log['date'];
-$vars["log"] = nl2br(create_anchors​($log['message']));​
+$vars["log"] = $bugtraq->replac​eIDs(nl2br(create_an​chors($log['message​'])));
 $vars["rev"] = $log["rev"];
 $vars["path"] = $ppath;
 

Modified: trunk/log.php
Url: http://svn.collab.ne​t/viewcvs/websvn/tru​nk/log.php?view=diff​&rev=284&p1=​trunk/log.php&r1​=283&p2=trunk/lo​g.php&r2=284
====================​====================​====================​==================
--- trunk/log.php (original)
+++ trunk/log.php Wed Aug 25 08:58:48 2004
@@ -27,6 +27,7 @@
 require_once("includ​e/svnlook.inc");
 require_once("includ​e/utils.inc");
 require_once("includ​e/template.inc");
+require_once("inclu​de/bugtraq.inc");
 
 $page = (int)@$_REQUEST["page"];
 $all = (@$_REQUEST["all"] == 1)?1:0;
@@ -110,6 +111,9 @@
 else
    $vars["goyoungestlink"] = "";
 
+// We get the bugtraq variable just once based on the HEAD
+$bugtraq = new Bugtraq($rep, $svnrep, $ppath);
+
 $history = $svnrep->getHistory($path, $rev);
 
 // Get the number of separate revisions
@@ -214,6 +218,10 @@
       $listing[$index]["revlog"] = nl2br(create_anchors​($log["message"]));​
       $listing[$index]["rowparity"] = "$row";
 
+ // Look for bugtraq properties if asked
+
+ $listing[$index]["revlog"] = $bugtraq->replac​eIDs($listing[$ind​ex]["revlog"]);
+
       $row = 1 - $row;
       $index++;
    }

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

websvn commit: r284 - in trunk: . include tarmes Tim Armes 2004-08-25 06:58:53 PDT
Messages per page: