'blame'
);
+define('SVN', '$Id$');
+
require_once('./global.php');
-$navbar = $controller->construct_breadcrumb();
+$navbar = ConstructNavbar();
// ###################################################################
-$latest = $controller->cachev->fetch_node();
-
-$link['log'] = $controller->href_compound('log.php');
-
-$show['head'] = ($latest['revision'] != $controller->revctx);
-if ($show['head'])
-{
- $link['gohead'] = $controller->href_compound('blame.php', null, Paths::fetch_rev_str(false, 'HEAD'));
- $link['diffhead'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, 'HEAD', $contoller->revctx));
-}
-
-$show['prev'] = ($prev = $controller->cachev->fetch_prev_revision($controller->revctx));
-if ($show['prev'])
-{
- $link['diffprev'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, $controller->revctx, $prev));
-}
-
-// ###################################################################
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
-$blame = new SVNBlame($controller);
+$blame = BSXml::Parse($lib->run('blame --xml -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true));
+$blame = $blame['blame']['target']['entry'];
+BSXml::UnifyNode($blame);
-$lines = '';
+$catdata = $lib->run('cat -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']));
-foreach ($blame->fetch() AS $entry)
+foreach ($catdata AS $num => $line)
{
- $entry['view_link'] = $controller->href_compound('view.php', null, Paths::fetch_rev_str(false, $entry['rev']));
- $entry['line_clean'] = SVNCommon::format($entry['line']);
+ $revision = $blame[$num]['commit']['revision'];
+ $author = $blame[$num]['commit']['author']['value'];
+ $view = ConstructLink('view', $input->in['repos'], $input->in['path'], $revision);
+ $line = FormatCode($line);
eval('$lines .= "' . $template->fetch('blame_line') . '";');
}
return BSRegister::Get('webpath') . '/' . $action . '/' . $repos . ':' . $path . ($rev > 0 ? '@' . $rev : '');
}
+// ###################################################################
+/**
+* Prepares data for output
+*
+* @param string Standard data
+*
+* @return string Output-ready data
+*/
+function FormatCode($string)
+{
+ // convert entities
+ $string = htmlspecialchars($string);
+
+ // tabs to 5 spaces
+ $string = str_replace("\t", ' ', $string);
+
+ // spaces to nbsp
+ if (true)
+ {
+ $string = preg_replace('#( +)#e', '_FormatSpaces("\1")', $string);
+ }
+ // no word wrap
+ else
+ {
+ $string = str_replace(' ', ' ', $string);
+ }
+
+ // convert advanced diff
+ $string = str_replace(array('{@+' . '+}', '{@-' . '-}'), array('<span class="diff_add_bit">', '<span class="diff_del_bit">'), $string);
+ $string = str_replace(array('{/@+' . '+}', '{/@-' . '-}'), '</span>', $string);
+
+ // nl2br
+ $string = nl2br($string);
+
+ return $string;
+}
+
+// ###################################################################
+/**
+* Counts the spaces and replaces two or more ones
+*
+* @param string Spaced string
+*
+* @return string 'd string
+*/
+function _FormatSpaces($thestring)
+{
+ if (strlen($thestring) >= 2)
+ {
+ $thestring = str_replace(' ', ' ', $thestring);
+ }
+
+ return $thestring;
+}
+
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
* @version $Id$
*/
class SVNCommon
-{
- // ###################################################################
- /**
- * Prepares data for output
- *
- * @access public
- *
- * @param string Standard data
- *
- * @return string Output-ready data
- */
- function format($string)
- {
- // convert entities
- $string = htmlspecialchars($string);
-
- // tabs to 5 spaces
- $string = str_replace("\t", ' ', $string);
-
- // spaces to nbsp
- if (true)
- {
- $string = preg_replace('#( +)#e', 'SVNCommon::format_spaces("\1")', $string);
- }
- // no word wrap
- else
- {
- $string = str_replace(' ', ' ', $string);
- }
-
- // convert advanced diff
- $string = str_replace(array('{@+' . '+}', '{@-' . '-}'), array('<span class="diff_add_bit">', '<span class="diff_del_bit">'), $string);
- $string = str_replace(array('{/@+' . '+}', '{/@-' . '-}'), '</span>', $string);
-
- // nl2br
- $string = nl2br($string);
-
- return $string;
- }
-
- // ###################################################################
- /**
- * Counts the spaces and replaces two or more ones
- *
- * @access private
- *
- * @param string Spaced string
- *
- * @return string 'd string
- */
- function format_spaces($thestring)
- {
- if (strlen($thestring) >= 2)
- {
- $thestring = str_replace(' ', ' ', $thestring);
- }
-
- return $thestring;
- }
-
+{
// ###################################################################
/**
* Prints the file changed list
}
}
-/**
-* Annotation/blame system; constructs an array that is ready for output
-*
-* @package ViewSVN
-* @version $Id$
-*/
-class SVNBlame
-{
- /**
- * Array of blame information
- * @var array
- * @access private
- */
- var $blame = array();
-
- /**
- * Raw "svn blame" output
- * @var array
- * @access private
- */
- var $rawoutput;
-
- // ###################################################################
- /**
- * Constructor: create blame and store data
- *
- * @param object Controller
- */
- function SVNBlame(&$controller)
- {
- $this->rawoutput = $controller->library->command('blame');
- $this->process();
- }
-
- // ###################################################################
- /**
- * Returns blame for display
- *
- * @access public
- *
- * @return array Blame data
- */
- function fetch()
- {
- return $this->blame;
- }
-
- // ###################################################################
- /**
- * Parses the blame data
- *
- * @access private
- */
- function process()
- {
- $lineno = 1;
-
- foreach ($this->rawoutput AS $line)
- {
- if (preg_match('#^\s+([0-9]+)\s+([\w\.\-_]+)\s(.*)$#', $line, $matches))
- {
- $this->blame[] = array(
- 'rev' => $matches[1],
- 'author' => $matches[2],
- 'line' => $matches[3],
- 'lineno' => $lineno++
- );
- }
- // a blank line
- else if (preg_match('#^\s+([0-9]+)\s+([\w\.\-_]+)$#', $line, $matches))
- {
- $this->blame[] = array(
- 'rev' => $matches[1],
- 'author' => $matches[2],
- 'line' => '',
- 'lineno' => $lineno++
- );
- }
- }
- }
-}
-
/**
* Diff system; constructs a diff array that is ready for output
*
<tr>
- <td class="lineheader" style="border-width: 0px 1px 1px 1px; width: 1%"><a href="$entry[view_link]">$entry[rev]</a></td>
- <td class="lineheader" style="border-width: 0px 1px 1px 0px; width: 1%">$entry[author]</td>
- <td class="code" style="border-width: 0px 1px 1px 0px">$entry[line_clean]</td>
+ <td class="lineheader" style="border-width: 0px 1px 1px 1px; width: 1%"><a href="$view">$revision</a></td>
+ <td class="lineheader" style="border-width: 0px 1px 1px 0px; width: 1%">$author</td>
+ <td class="code" style="border-width: 0px 1px 1px 0px">$line</td>
</tr>