return max(array_keys($data));
}
+ // ###################################################################
+ /**
+ * Returns the revision entry that it's in context with the node. For
+ * instance, if the version 50 was passed and this node only has 48 as
+ * it's max, 48 will be returned.
+ *
+ * @access public
+ *
+ * @param integer Target revision
+ *
+ * @return integer Contextual revision
+ */
+ function fetch_revision_context($target)
+ {
+ $data = $this->fetch_node();
+ $data = $data['history'];
+
+ if (isset($data["$target"]))
+ {
+ return $this->fetch_revision($target);
+ }
+
+ $keys = array_keys($data);
+
+ $prev = 0;
+ foreach ($keys AS $id => $revnum)
+ {
+ if ($target > $revnum)
+ {
+ $prev = $revnum;
+ if ($prev > $rev)
+ {
+ $rev = $prev;
+ }
+ }
+ else if ($target < $revnum)
+ {
+ $rev = $prev;
+ }
+ else
+ {
+ $rev = $keys[0];
+ }
+ }
+
+ return $this->fetch_revision($rev);
+ }
+
// ###################################################################
/**
* Fetches the latest revision for a given path
*/
var $revstr;
+ /**
+ * The revision number in context for this node. For instance, r40 may be passed, but the file only has revision 38 (and that's what this would be)
+ * @var integer
+ * @access public
+ */
+ var $revctx;
+
// ###################################################################
/**
* Constructor
require_once('./includes/cachev.php');
$this->cachev = new cacheV($this);
+
+ $this->revctx = $this->cachev->fetch_revision_context($this->revnum);
+ $this->revctx = $this->revctx['revision'];
}
// ###################################################################
if ($show['head'])
{
$link['gohead'] = $controller->href_compound('view.php', null, Paths::fetch_rev_str(false, 'HEAD'));
- $link['diffhead'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, 'HEAD', $controller->revnum));
+ $link['diffhead'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, 'HEAD', $controller->revctx));
}
-$show['prev'] = ($prev = $controller->cachev->fetch_prev_revision($controller->revnum));
+$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->revnum, $prev['revision']));
+ $link['diffprev'] = $controller->href_compound('diff.php', null, Paths::fetch_rev_str(true, $controller->revctx, $prev['revision']));
}
// ###################################################################
-$logmsg = $controller->cachev->fetch_revision($controller->revnum);
+$logmsg = $controller->cachev->fetch_revision($controller->revctx);
unset($logmsg['files']);
$logmsg['message_clean'] = SVNCommon::format_log_message($logmsg['message']);