TortoiseSVN, bugtraq:logregex and log message substitution in Bugtraq->replaceIDs()
<catapuit2000-websvn <at> yahoo.de>
2007-10-16 15:16:49 GMT
Hi,
to my understanding, it seems that TortoiseSVN follows a different policy on log message substitution than WebSVN:
1. If bugtraq:logregex is defined, substitution is done only according to bugtraq:logregex, no prepending or appending of bug IDs.
2. bugtraq:logregex may be single line but contain multiple capture groups with valid issue IDs. In this case, all captures should be transformed (one may use non-capturing groups for sub-pattern grouping). Sample pattern: [Ii]ssue #?(\d+)(?:,? ?#?(\d+))*
The attached patch is supposed to resolve these issues.
Diff command: svn diff bugtraq.php
Regards,
Hoang
Die etwas anderen Infos rund um das Thema Reisen.
BE A BETTER WELTENBUMMLER!
Index: bugtraq.php
===================================================================
--- bugtraq.php (revision 627)
+++ bugtraq.php (working copy)
<at> <at> -109,60 +109,60 <at> <at>
$logmsg = "";
$message = rtrim($message);
-
- if ($this->append)
- {
- // Just compare the last line
- if (($offset = strrpos($message, "\n")) !== false)
- {
- $logmsg = substr($message, 0, $offset + 1);
- $bugLine = substr($message, $offset + 1);
+
+ // Only perform this substitution when bugtraq:logregex is not set
+ if (!$this->logregex) {
+ if ($this->append)
+ {
+ // Just compare the last line
+ if (($offset = strrpos($message, "\n")) !== false)
+ {
+ $logmsg = substr($message, 0, $offset + 1);
+ $bugLine = substr($message, $offset + 1);
+ }
+ else
+ $bugLine = $message;
}
else
- $bugLine = $message;
- }
- else
- {
- if (($offset = strpos($message, "\n")) !== false)
{
- $bugLine = substr($message, 0, $offset);
- $logmsg = substr($message, $offset);
+ if (($offset = strpos($message, "\n")) !== false)
+ {
+ $bugLine = substr($message, 0, $offset);
+ $logmsg = substr($message, $offset);
+ }
+ else
+ $bugLine = $message;
}
- else
- $bugLine = $message;
- }
-
- // Make sure that our line really is an issue tracker message
-
- if (((strncmp($bugLine, $this->firstPart, $this->firstPartLen) == 0)) &&
- strcmp(substr($bugLine, -$this->lastPartLen, $this->lastPartLen), $this->lastPart) == 0)
- {
- // Get the issues list
- if ($this->lastPartLen > 0)
- $issues = substr($bugLine, $this->firstPartLen, -$this->lastPartLen);
- else
- $issues = substr($bugLine, $this->firstPartLen);
+
+ // Make sure that our line really is an issue tracker message
+
+ if (((strncmp($bugLine, $this->firstPart, $this->firstPartLen) == 0)) &&
+ strcmp(substr($bugLine, -$this->lastPartLen, $this->lastPartLen), $this->lastPart) == 0)
+ {
+ // Get the issues list
+ if ($this->lastPartLen > 0)
+ $issues = substr($bugLine, $this->firstPartLen, -$this->lastPartLen);
+ else
+ $issues = substr($bugLine, $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);
+ // 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%", $issue, $this->urlstring)."\">$issue</a>, ";
+ }
+ $line .= "<a href=\"".str_replace("%BUGID%", trim($issues), $this->urlstring)."\">".trim($issues)."</a>".$this->lastPart;
+
+ if ($this->append)
+ $message = $logmsg.$line;
+ else
+ $message = $line.$logmsg;
}
- $line .= "<a href=\"".str_replace("%BUGID%", trim($issues), $this->urlstring)."\">".trim($issues)."</a>".$this->lastPart;
-
- if ($this->append)
- $message = $logmsg.$line;
- else
- $message = $line.$logmsg;
}
-
- // Now replace all other instances of bug IDs that match the regex
-
- if ($this->logregex)
+ else // bugtraq:logregex is set
{
$message = rtrim($message);
$line = "";
<at> <at> -174,22 +174,24 <at> <at>
if (empty($regex_single))
{
- // If the property only contains one line, then the pattern is only designed
- // to find one issue number at a time. e.g. [Ii]ssue #?(\d+). In this case
- // we need to replace the matched issue ID with the link.
+ // If the property only contains one line, every capture must be an issue.
+ // e.g. [Ii]ssue #?(\d+)(?:,? ?#?(\d+))*. Therefore, we replace all
+ // captured issue IDs with proper links.
if ($numMatches = preg_match_all($regex_all, $message, $matches, PREG_SET_ORDER |
PREG_OFFSET_CAPTURE))
{
$addedOffset = 0;
for ($match = 0; $match < $numMatches; $match++)
{
- $issue = $matches[$match][1][0];
- $issueOffset = $matches[$match][1][1];
-
- $issueLink = "<a href=\"".str_replace("%BUGID%", $issue, $this->urlstring)."\">".$issue."</a>";
- $message = substr_replace($message, $issueLink, $issueOffset + $addedOffset, strlen($issue));
- $addedOffset += strlen($issueLink) - strlen($issue);
- }
+ for ($capture = 1; $capture < count($matches[$match]); $capture++) {
+ $issue = $matches[$match][$capture][0];
+ $issueOffset = $matches[$match][$capture][1];
+
+ $issueLink = "<a href=\"".str_replace("%BUGID%", $issue, $this->urlstring)."\">".$issue."</a>";
+ $message = substr_replace($message, $issueLink, $issueOffset + $addedOffset, strlen($issue));
+ $addedOffset += strlen($issueLink) - strlen($issue);
+ }
+ }
}
}
else
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe <at> websvn.tigris.org
For additional commands, e-mail: dev-help <at> websvn.tigris.org