示例#1
0
function getRevInfo($repository_id, $revision_id)
{
    global $db;
    $sth = $db->prepare('SELECT * FROM node_change WHERE repos=? AND rev=?');
    $sth->execute(array($repository_id, $revision_id));
    $files = array();
    while ($change = $sth->fetch(PDO::FETCH_ASSOC)) {
        list($module, $filename) = expandPath($change['path']);
        $base_rev = (int) ltrim($change['base_rev'], '0');
        $rev = (int) ltrim($change['rev'], '0');
        $file = array('file' => $filename, 'old_version' => $base_rev >= 0 ? $base_rev : null, 'new_version' => $rev, 'module' => $module);
        $files[] = $file;
    }
    return $files;
}
示例#2
0
/**
 *  This method returns a MetaPath. It needs to return that type because
 *  during expansion, the destination station may be found. If that is the
 *  case, then we need a way to indicate that we found a completed path. If
 *  there is no path found, then null is returned.
 *
 *  @return MetaPath the path that is extended or null if the path is no
 *  longer needed (hit a dead-end)
 */
function expandPath($path)
{
    // TODO modify method to check for path duration and to check whether
    // path has found a destination station.
    $debug = false;
    $currentStation = $path->getCurrentStation();
    outputDebug("current station = " . $currentStation->toString(), $debug);
    $lastStation = $path->getLastStation();
    outputDebug("last station = " . $lastStation->toString(), $debug);
    // if we're here, we know that currentStation is not a junction
    $visitedStations = array();
    $finished = false;
    foreach ($currentStation->getLines() as $line) {
        outputDebug("expandPath on line " . $line->name, $debug);
        foreach ($line->getConnections() as $connection) {
            $cid = $connection->id;
            outputDebug("current path : " . $path->toString(), $debug);
            outputDebug("looking at station = " . $cid, $debug);
            // TODO this if statement may not be necessary
            if (in_array($cid, $visitedStations)) {
                // already visited, so we ignore
                outputDebug("already visited " . $cid . ". ignoring.", $debug);
                continue;
            }
            if ($cid == $lastStation->getID()) {
                if (count($line->getConnections()) == 1) {
                    // this is a terminal path. it won't go where we want it to go
                    outputDebug("terminal path = " . $path->toString(), $debug);
                    return;
                }
                // we don't want to backtrack. ignore.
                continue;
            }
            // if we're here, we found the other station
            // there should be only one station, so no point
            $nextStation = retrieveStation($cid);
            outputDebug("found next station = " . $nextStation->toString(), $debug);
            $path->addSegment(new Segment($currentStation, $nextStation, $currentStation->getConnectingLines($nextStation, $connection->type), $connection->duration, $connection->type));
            if ($nextStation == $path->getDestination()) {
                // we found the destination station
                return new MetaPath("complete", $path);
            }
            if ($nextStation->isJunction()) {
                return new MetaPath("extended", $path);
            }
            $newPath = expandPath($path);
            #outputDebug("recursive complete.", $debug);
            //if ($newPath != null) {
            return $newPath;
            //}
        }
    }
    // we hit an end point and the only connection is backtracking.
    // don't care about the path at this point because it isn't useful.
    // we should check, however, to see if it is the destination point.
    return null;
}