http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70014
Revision: 70014
Author: platonides
Date: 2010-07-27 13:56:57 +0000 (Tue, 27 Jul 2010)
Log Message:
-----------
For each download, there is a slow svn up, which locks the working copy.
Another download at the same time will produce the 'cleanup needed' error.
Replace the svn up with a remote svn info, which is equally slow but
non-locking. Then only svn up if it has really changed.
Modified Paths:
--------------
trunk/extensions/ExtensionDistributor/svn-invoker.php
Modified: trunk/extensions/ExtensionDistributor/svn-invoker.php
===================================================================
--- trunk/extensions/ExtensionDistributor/svn-invoker.php 2010-07-27
13:19:52 UTC (rev 70013)
+++ trunk/extensions/ExtensionDistributor/svn-invoker.php 2010-07-27
13:56:57 UTC (rev 70014)
@@ -71,36 +71,58 @@
}
$version = $command->version;
$extension = $command->extension;
+ $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension";
- // svn up
- $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension";
- $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1";
- $retval = - 1;
- $result = svnShellExec( $cmd, $retval );
- if ( $retval ) {
- svnError( 'extdist-svn-error', $result );
+ // Determine last changed revision in the checkout
+ $localRev = svnGetRev( $dir, &$remoteDir );
+ if ( !$localRev ) {
return;
}
+
+ // Determine last changed revision in the repo
+ $remoteRev = svnGetRev( $remoteDir );
+ if ( !$remoteRev ) {
+ return;
+ }
+
+ if ( $remoteRev != $localRev ) {
+ // Bad luck, we need to svn up
+ $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . "
2>&1";
+ $retval = - 1;
+ $result = svnShellExec( $cmd, $retval );
+ if ( $retval ) {
+ svnError( 'extdist-svn-error', $result );
+ return;
+ }
+ }
+
+ echo json_encode( array( 'revision' => $remoteRev ) );
+}
- // Determine last changed revision
+// Returns the last changed revision or false
+// @param $dir Path or url of the folder
+// Output param $url Remote location of the folder
+function svnGetRev( $dir, &$url = null ) {
+
$cmd = "svn info --non-interactive --xml " . escapeshellarg( $dir );
$retval = - 1;
$result = svnShellExec( $cmd, $retval );
if ( $retval ) {
svnError( 'extdist-svn-error', $result );
- return;
+ return false;
}
try {
$sx = new SimpleXMLElement( $result );
$rev = strval( $sx->entry->commit['revision'] );
+ $url = $sx->entry->url;
} catch ( Exception $e ) {
$rev = false;
}
if ( !$rev || strpos( $rev, '/' ) !== false || strpos( $rev, "\000" )
!== false ) {
svnError( 'extdist-svn-parse-error', $result );
- return;
+ return false;
}
-
- echo json_encode( array( 'revision' => $rev ) );
+
+ return $rev;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs