r49995 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49994‎ | r49995 | r49996 >
Date:05:24, 28 April 2009
Author:shinjiman
Status:resolved (Comments)
Tags:
Comment:
* (bug 18593) Unify svn-revision references in Special:Version, in addition with Brion's recommendations. :)
Modified paths:
  • /trunk/phase3/includes/specials/SpecialVersion.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialVersion.php
@@ -114,7 +114,7 @@
115115 public static function getVersion() {
116116 global $wgVersion, $IP;
117117 wfProfileIn( __METHOD__ );
118 - $svn = self::getSvnRevision( $IP, false );
 118+ $svn = self::getSvnRevision( $IP, false , false);
119119 $version = $svn ? $wgVersion . wfMsg( 'version-svn-revision', $svn ) : $wgVersion;
120120 wfProfileOut( __METHOD__ );
121121 return $version;
@@ -129,8 +129,11 @@
130130 public static function getVersionLinked() {
131131 global $wgVersion, $IP;
132132 wfProfileIn( __METHOD__ );
133 - $svn = self::getSvnRevision( $IP, false );
134 - $viewvc = 'http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/?pathrev=';
 133+ $svn = self::getSvnRevision( $IP, false, false );
 134+ $svnDir = self::getSvnRevision( $IP, false, true );
 135+ $viewvcStart = 'http://svn.wikimedia.org/viewvc/mediawiki/';
 136+ $viewvcEnd = '/?pathrev=';
 137+ $viewvc = $viewvcStart . $svnDir . $viewvcEnd;
135138 $version = $svn ? $wgVersion . " [{$viewvc}{$svn} " . wfMsg( 'version-svn-revision', $svn ) . ']' : $wgVersion;
136139 wfProfileOut( __METHOD__ );
137140 return $version;
@@ -164,8 +167,13 @@
165168 foreach ( $wgExtensionCredits[$type] as $extension ) {
166169 $version = null;
167170 $subVersion = null;
168 - if (isset($extension['path']))
169 - $subVersion = self::getSvnRevision(dirname($extension['path']), true);
 171+ $viewvc = null;
 172+ if ( isset( $extension['path'] ) ) {
 173+ $subVersion = self::getSvnRevision(dirname($extension['path']), true, false);
 174+ $subVersionDir = self::getSvnRevision(dirname($extension['path']), true, true);
 175+ if ($subVersionDir)
 176+ $viewvc = $subVersionDir . $subVersion;
 177+ }
170178 if ( isset( $extension['version'] ) ) {
171179 $version = $extension['version'];
172180 }
@@ -174,6 +182,7 @@
175183 isset ( $extension['name'] ) ? $extension['name'] : '',
176184 $version,
177185 $subVersion,
 186+ $viewvc,
178187 isset ( $extension['author'] ) ? $extension['author'] : '',
179188 isset ( $extension['url'] ) ? $extension['url'] : null,
180189 isset ( $extension['description'] ) ? $extension['description'] : '',
@@ -220,10 +229,11 @@
221230 }
222231 }
223232
224 - function formatCredits( $name, $version = null, $subVersion = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) {
 233+ function formatCredits( $name, $version = null, $subVersion = null, $subVersionURL = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) {
225234 $extension = isset( $url ) ? "[$url $name]" : $name;
226235 $version = isset( $version ) ? wfMsg( 'version-version', $version ) : '';
227236 $subVersion = isset( $subVersion ) ? wfMsg( 'version-svn-revision', $subVersion ) : '';
 237+ $subVersion = isset( $subVersionURL ) ? "[$subVersionURL $subVersion]" : $subVersion;
228238
229239 # Look for a localized description
230240 if( isset( $descriptionMsg ) ) {
@@ -341,7 +351,7 @@
342352 * @param string $dir
343353 * @return mixed revision number as int, or false if not a SVN checkout
344354 */
345 - public static function getSvnRevision( $dir , $extension = false) {
 355+ public static function getSvnRevision( $dir , $extension = false, $relPath = false) {
346356 // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
347357 $entries = $dir . '/.svn/entries';
348358
@@ -377,6 +387,31 @@
378388 return false;
379389 } else {
380390 // subversion is release 1.4 or above
 391+ if ($relPath) {
 392+ $endPath = strstr( $content[4], 'tags' );
 393+ if (!$endPath) {
 394+ $endPath = strstr( $content[4], 'branches' );
 395+ if (!$endPath) {
 396+ $endPath = strstr( $content[4], 'trunk' );
 397+ if (!$endPath)
 398+ return false;
 399+ }
 400+ }
 401+ $endPath = trim ( $endPath );
 402+ if ($extension) {
 403+ $wmSvnPath = 'svn.wikimedia.org/svnroot/mediawiki';
 404+ $isWMSvn = strstr($content[5],$wmSvnPath);
 405+ if (!strcmp($isWMSvn,null)) {
 406+ return false;
 407+ } else {
 408+ $viewvcStart = 'http://svn.wikimedia.org/viewvc/mediawiki/';
 409+ $viewvcEnd = '/?pathrev=';
 410+ $viewvc = $viewvcStart . $endPath . $viewvcEnd;
 411+ return $viewvc;
 412+ }
 413+ }
 414+ return $endPath;
 415+ }
381416 if ($extension)
382417 // get the last file revsion number
383418 return intval( $content[10]) ;

Follow-up revisions

RevisionCommit summaryAuthorDate
r55130Fixes for Shinjiman's Special:Version updates r49995-r50121:...tstarling08:31, 16 August 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49948* (bug 18593) Unify svn-revision references in Special:Versionshinjiman13:00, 27 April 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   17:54, 28 April 2009

This seems to be just discarding revision info for an extension checked out of a branch. Something ain't right...

#Comment by Brion VIBBER (talk | contribs)   18:01, 28 April 2009

Ehhh, seems to work but it's got a lot of funky hardcoding, and looks like it would get confused by something from a third-party SVN. Instead of manually looking for 'tags', 'branches', and 'trunk', just chopping off the known svn.wikimedia.org/svnroot path prefix should do fine.

Branch checkout info didn't work because existing branches don't have the path specified in their about info, which kinda sucks but eh.

#Comment by Tim Starling (talk | contribs)   08:32, 16 August 2009

Should be fixed as of r55130.

Status & tagging log