Added multi-chan support
This commit is contained in:
@@ -8,7 +8,7 @@ image {
|
||||
border: none;
|
||||
}
|
||||
|
||||
body {
|
||||
body, select {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color: #1e1e1e;
|
||||
|
||||
32
index.php
32
index.php
@@ -42,11 +42,11 @@ function sort_by_date($a, $b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
function print_changes($current, $next)
|
||||
function print_changes($current, $next, $chan)
|
||||
{
|
||||
global $DB;
|
||||
$revs = array();
|
||||
if (!($res = $DB->query(kl_str_sql("select revisions from changes where build<=!i and build>!i order by build desc", $current->nr, $next->nr)))) {
|
||||
if (!($res = $DB->query(kl_str_sql("select revisions from changes where chan=!s and build<=!i and build>!i order by build desc", $chan, $current->nr, $next->nr)))) {
|
||||
return;
|
||||
} else {
|
||||
while ($row = $DB->fetchRow($res)) {
|
||||
@@ -54,7 +54,7 @@ function print_changes($current, $next)
|
||||
}
|
||||
}
|
||||
|
||||
if ($res = $DB->query("select * from revs where hash in ('" . implode("','", $revs) . "')")) {
|
||||
if ($res = $DB->query(kl_str_sql("select * from revs where chan=!s and hash in ('" . implode("','", $revs) . "')", $chan))) {
|
||||
print '<table style="width: 100%;">';
|
||||
|
||||
$changesets = array();
|
||||
@@ -73,7 +73,7 @@ function print_changes($current, $next)
|
||||
}
|
||||
}
|
||||
|
||||
Function print_build($current, $next, $buildNr)
|
||||
Function print_build($current, $next, $buildNr, $chan)
|
||||
{
|
||||
print "
|
||||
<tr style=\"background-color: #303030;\">
|
||||
@@ -88,15 +88,31 @@ Function print_build($current, $next, $buildNr)
|
||||
<a href="javascript:void(0)" id="toggle_link_'. $current->nr . '" onclick="javascript:toggleChanges('. $current->nr . ')">' .
|
||||
($buildNr ? 'Hide changes <<' : 'Show changes >>') .
|
||||
'</a><div ' . ($buildNr ? '' : 'style="display: none;"') . ' id="changes_' . $current->nr . '">';
|
||||
print_changes($current, $next);
|
||||
print_changes($current, $next, $chan);
|
||||
print "</div></td></tr>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function chan_selector($current_chan)
|
||||
{
|
||||
global $CHANS;
|
||||
print '<form method="GET">';
|
||||
print 'Select channel <select name="chan" onchange="this.form.submit()">';
|
||||
foreach($CHANS as $chan => $ref) {
|
||||
print "<option value=\"$chan\"" . ($current_chan == $chan ? " selected" : "") . ">$chan</option>";
|
||||
}
|
||||
print '</select><noscript><input type="submit" value="Change"></noscript></form>';
|
||||
|
||||
}
|
||||
|
||||
Layout::header();
|
||||
|
||||
$chan = "SingularityAlpha";
|
||||
if (isset($_GET["chan"]) && isset($CHANS[$_GET["chan"]])) {
|
||||
$chan = $_GET["chan"];
|
||||
} else {
|
||||
$chan = "SingularityMultiWearable";
|
||||
}
|
||||
|
||||
$pageSize = 20;
|
||||
|
||||
@@ -109,6 +125,8 @@ if (isset($_GET["build_id"])) {
|
||||
$buildNr = (int)$_GET["build_id"];
|
||||
$pageSize = 1;
|
||||
$where = kl_str_sql(" and nr <= !i ", $buildNr);
|
||||
} else {
|
||||
chan_selector($chan);
|
||||
}
|
||||
|
||||
if ($res = $DB->query(kl_str_sql("select * from builds where chan=!s $where order by nr desc limit !i", $chan, $pageSize + 1))) {
|
||||
@@ -128,7 +146,7 @@ if ($nrBuilds) {
|
||||
|
||||
for ($i = 0; $i < $pageSize; $i++) {
|
||||
if (!isset($builds[$i])) continue;
|
||||
print_build($builds[$i], $builds[$i + 1], $buildNr);
|
||||
print_build($builds[$i], $builds[$i + 1], $buildNr, $chan);
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@@ -80,7 +80,7 @@ class Layout
|
||||
</div><!-- container -->
|
||||
<div class="container">
|
||||
<table style="width: 100%; border: none; padding: 0;"><tr>
|
||||
<td class="bottom-links"><a href="http://www.singularityviewer.org/">Sigularity Main Site</a></td>
|
||||
<td class="bottom-links"><a href="http://www.singularityviewer.org/">Singularity Main Site</a></td>
|
||||
<td class="bottom-links"><a href="http://www.singularityviewer.org/about">About</a></td>
|
||||
<td class="bottom-links"><a href="http://code.google.com/p/singularity-viewer/issues/">Issue Tracker</a></td>
|
||||
<td class="bottom-links"><a href="https://github.com/siana/SingularityViewer">Source Tracker</a></td>
|
||||
|
||||
@@ -12,7 +12,7 @@ if (PHP_SAPI != "cli") {
|
||||
define("SITE_ROOT", realpath(dirname(__file__) . "/.."));
|
||||
require_once SITE_ROOT . "/lib/init.php";
|
||||
|
||||
function import_rev($raw)
|
||||
function import_rev($raw, $chan)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
@@ -43,24 +43,19 @@ function import_rev($raw)
|
||||
|
||||
$DB->query(
|
||||
kl_str_sql(
|
||||
"insert into revs (hash, author, time, message) values (!s, !s, !t, !s)",
|
||||
$hash, $author, $date, $msg));
|
||||
"insert into revs (hash, chan, author, time, message) values (!s, !s, !s, !t, !s)",
|
||||
$hash, $chan, $author, $date, $msg));
|
||||
|
||||
}
|
||||
|
||||
function save_build_changes($changes)
|
||||
function save_build_changes($changes, $chan)
|
||||
{
|
||||
global $DB;
|
||||
|
||||
$DB->query("begin transaction");
|
||||
if (!($res = $DB->query("delete from changes"))) {
|
||||
$DB->query("create table changes (build integer, revisions text, primary key(build))");
|
||||
}
|
||||
$DB->query("commit");
|
||||
|
||||
$DB->query("begin transaction");
|
||||
foreach ($changes as $buildNr => $revs) {
|
||||
$DB->query(kl_str_sql("insert into changes (build, revisions) values (!i, !s)", $buildNr, implode(",", $revs)));
|
||||
$DB->query(kl_str_sql("insert into changes (build, chan, revisions) values (!i, !s, !s)", $buildNr, $chan, implode(",", $revs)));
|
||||
}
|
||||
$DB->query("commit");
|
||||
|
||||
@@ -68,51 +63,65 @@ function save_build_changes($changes)
|
||||
|
||||
function update_revs()
|
||||
{
|
||||
global $DB;
|
||||
global $DB, $CHANS;
|
||||
|
||||
$DB->query("begin transaction");
|
||||
if (!($res = $DB->query("delete from revs"))) {
|
||||
$DB->query("create table revs(hash varchar, author varchar, time timestamp, message text, diff text, primary key(hash))");
|
||||
$DB->query("create table revs(hash varchar, chan varchar, author varchar, time timestamp, message text, diff text, primary key(hash))");
|
||||
}
|
||||
|
||||
$DB->query("commit");
|
||||
|
||||
$DB->query("begin transaction");
|
||||
$revs = array_reverse(explode(chr(0), rtrim(`git rev-list HEAD --header`)));
|
||||
$nrRevs = count($revs);
|
||||
|
||||
print "Importing $nrRevs revisions\n";
|
||||
|
||||
for ($i=0; $i<$nrRevs; $i++) {
|
||||
import_rev($revs[$i]);
|
||||
$DB->query("begin transaction");
|
||||
if (!($res = $DB->query("delete from changes"))) {
|
||||
$DB->query("create table changes (build integer, chan varchar, revisions text, primary key(build, chan))");
|
||||
}
|
||||
$DB->query("commit");
|
||||
|
||||
$res = $DB->query("commit");
|
||||
|
||||
$revs = explode("\n", rtrim(`git rev-list HEAD`));
|
||||
|
||||
$res = 0;
|
||||
$c =0;
|
||||
$changesAt = array();
|
||||
|
||||
while (true) {
|
||||
exec("git reset --soft HEAD~ 2>&1", $out, $res);
|
||||
if ($res != 0) {
|
||||
break;
|
||||
} else {
|
||||
$c++;
|
||||
$newRevs = explode("\n", rtrim(`git rev-list HEAD`));
|
||||
$changes = array_diff($revs, $newRevs);
|
||||
$nrChanges = count($changes);
|
||||
$build = count($revs);
|
||||
$revs = $newRevs;
|
||||
$changesAt[$build] = $changes;
|
||||
print $nrChanges . " changes in build $build\n";
|
||||
if ($build < 2169) break; // this is when we started building
|
||||
foreach ($CHANS as $chan => $branch) {
|
||||
exec("git fetch --all 2>&1");
|
||||
if ($branch != "HEAD") {
|
||||
exec("git reset --soft $branch 2>&1");
|
||||
}
|
||||
|
||||
$DB->query("begin transaction");
|
||||
|
||||
$revs = array_reverse(explode(chr(0), rtrim(`git rev-list HEAD --header`)));
|
||||
$nrRevs = count($revs);
|
||||
|
||||
print "Importing $nrRevs revisions for $chan\n";
|
||||
|
||||
for ($i=0; $i<$nrRevs; $i++) {
|
||||
import_rev($revs[$i], $chan);
|
||||
}
|
||||
|
||||
$res = $DB->query("commit");
|
||||
|
||||
$revs = explode("\n", rtrim(`git rev-list HEAD`));
|
||||
|
||||
$res = 0;
|
||||
$c =0;
|
||||
$changesAt = array();
|
||||
|
||||
while (true) {
|
||||
exec("git reset --soft HEAD~ 2>&1", $out, $res);
|
||||
if ($res != 0) {
|
||||
break;
|
||||
} else {
|
||||
$c++;
|
||||
$newRevs = explode("\n", rtrim(`git rev-list HEAD`));
|
||||
$changes = array_diff($revs, $newRevs);
|
||||
$nrChanges = count($changes);
|
||||
$build = count($revs);
|
||||
$revs = $newRevs;
|
||||
$changesAt[$build] = $changes;
|
||||
print $nrChanges . " changes in build $build\n";
|
||||
if ($build < 2169) break; // this is when we started building
|
||||
}
|
||||
}
|
||||
save_build_changes($changesAt, $chan);
|
||||
}
|
||||
|
||||
save_build_changes($changesAt);
|
||||
|
||||
print "Number resets: $c\n";
|
||||
exec("git fetch --all 2>&1");
|
||||
@@ -156,7 +165,8 @@ function update_builds()
|
||||
$DB->query("PRAGMA synchronous = OFF");
|
||||
chdir(SITE_ROOT . "/lib/source");
|
||||
exec("git fetch --all");
|
||||
update_revs();
|
||||
update_revs("SingularityMultiWearable");
|
||||
die();
|
||||
|
||||
chdir(SITE_ROOT);
|
||||
update_builds();
|
||||
|
||||
@@ -55,6 +55,7 @@ if (!defined('IMG_ROOT')) {
|
||||
}
|
||||
|
||||
|
||||
$CHANS = array("SingularityAlpha" => "HEAD", "SingularityMultiWearable" => "refs/remotes/shyotl/V2MultiWear");
|
||||
$DB = new DBH();
|
||||
|
||||
$DB_NAME = SITE_ROOT . '/lib/singularity_revisions.db';
|
||||
|
||||
Reference in New Issue
Block a user