svn: /web/php-rmtools/trunk/ include/Base.php include/Storage.php include/Svn.php script/snapshot.php
| From: | Pierre Joye | Date: | Tue, 12 Jan 2010 16:57:46 +0000 |
| Subject: | svn: /web/php-rmtools/trunk/ include/Base.php include/Storage.php include/Svn.php script/snapshot.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-6981@lists.php.net to get a copy of this message | ||
pajoye Tue, 12 Jan 2010 16:57:46 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=293457
Log:
- improve snapshot when no dev branch are used
Changed paths:
U web/php-rmtools/trunk/include/Base.php
U web/php-rmtools/trunk/include/Storage.php
U web/php-rmtools/trunk/include/Svn.php
U web/php-rmtools/trunk/script/snapshot.php
Modified: web/php-rmtools/trunk/include/Base.php
===================================================================
--- web/php-rmtools/trunk/include/Base.php 2010-01-12 16:44:28 UTC (rev 293456)
+++ web/php-rmtools/trunk/include/Base.php 2010-01-12 16:57:46 UTC (rev 293457)
@@ -5,6 +5,10 @@
class Base {
protected $db;
+ const STATUS_SNAP_ONLY = 1;
+ const STATUS_CLOSED = 2;
+ const STATUS_RELEASE = 3;
+ const STATUS_DEV = 4;
function __construct() {
$path = DB_PATH . '/rmtools.sqlite';
@@ -92,6 +96,21 @@
}
}
+ function setLastRevisionSnapForRelease($release, $revision) {
+ $release = sqlite_escape_string($release);
+ $revision = (int)$revision;
+
+ if (!$revision) {
+ Throw new \Exception('Invalid revision ' . $revision);
+ }
+
+ $res = sqlite_query($this->db, "UPDATE release SET last_snap_revision=$revision WHERE
name='$release'");
+
+ if (sqlite_changes($this->db) < 1) {
+ Throw new \Exception('Release not found ' . $release);
+ }
+ }
+
function getRelease($release) {
$release = sqlite_escape_string($release);
$sql = "SELECT name, release_branch, dev_branch, status, first_revision, last_revision,
last_update, last_snap_revision FROM release WHERE name='" . $release .
"'";
Modified: web/php-rmtools/trunk/include/Storage.php
===================================================================
--- web/php-rmtools/trunk/include/Storage.php 2010-01-12 16:44:28 UTC (rev 293456)
+++ web/php-rmtools/trunk/include/Storage.php 2010-01-12 16:57:46 UTC (rev 293457)
@@ -53,11 +53,16 @@
function updateRelease() {
$svn = new Svn;
- $svn->update($this->dev_branch);
-
+ $last_revision = $svn->update($this->dev_branch);
+
if ($this->dev_branch == $this->release_branch) {
+ $this->release['last_update'] = date(DATE_RFC822);
+ $this->release['last_revision'] = $last_revision;
+ $this->base->setLatestRevisionForRelease($this->release['name'],
$last_revision);
+ $this->base->setLastUpdateForRelease($this->release['name'],
$this->release['last_update']);
return TRUE;
}
+
$logxml = $svn->fetchLogFromBranch($this->dev_branch, $this->first_revision);
if (!$logxml) {
@@ -90,7 +95,8 @@
}
}
}
- $this->release['last_revision'] = $this->getLatestRevision();
+
+ $this->release['last_revision'] = $last_revision;
$this->base->setLatestRevisionForRelease($this->release['name'],
$this->release['last_revision']);
$this->release['last_update'] = date(DATE_RFC822);
$this->base->setLastUpdateForRelease($this->release['name'],
$this->release['last_update']);
@@ -106,8 +112,7 @@
$filename = SNAPS_PATH . '/php-' . $this->release['name'] .
'-src-' . date("YmdHis") . '.zip';
}
- $latest_revision = $this->getLatestRevision();
- if ($this->release['last_revision'] == $latest_revision && !$force) {
+ if ($this->release['last_revision'] ==
$this->release['last_snap_revision'] && !$force) {
return TRUE;
}
@@ -139,14 +144,13 @@
throw new \Exception('Fail to create archive ' . $snaps_archive_name);
}
- $this->base->setLatestRevisionForRelease($this->release['name'],
$latest_revision);
- $this->release['last_revision'] = $latest_revision;
+ $this->base->setLastRevisionSnapForRelease($this->release['name'],
$this->release['last_revision']);
+ $this->release['last_snap_revision'] = $this->release['last_revision'];
return $filename;
}
function getLatestRevision() {
- ;
$res = sqlite_query($this->db, 'SELECT MAX(revision) as revision FROM revision WHERE
release=' . "'" . $this->release['name'] . "'",
SQLITE_ASSOC);
if ($res && sqlite_num_rows($res) > 0) {
$latest_rev = sqlite_fetch_array($res);
Modified: web/php-rmtools/trunk/include/Svn.php
===================================================================
--- web/php-rmtools/trunk/include/Svn.php 2010-01-12 16:44:28 UTC (rev 293456)
+++ web/php-rmtools/trunk/include/Svn.php 2010-01-12 16:57:46 UTC (rev 293457)
@@ -49,8 +49,10 @@
$process = proc_open($cmd, $descriptorspec, $pipes, $path);
$out = stream_get_contents($pipes[1]);
+ $revision = (int)str_replace('At revision ', '', $out);
fclose($pipes[1]);
proc_close($process);
+ return $revision;
}
function export($branch, $targetdir) {
Modified: web/php-rmtools/trunk/script/snapshot.php
===================================================================
--- web/php-rmtools/trunk/script/snapshot.php 2010-01-12 16:44:28 UTC (rev 293456)
+++ web/php-rmtools/trunk/script/snapshot.php 2010-01-12 16:57:46 UTC (rev 293457)
@@ -11,6 +11,7 @@
echo "Usage: snapshot <release name> <snap absolute path>\n";
exit();
}
+
$release = filter_var($argv[1], FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH);
if ($argc == 3) {