Added: web/php-rmtools/trunk/docroot/css/table.css =================================================================== --- web/php-rmtools/trunk/docroot/css/table.css (rev 0) +++ web/php-rmtools/trunk/docroot/css/table.css 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,78 @@ +body { +-x-system-font:none; +background-color:White; +color:Black; +font-family:"Lucida Grande",Verdana,Lucida,Helvetica,Arial,sans-serif; +font-size:10pt; +font-size-adjust:none; +font-stretch:normal; +font-style:normal; +font-variant:normal; +font-weight:normal; +line-height:normal; +} + +table { +font-size:100%; +margin:4; +padding:0; +} +tr, td, th { +margin:0; +padding:0; +} + + +table.listing { +background-color:#FFFFFF; +border-collapse:collapse; +border-spacing:0; +font-size:80%; +} + +table.listing th { +border-color:#000000; +border-style:solid; +border-width:1px 1px 2px; +padding:3px; +} + +table.listing td { +border:1px solid #000000; +padding:3px; +} + +label{ +float: left; +width: 120px; +font-weight: bold; +} + +input, textarea{ +width: 180px; +margin-bottom: 5px; +} + +textarea{ +width: 450px; +height: 150px; +} + +textarea.news{ +width: 450px; +height: 50px; +} + +.boxes{ +width: 1em; +} + +#submitbutton{ +margin-left: 120px; +margin-top: 5px; +width: 90px; +} + +br{ +clear: left; +} \ No newline at end of file Added: web/php-rmtools/trunk/docroot/images/hover.gif =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/hover.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/images/merged.png =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/merged.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/images/merged_small.png =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/merged_small.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/images/rejected.png =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/rejected.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/images/rejected_small.png =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/rejected_small.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/images/seperator.gif =================================================================== (Binary files differ) Property changes on: web/php-rmtools/trunk/docroot/images/seperator.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: web/php-rmtools/trunk/docroot/rm/index.php =================================================================== --- web/php-rmtools/trunk/docroot/rm/index.php (rev 0) +++ web/php-rmtools/trunk/docroot/rm/index.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,84 @@ +getAll(); + } else { + $extra_head = TPL_PATH . '/revision_list_yui_extra_head.php'; + $tpl = TPL_PATH . '/revision_list_yui.php'; + } + break; + + case 'edit': + $json = filter_input(INPUT_GET, 'json', FILTER_VALIDATE_INT); + if ($json) { + $rev = filter_input(INPUT_POST, 'revision', FILTER_VALIDATE_INT); + } else { + $rev = filter_input(INPUT_GET, 'rev', FILTER_VALIDATE_INT); + } + if ($rev) { + $revision = $svn->getOne($rev); + } + if (!$revision) { + if ($json) { + //header('HTTP/1.0 404 Not Found'); + } + $error = "$revision cannot be found."; + $tpl = __DIR__ . '/../template/error.php'; + } else { + if (!empty($_POST)) { + $revision['comment'] = filter_input(INPUT_POST, 'comment', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); + $revision['news'] = filter_input(INPUT_POST, 'news', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); + $revision['status'] = filter_input(INPUT_POST, 'status', FILTER_VALIDATE_INT, array('min_range'=>0. , 'max_range'=>2)); + + if (!$svn->updateRevision($revision)) { + if ($json) { + header('HTTP/1.0 500 Internal Server Error'); + } + $error = "Failed to update revision: $revision"; + $tpl = __DIR__ . '/../template/error.php'; + break; + } + if ($json) { + echo json_encode($revision); + exit(); + } else { + header('Location: index.php'); + exit(); + } + break; + } + + $tpl = __DIR__ . '/../template/edit_revision.php'; + } + break; + + case 'menu': + default: + $base = new rm\Base; + $releases = $base->getReleaseForRM($username); + $tpl = TPL_PATH . '/menu.php'; +} +include TPL_PATH . '/header.php'; +include $tpl; +include TPL_PATH . '/footer.php'; Added: web/php-rmtools/trunk/docroot/rm/json.php =================================================================== --- web/php-rmtools/trunk/docroot/rm/json.php (rev 0) +++ web/php-rmtools/trunk/docroot/rm/json.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,16 @@ +exportAsJson(); + +//$json = '{"replyCode":201, "replyText":"Data follows","data": ' . $json . '}'; +//var_dump(json_decode($json)); +echo $json; Added: web/php-rmtools/trunk/docroot/rm/login.php =================================================================== --- web/php-rmtools/trunk/docroot/rm/login.php (rev 0) +++ web/php-rmtools/trunk/docroot/rm/login.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,44 @@ + MASTER_AUTH_TOKEN, + "username" => $user, + "password" => $pass, + ), '', '&' + ); + + $opts = array( + "method" => "POST", + "header" => "Content-type: application/x-www-form-urlencoded", + "content" => $post, + ); + + $ctx = stream_context_create(array("http" => $opts)); + $s = file_get_contents("http://master.php.net/fetch/cvsauth.php", false, $ctx); + $a = unserialize($s); + + /* + define("E_UNKNOWN", 0); + define("E_USERNAME", 1); + define("E_PASSWORD", 2); + */ + if (!is_array($a)) { + return 0; + } + if (isset($a["errno"])) { + return (int)$a["errno"]; + } + + return true; + } + +} \ No newline at end of file Added: web/php-rmtools/trunk/include/Base.php =================================================================== --- web/php-rmtools/trunk/include/Base.php (rev 0) +++ web/php-rmtools/trunk/include/Base.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,91 @@ +db = sqlite_open($path); + if (!$this->db) { + throw new \Exception('Cannot open storage ' . $path); + } + + if (!static::isInitialized()) { + static::createStorage(); + } + } + + function isInitialized() { + $res = sqlite_query($this->db, "SELECT name FROM sqlite_master WHERE type='table' AND name='release'"); + return (sqlite_num_rows($res) > 0); + } + + function createStorage() { + if (!sqlite_query($this->db, 'CREATE TABLE release (name VARCHAR(32), release_branch VARCHAR(32), dev_branch VARCHAR(32), status INTEGER, first_revision INTEGER)')) { + throw new \Exception('Cannot initialize TABLE release'); + } + if (!sqlite_query($this->db, 'CREATE TABLE rm (name VARCHAR(32), release_name VARCHAR(32))')) { + throw new \Exception('Cannot initialize TABLE release'); + } + } + + function createNewRelease($release, $release_branch, $dev_branch, $first_revision) { + // TODO: valid release format + $res = sqlite_query($this->db, "SELECT name FROM release WHERE name='" . sqlite_escape_string($release) . "'"); + if (!$res || sqlite_num_rows($res) > 0) { + Throw new \Exception($release . ' already exists'); + } + + $res = sqlite_query($this->db, "INSERT INTO release (name, release_branch, dev_branch, first_revision) VALUES('" . + sqlite_escape_string($release) . "','" . sqlite_escape_string($release_branch) . "','" . sqlite_escape_string($dev_branch) . "'," . + (int)$first_revision . ")"); + if (!$res) { + Throw new \Exception('Cannot create release'); + } + } + + function addRmToRelease($release, $rm){ + $release = sqlite_escape_string($release); + $rm = sqlite_escape_string($rm); + $res = sqlite_query($this->db, "SELECT name FROM rm WHERE name='$rm' AND release_name='$release'"); + if (sqlite_num_rows($res) > 0) { + Throw new \Exception($release . 'already exists'); + } + + $res = sqlite_query($this->db, "INSERT INTO rm (name, release_name) VALUES('$rm','$release')"); + if (!$res) { + Throw new \Exception('Cannot create release'); + } + } + + function getRelease($release) { + $release = sqlite_escape_string($release); + $sql = "SELECT name, release_branch, dev_branch, status, first_revision FROM release WHERE name='" . $release . "'"; + $res = sqlite_query($this->db, $sql, SQLITE_ASSOC); + if (!$res) { + Throw new \Exception('Query failed for ' . $release); + } + + if (sqlite_num_rows($res) == 0) { + Throw new \Exception($release . ' not found.'); + } + return sqlite_fetch_array($res); + } + + + function getReleaseForRM($rm) { + $sql = "SELECT release_name FROM rm WHERE name='" . sqlite_escape_string($rm) . "'"; + $res = sqlite_query($this->db, $sql); + if (!$res) { + Throw new \Exception('Query failed for ' . $release); + } + + if (sqlite_num_rows($res) == 0) { + Throw new \Exception($rm . ' not found.'); + } + return sqlite_fetch_array($res, SQLITE_ASSOC); + } +} \ No newline at end of file Added: web/php-rmtools/trunk/include/Storage.php =================================================================== --- web/php-rmtools/trunk/include/Storage.php (rev 0) +++ web/php-rmtools/trunk/include/Storage.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,112 @@ +getRelease($release); + $this->dev_branch = $release['dev_branch']; + $this->release_branch = $release['release_branch']; + $this->first_revision = $release['first_revision']; + + $path = DB_PATH . '/' . $this->release_branch . '.sqlite'; + $this->db = sqlite_open($path); + + if (!$this->db) { + throw new \Exception('Cannot open storage ' . $path); + } + + if (!static::isInitialized()) { + static::createStorage(); + } + } + + function isInitialized() { + $res = sqlite_query($this->db, "SELECT name FROM sqlite_master WHERE type='table' AND name='revision'"); + return (sqlite_num_rows($res) > 0); + } + + function createStorage() { + if (!sqlite_query($this->db, 'CREATE TABLE revision (revision VARCHAR(32), date VARCHAR(32), author VARCHAR(80), msg VARCHAR(255), status integer, comment TEXT, news TEXT)')) { + throw new \Exception('Cannot initialize storage ' . $path); + } + } + + function updateRelease() { + + $svn = new Svn; + + $logxml = $svn->fetchLogFromBranch($this->dev_branch, $this->first_revision); + if (!$logxml) { + Throw new \Exception('SVN log failed ' ); + } + + foreach ($logxml->logentry as $v) { + $msg = (string) $v->msg; + $msg = substr(substr($msg, 0, strpos($msg . "\n", "\n")), 0, 80); + $rev = (string) $v['revision']; + $author = (string) $v->author; + $date = (string) $v->date; + + $res = sqlite_query($this->db, "SELECT status FROM revision WHERE revision='" . $rev . "'"); + + if ($res && sqlite_num_rows($res) > 0) { + $row = sqlite_fetch_array($res); + if ($row && empty($row['author'])) { + $res = sqlite_query($this->db, "UPDATE revision SET author='" . sqlite_escape_string($author). "' WHERE revision='" . sqlite_escape_string($rev) . "'"); + if (!$res) { + Throw new \Exception('Update query failed for ' . $rev); + } + } + } else { + $res = sqlite_query($this->db, "INSERT INTO revision (revision, date, author, status, msg, comment, news) VALUES('$rev' ,'" . $date . "','" . $author . "', 0, '" . sqlite_escape_string($msg) . "', '', '');"); + if (!$res) { + Throw new \Exception('Insert query failed for ' . $rev); + } + } + } + } + + function getAll() { + $res = sqlite_query($this->db, 'SELECT * FROM revision ORDER by revision', SQLITE_ASSOC); + if ($res && sqlite_num_rows($res) > 0) { + return sqlite_fetch_all($res); + } + return NULL; + } + + function getOne($revision) { + $res = sqlite_query($this->db, 'SELECT * FROM revision WHERE revision=' . (integer) $revision, SQLITE_ASSOC); + if ($res && sqlite_num_rows($res) > 0) { + return sqlite_fetch_array($res); + } + return NULL; + } + + function updateRevision($revision) { + $sql = "UPDATE revision + set status=" . $revision['status'] . ", comment='" . sqlite_escape_string($revision['comment']) . "', news='" . sqlite_escape_string($revision['news']) . "' WHERE revision=" . (integer)$revision['revision']; + $res = sqlite_query($this->db, $sql); + if ($res) { + return TRUE; + } + return FALSE; + } + + function exportAsJson() { + $log = $this->getAll(); + if ($log) { + $json = new \StdClass; + $json->totalRecords = count($log); + $json->data = $log; + return json_encode($json); + } + } +} Added: web/php-rmtools/trunk/include/Svn.php =================================================================== --- web/php-rmtools/trunk/include/Svn.php (rev 0) +++ web/php-rmtools/trunk/include/Svn.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,47 @@ + array("pipe", "w"), // stdout is a pipe that the child will write to + 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to + ); + + $cwd = '/tmp'; + $env = array('some_option' => 'aeiou'); + $cmd = "svn log -r $first_revision:HEAD --xml"; + + + $path = SVN_REPO_PATH . '/php-src/branches/' . $branch; + + $process = proc_open($cmd, $descriptorspec, $pipes, $path, $env); + $log_xml = stream_get_contents($pipes[1]); + fclose($pipes[1]); + proc_close($process); + + $sx = new \SimpleXMLElement($log_xml); + if (!$sx) { + throw new \Exception('svn log failed ' . $path); + } + return $sx; + } + + /* TODO: do some sanity check if the branch is actually co'ed */ + static function isValidBranch($branch) { + $path = SVN_REPO_PATH . '/php-src/branches/' . $branch; + if (is_dir($path)) { + return TRUE; + } else { + return FALSE; + } + } +} Added: web/php-rmtools/trunk/include/config.php =================================================================== --- web/php-rmtools/trunk/include/config.php (rev 0) +++ web/php-rmtools/trunk/include/config.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,6 @@ + +\tname of the new release (5.3.3) +\tname of the new release branch (PHP_5_3_3) +\tname of the new branch name (PHP_5_3) +\tLast revision commited before the branch was created (PHP_5_3) +"; + exit(); +} + +$release_name = filter_var($argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); +$release_branch_name = filter_var($argv[2], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); +$dev_branch_name = filter_var($argv[3], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); +$revision = filter_var($argv[4], FILTER_VALIDATE_INT); + +if (!rm\Svn::isValidBranch($release_branch_name)) { + echo "$release_branch_name does not exist or is not valid.\n"; + exit(); +} + +if (!rm\Svn::isValidBranch($dev_branch_name)) { + echo "$dev_branch_name does not exist or is not valid.\n"; + exit(); +} + +try { + $svn = new rm\Base(); + $svn->createNewRelease($release_name, $release_branch_name, $dev_branch_name, $revision); + + // Rest of the arguments are RM handles + if ($argv == 4) { + exit(); + } + + for ($i = 4; $i < $argc; $i++) { + $handle = filter_var($argv[$i], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); + $svn->addRmToRelease($release_name, $handle); + } + +} catch (Exception $e) { + echo 'An error occured: ', $e->getMessage(), "\n"; +} Added: web/php-rmtools/trunk/script/updaterelease.php =================================================================== --- web/php-rmtools/trunk/script/updaterelease.php (rev 0) +++ web/php-rmtools/trunk/script/updaterelease.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,22 @@ +\n"; + exit(); +} + +$release = filter_var($argv[1], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH); +try { + $svn = new rm\Storage($release); + $logxml = $svn->updateRelease(); +} catch (Exception $e) { + echo 'An error occured: ', $e->getMessage(), "\n"; +} Added: web/php-rmtools/trunk/template/edit_revision.php =================================================================== --- web/php-rmtools/trunk/template/edit_revision.php (rev 0) +++ web/php-rmtools/trunk/template/edit_revision.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,14 @@ +Back to listing: +
+  
+  
+  
+  > Merged + >Rejected
+ +
+ +
+
+
+Back to listing: \ No newline at end of file Added: web/php-rmtools/trunk/template/error.php =================================================================== --- web/php-rmtools/trunk/template/error.php (rev 0) +++ web/php-rmtools/trunk/template/error.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,3 @@ +

Error

+
+Back to listing: \ No newline at end of file Added: web/php-rmtools/trunk/template/footer.php =================================================================== --- web/php-rmtools/trunk/template/footer.php (rev 0) +++ web/php-rmtools/trunk/template/footer.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,2 @@ + + \ No newline at end of file Added: web/php-rmtools/trunk/template/header.php =================================================================== --- web/php-rmtools/trunk/template/header.php (rev 0) +++ web/php-rmtools/trunk/template/header.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,61 @@ + + +Release Management Tools (<?php echo $title; ?>) + + + + + + + + +
+ +
+ Added: web/php-rmtools/trunk/template/login.php =================================================================== --- web/php-rmtools/trunk/template/login.php (rev 0) +++ web/php-rmtools/trunk/template/login.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,10 @@ +Back to main page + +
+ +
+ +
+
+
+Back to main page Added: web/php-rmtools/trunk/template/menu.php =================================================================== --- web/php-rmtools/trunk/template/menu.php (rev 0) +++ web/php-rmtools/trunk/template/menu.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,9 @@ + +


+ +

Release

+
    +
  • Merges
  • +
  • Merges (no js)
  • +
  • Builds
  • + \ No newline at end of file Added: web/php-rmtools/trunk/template/revision_list.php =================================================================== --- web/php-rmtools/trunk/template/revision_list.php (rev 0) +++ web/php-rmtools/trunk/template/revision_list.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,11 @@ + +

    PHP Merges

    + + + + + + + + +
    RevisionAuthorMsgStatusCommentNews 
    edit
    Added: web/php-rmtools/trunk/template/revision_list_yui.php =================================================================== --- web/php-rmtools/trunk/template/revision_list_yui.php (rev 0) +++ web/php-rmtools/trunk/template/revision_list_yui.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,103 @@ +
    +
    +

    PHP Merges

    +
    + +
    +
    +
    + +
    + +
    + Debug area for server responses +
    + +
    +
    + Please enter your information +
    + +
    +
    +
    + + + +
    Merged Rejected Open + +
    +
    +
    +
    +
    + + Added: web/php-rmtools/trunk/template/revision_list_yui_extra_head.php =================================================================== --- web/php-rmtools/trunk/template/revision_list_yui_extra_head.php (rev 0) +++ web/php-rmtools/trunk/template/revision_list_yui_extra_head.php 2010-01-09 01:48:05 UTC (rev 293305) @@ -0,0 +1,186 @@ + + + + + + + + + + + + +