$ps_opts = array();
if ($ps_id = Horde_Util::getFormData('ps')) {
$ps_opts['range'] = array($ps_id);
- $title = sprintf(_("Patchset (%s) for %s"), $ps_id, $where);
-} else {
- $title = sprintf(_("Patchsets for %s"), $where);
+ $title = sprintf(_("Patchset %s"), $ps_id);
+}
+
+if ($where) {
+ $ps_opts['file'] = $where;
+ if (!isset($title)) {
+ $title = sprintf(_("Patchsets for %s"), $where);
+ }
}
try {
- $ps = $VC->getPatchsetObject($where, $ps_opts);
+ $ps = $VC->getPatchsetObject($ps_opts);
$patchsets = $ps->getPatchsets();
} catch (Horde_Vcs_Exception $e) {
Chora::fatal($e);
// JS search not needed if showing a single patchset
if ($ps_id) {
- $full_ps_link = Horde::link(Chora::url('patchsets', $where)) . _("View All Patchsets for File") . '</a>';
-} else {
Horde::addScriptFile('QuickFinder.js', 'horde', true);
}
require CHORA_TEMPLATES . '/common-header.inc';
require CHORA_TEMPLATES . '/menu.inc';
-require CHORA_TEMPLATES . '/headerbar.inc';
-require CHORA_TEMPLATES . '/patchsets/header.inc';
-if (!$ps_id) {
+
+if ($ps_id) {
+ require CHORA_TEMPLATES . '/patchsets/header.inc';
+} else {
+ require CHORA_TEMPLATES . '/headerbar.inc';
+ require CHORA_TEMPLATES . '/patchsets/header.inc';
require CHORA_TEMPLATES . '/patchsets/header_table.inc';
}
-<div class="options">
- <span>
<?php if ($ps_id): ?>
- <?php echo $full_ps_link ?>
+<h1 class="header"><?php echo htmlspecialchars($title) ?></h1>
+<br />
<?php else: ?>
+<div class="options">
+ <span>
<?php echo _("Search Patchsets:") ?>
<input type="text" for="patchsets_body" size="20" />
-<?php endif; ?>
</span>
</div>
+<?php endif; ?>
/**
* TODO
+ *
+ * @param array $opts Options:
+ * <pre>
+ * 'file' - (string) TODO
+ * 'range' - (array) TODO
+ * </pre>
+ *
+ * @return Horde_Vcs_Patchset Patchset object.
*/
- public function getPatchsetObject($filename, $opts = array())
+ public function getPatchsetObject($opts = array())
{
$class = 'Horde_Vcs_Patchset_' . $this->_driver;
ksort($opts);
- $cacheId = implode('|', array($class, $this->sourceroot(), $filename, serialize($opts), $this->_cacheVersion));
+ $cacheId = implode('|', array($class, $this->sourceroot(), serialize($opts), $this->_cacheVersion));
if (!empty($this->_cache)) {
- // TODO: Can't use filemtime() - Git bare repos contain no files
- if (file_exists($filename)) {
- $ctime = time() - filemtime($filename);
+ if (isset($opts['file']) && file_exists($opts['file'])) {
+ $ctime = time() - filemtime($opts['file']);
} else {
$ctime = 60;
}
+
if ($this->_cache->exists($cacheId, $ctime)) {
return unserialize($this->_cache->get($cacheId, $ctime));
}
}
- $ob = new $class($this, $filename, $opts);
+ $ob = new $class($this, $opts);
if (!empty($this->_cache)) {
$this->_cache->set($cacheId, serialize($ob));
* @param string $file The filename to create a patchset for.
* @param array $opts Additional options.
* <pre>
+ * 'file' - (string) The filename to process.
+ * REQUIRED for this driver.
* 'range' - (array) The patchsets to process.
* DEFAULT: None (all patchsets are processed).
* </pre>
*
* @throws Horde_Vcs_Exception
*/
- public function __construct($rep, $file, $opts = array())
+ public function __construct($rep, $opts = array())
{
- $file = $rep->sourceroot() . '/' . $file;
+ $file = $rep->sourceroot() . '/' . $opts['file'];
/* Check that we are actually in the filesystem. */
if (!$rep->isFile($file)) {
* Constructor
*
* @param Horde_Vcs $rep A Horde_Vcs repository object.
- * @param string $file The filename to create patchsets for.
* @param array $opts Additional options.
* <pre>
+ * 'file' - (string) The filename to produce patchsets for.
* 'range' - (array) The patchsets to process.
* DEFAULT: None (all patchsets are processed).
* </pre>
*/
- public function __construct($rep, $file, $opts = array())
+ public function __construct($rep, $opts = array())
{
- $fileOb = $rep->getFileObject($file);
$revs = array();
- if (empty($opts['range'])) {
- $revs = $fileOb->queryLogs();
- } else {
+ if (isset($opts['file'])) {
+ $ob = $rep->getFileObject($file);
+ $revs = $ob->queryLogs();
+ } elseif (!empty($opts['range'])) {
foreach ($opts['range'] as $val) {
- $revs[$val] = $fileOb->queryLogs($val);
+ /* Grab a filename in the patchset to get log info. */
+ $cmd = $rep->getCommand() . ' diff-tree --name-only -r ' . escapeshellarg($val);
+ exec($cmd, $output);
+
+ /* The first line is the SHA1 hash. */
+ $ob = $rep->getFileObject($output[1]);
+ $revs[$val] = $ob->queryLogs($val);
}
}
* @param Horde_Vcs $rep A Horde_Vcs repository object.
* @param string $file The filename to create patchsets for.
*/
- public function __construct($rep, $file)
+ public function __construct($rep, $opts = array())
{
- $fileOb = $rep->getFileObject($file);
+ // TODO: Allow access via 'range'
+ $fileOb = $rep->getFileObject($opts['file']);
foreach ($fileOb->logs as $rev => $log) {
$this->_patchsets[$rev] = array(