// ###################################################################
-$revision = new Revision($input->in['repos'], $input->in['rev']);
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
// ###################################################################
// ###################################################################
-// $revinfo['message_clean'] = SVNCommon::format_log_message($revinfo['message']);
-// $revinfo['date'] = SVNCommon::format_date_string($revinfo['dateline']);
+$revision->getRevisionInfo();
$listing = BSXml::Parse($lib->run('ls --xml -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true));
*/
private $repos;
+ /**
+ * The subpath inside the repository we're getting info for
+ * @var string
+ */
+ private $subpath;
+
/**
* The revision number
* @var integer
*/
public $revision;
+ /**
+ * The commmit message for this revision
+ * @var string
+ */
+ public $message;
+
+ /**
+ * The unparsed/unformatted log message
+ * @var string
+ */
+ public $messageClean;
+
+ /**
+ * Author who committed the revision
+ * @var string
+ */
+ public $author;
+
+ /**
+ * The date and time this revision was made
+ * @var string
+ */
+ public $datetime;
+
// ###################################################################
/**
* Creates a new revision for a given repository and revision
*
* @param string Repository
* @param integer Revision to get; to get HEAD, specify 0
+ * @param string Path inside the repository to get info for
*/
- public function __construct($repos, $rev = 0)
+ public function __construct($repos, $rev = 0, $subpath = null)
{
$this->path = BSRegister::Get('repos')->fetchPath($repos);
$this->repos = $repos;
+ $this->subpath = $subpath;
$this->_fetchRevision($rev);
}
return $proplist;
}
+ // ###################################################################
+ /**
+ * Gets the revision information (commit message, author, date) for the
+ * revision
+ */
+ public function getRevisionInfo()
+ {
+ $xml = BSXml::Parse(BSRegister::Get('lib')->run('log --xml -r' . $this->revision . ' ' . BSRegister::Get('lib')->arg($this->path), true));
+ $this->message = FormatLogMessage($xml['log']['logentry']['msg']['value']);
+ $this->messasgeClean = $xml['log']['logentry']['msg']['value'];
+ $this->datetime = FormatSvnDate($xml['log']['logentry']['date']['value']);
+ $this->author = $xml['log']['logentry']['author']['value'];
+ }
+
// ###################################################################
/**
* Gets the desired XML revision information from the repository
*/
private function _fetchRevision($desired)
{
- $xml = BSXml::Parse(BSRegister::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister::Get('lib')->arg($this->path), true));
+ $xml = BSXml::Parse(BSRegister::Get('lib')->run('info --xml ' . ($desired > 0 ? '-r' . intval($desired) . ' ' : '') . BSRegister::Get('lib')->arg($this->path . $this->subpath), true));
$this->revision = intval($xml['info']['entry']['commit']['revision']);
}
}
return $proplist;
}
+// ###################################################################
+/**
+* Formats a SVN log message
+*
+* @param string Unformatted log message
+*
+* @return string Output-ready log message
+*/
+function FormatLogMessage($message)
+{
+ global $viewsvn;
+
+ $message = BSRegister::Get('input')->entityEncode($message);
+
+ // TODO - fix the revision links
+ // $message = preg_replace('#r([0-9]+)#e', '"<a href=\"" . $viewsvn->maincontrol->href_struct("diff.php" . Paths::fetch_rev_str(true, "\1", 0), "/") . "\">r\1</a>"', $message);
+
+ $list = false;
+ $lines = explode("\n", $message);
+ $message = '';
+ foreach ($lines AS $line)
+ {
+ if (preg_match('#^\s*?(\*|\-)\s?(.*)#', $line, $matches))
+ {
+ if ($list)
+ {
+ $message .= '<li>' . $matches[2] . '</li>';
+ }
+ else
+ {
+ $message .= '<ul class="list">';
+ $message .= '<li>' . $matches[2] . '</li>';
+ }
+ $list = true;
+ }
+ else
+ {
+ if ($list)
+ {
+ $message .= '</ul>';
+ $message .= $line;
+ }
+ else
+ {
+ $message .= $line;
+ $message .= '<br />';
+ }
+ $list = false;
+ }
+
+ $message .= "\n";
+ }
+
+ if ($list)
+ {
+ $message .= '</ul>';
+ }
+
+ $message = preg_replace('#(<br />)*$#', '', $message);
+
+ return $message;
+}
+
+// ###################################################################
+/**
+* Parses a date from SVN into something more human-friendly
+*
+* @param string Date string
+*
+* @return string Formatted and readable date string
+*/
+function FormatSvnDate($string)
+{
+ // 2005-01-23T20:42:53.703057Z
+ return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string);
+}
+
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
return $string;
}
- // ###################################################################
- /**
- * Formats a SVN log message
- *
- * @access public
- *
- * @param string Unformatted log message
- *
- * @return string Output-ready log message
- */
- function format_log_message($message)
- {
- global $viewsvn;
-
- $message = $viewsvn->entity_encode($message);
-
- $message = preg_replace('#r([0-9]+)#e', '"<a href=\"" . $viewsvn->maincontrol->href_struct("diff.php" . Paths::fetch_rev_str(true, "\1", 0), "/") . "\">r\1</a>"', $message);
-
- $list = false;
- $lines = explode("\n", $message);
- $message = '';
- foreach ($lines AS $line)
- {
- if (preg_match('#^\s*?(\*|\-)\s?(.*)#', $line, $matches))
- {
- if ($list)
- {
- $message .= '<li>' . $matches[2] . '</li>';
- }
- else
- {
- $message .= '<ul class="list">';
- $message .= '<li>' . $matches[2] . '</li>';
- }
- $list = true;
- }
- else
- {
- if ($list)
- {
- $message .= '</ul>';
- $message .= $line;
- }
- else
- {
- $message .= $line;
- $message .= '<br />';
- }
- $list = false;
- }
-
- $message .= "\n";
- }
-
- if ($list)
- {
- $message .= '</ul>';
- }
-
- $message = preg_replace('#(<br />)*$#', '', $message);
-
- return $message;
- }
-
- // ###################################################################
- /**
- * Parses a date from Xquery XML outut
- *
- * @access public
- *
- * @param string Date string
- *
- * @return string Formatted and readable date string
- */
- function format_date_string($string)
- {
- // 2005-01-23T20:42:53.703057Z
- return preg_replace('#(....)\-(..)\-(..)T(..):(..):(..).(.*)Z#e', 'gmdate("r", mktime(\4, \5, \6, \2, \3, \1))', $string);
- }
-
// ###################################################################
/**
* Counts the spaces and replaces two or more ones
<div class="head">{@"Revision Information"}</div>
<div class="content">
- <div><strong>{@"Revision"}:</strong> $revinfo[revision]</div>
- <div><strong>{@"Author"}:</strong> $revinfo[author]</div>
- <div><strong>{@"Date"}:</strong> $revinfo[date]</div>
- <div><strong>{@"Message"}:</strong> $revinfo[message_clean]</div>
+ <div><strong>{@"Revision"}:</strong> $revision->revision</div>
+ <div><strong>{@"Author"}:</strong> $revision->author</div>
+ <div><strong>{@"Date"}:</strong> $revision->datetime</div>
+ <div><strong>{@"Message"}:</strong> $revision->message</div>
</div>
<div class="head" style="border-width: 0px 1px 1px 1px">
<div class="head">{@"Revision Information"}</div>
<div class="content">
- <div><strong>{@"Revision"}:</strong> $logmsg[revision]</div>
- <div><strong>{@"Author"}:</strong> $logmsg[author]</div>
- <div><strong>{@"Date"}:</strong> $logmsg[date]</div>
- <div><strong>{@"Message"}:</strong> $logmsg[message_clean]</div>
+ <div><strong>{@"Revision"}:</strong> $revision->revision</div>
+ <div><strong>{@"Author"}:</strong> $revision->author</div>
+ <div><strong>{@"Date"}:</strong> $revision->datetime</div>
+ <div><strong>{@"Message"}:</strong> $revision->message</div>
</div>
<div class="head" style="border-width: 0px 1px 0px 1px">
// ###################################################################
-$revision = new Revision($input->in['repos'], $input->in['rev']);
+$revision = new Revision($input->in['repos'], $input->in['rev'], $input->in['path']);
// ###################################################################
-/*$logmsg = $controller->cachev->fetch_revision($controller->revctx);
-unset($logmsg['files']);
-
-$logmsg['message_clean'] = SVNCommon::format_log_message($logmsg['message']);
-$logmsg['date'] = SVNCommon::format_date_string($logmsg['dateline']);*/
+$revision->getRevisionInfo();
$catdata = $lib->run('cat -r' . $revision->revision . ' ' . $lib->arg($repos->fetchPath($input->in['repos']) . $input->in['path']), true);