From 796711e0c4c4df8973960425ae5fbe669aab6237 Mon Sep 17 00:00:00 2001 From: Max Semenik Date: Fri, 29 Jan 2016 17:02:36 -0800 Subject: [PATCH] Kill vestiges of SVN times Change-Id: Ib80c71ea93479eb326ac5afea295d4608f92babe --- includes/api/ApiQuerySiteinfo.php | 17 --- includes/logging/LogFormatter.php | 4 +- includes/specials/SpecialVersion.php | 175 ++------------------------- languages/i18n/en.json | 1 - languages/i18n/qqq.json | 1 - 5 files changed, 9 insertions(+), 189 deletions(-) diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ca9ceca59e..196c1faf8a 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -184,11 +184,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['git-hash'] = $git; $data['git-branch'] = SpecialVersion::getGitCurrentBranch( $GLOBALS['IP'] ); - } else { - $svn = SpecialVersion::getSvnRevision( $IP ); - if ( $svn ) { - $data['rev'] = $svn; - } } // 'case-insensitive' option is reserved for future @@ -602,11 +597,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { } if ( isset( $ext['version'] ) ) { $ret['version'] = $ext['version']; - } elseif ( isset( $ext['svn-revision'] ) && - preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/', - $ext['svn-revision'], $m ) - ) { - $ret['version'] = 'r' . $m[1]; } if ( isset( $ext['path'] ) ) { $extensionPath = dirname( $ext['path'] ); @@ -620,13 +610,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( $vcsDate !== false ) { $ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $vcsDate ); } - } else { - $svnInfo = SpecialVersion::getSvnInfo( $extensionPath ); - if ( $svnInfo !== false ) { - $ret['vcs-system'] = 'svn'; - $ret['vcs-version'] = $svnInfo['checkout-rev']; - $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : ''; - } } if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) { diff --git a/includes/logging/LogFormatter.php b/includes/logging/LogFormatter.php index e2d9946b83..bb3d490b9b 100644 --- a/includes/logging/LogFormatter.php +++ b/includes/logging/LogFormatter.php @@ -237,7 +237,7 @@ class LogFormatter { // @codingStandardsIgnoreStart Long line //case 'revision': // Revision deletion //case 'event': // Log deletion - // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044 + // see https://github.com/wikimedia/mediawiki/commit/a9c243b7b5289dad204278dbe7ed571fd914e395 //default: // @codingStandardsIgnoreEnd } @@ -245,7 +245,7 @@ class LogFormatter { case 'patrol': // @codingStandardsIgnoreStart Long line - // https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PatrolLog.php?&pathrev=97495&r1=97494&r2=97495 + // https://github.com/wikimedia/mediawiki/commit/1a05f8faf78675dc85984f27f355b8825b43efff // @codingStandardsIgnoreEnd // Create a diff link to the patrolled revision if ( $entry->getSubtype() === 'patrol' ) { diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 43228fab79..a628902e41 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -38,12 +38,6 @@ class SpecialVersion extends SpecialPage { protected static $extensionTypes = false; - protected static $viewvcUrls = array( - 'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki', - 'http://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki', - 'https://svn.wikimedia.org/svnroot/mediawiki' => 'https://svn.wikimedia.org/viewvc/mediawiki', - ); - public function __construct() { parent::__construct( 'Version' ); } @@ -258,7 +252,7 @@ class SpecialVersion extends SpecialPage { } /** - * Return a string of the MediaWiki version with SVN revision if available. + * Return a string of the MediaWiki version with Git revision if available. * * @param string $flags * @return mixed @@ -267,25 +261,15 @@ class SpecialVersion extends SpecialPage { global $wgVersion, $IP; $gitInfo = self::getGitHeadSha1( $IP ); - $svnInfo = self::getSvnInfo( $IP ); - if ( !$svnInfo && !$gitInfo ) { + if ( !$gitInfo ) { $version = $wgVersion; - } elseif ( $gitInfo && $flags === 'nodb' ) { + } elseif ( $flags === 'nodb' ) { $shortSha1 = substr( $gitInfo, 0, 7 ); $version = "$wgVersion ($shortSha1)"; - } elseif ( $gitInfo ) { + } else { $shortSha1 = substr( $gitInfo, 0, 7 ); $shortSha1 = wfMessage( 'parentheses' )->params( $shortSha1 )->escaped(); $version = "$wgVersion $shortSha1"; - } elseif ( $flags === 'nodb' ) { - $version = "$wgVersion (r{$svnInfo['checkout-rev']})"; - } else { - $version = $wgVersion . ' ' . - wfMessage( - 'version-svn-revision', - isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : '', - isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : '' - )->text(); } return $version; @@ -293,8 +277,7 @@ class SpecialVersion extends SpecialPage { /** * Return a wikitext-formatted string of the MediaWiki version with a link to - * the SVN revision or the git SHA1 of head if available. - * Git is prefered over Svn + * the Git SHA1 of head if available. * The fallback is just $wgVersion * * @return mixed @@ -306,43 +289,12 @@ class SpecialVersion extends SpecialPage { if ( $gitVersion ) { $v = $gitVersion; } else { - $svnVersion = self::getVersionLinkedSvn(); - if ( $svnVersion ) { - $v = $svnVersion; - } else { - $v = $wgVersion; // fallback - } + $v = $wgVersion; // fallback } return $v; } - /** - * @return string Global wgVersion + a link to subversion revision of svn BASE - */ - private static function getVersionLinkedSvn() { - global $IP; - - $info = self::getSvnInfo( $IP ); - if ( !isset( $info['checkout-rev'] ) ) { - return false; - } - - $linkText = wfMessage( - 'version-svn-revision', - isset( $info['directory-rev'] ) ? $info['directory-rev'] : '', - $info['checkout-rev'] - )->text(); - - if ( isset( $info['viewvc-url'] ) ) { - $version = "[{$info['viewvc-url']} $linkText]"; - } else { - $version = $linkText; - } - - return self::getwgVersionLinked() . " $version"; - } - /** * @return string */ @@ -744,7 +696,7 @@ class SpecialVersion extends SpecialPage { } // ... and the version information - // If the extension path is set we will check that directory for GIT and SVN + // If the extension path is set we will check that directory for GIT // metadata in an attempt to extract date and vcs commit metadata. $canonicalVersion = '–'; $extensionPath = null; @@ -764,11 +716,6 @@ class SpecialVersion extends SpecialPage { $coreHeadSHA1 = self::getGitHeadSha1( $IP ); if ( $coreHeadSHA1 ) { $this->coreId = $coreHeadSHA1; - } else { - $svnInfo = self::getSvnInfo( $IP ); - if ( $svnInfo !== false ) { - $this->coreId = $svnInfo['checkout-rev']; - } } } $cache = wfGetCache( CACHE_ANYTHING ); @@ -783,12 +730,6 @@ class SpecialVersion extends SpecialPage { $vcsVersion = substr( $vcsVersion, 0, 7 ); $vcsLink = $gitInfo->getHeadViewUrl(); $vcsDate = $gitInfo->getHeadCommitDate(); - } else { - $svnInfo = self::getSvnInfo( $extensionPath ); - if ( $svnInfo !== false ) { - $vcsVersion = $this->msg( 'version-svn-revision', $svnInfo['checkout-rev'] )->text(); - $vcsLink = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : ''; - } } $cache->set( $memcKey, array( $vcsVersion, $vcsLink, $vcsDate ), 60 * 60 * 24 ); } else { @@ -1154,108 +1095,6 @@ class SpecialVersion extends SpecialPage { } } - /** - * Get an associative array of information about a given path, from its .svn - * subdirectory. Returns false on error, such as if the directory was not - * checked out with subversion. - * - * Returned keys are: - * Required: - * checkout-rev The revision which was checked out - * Optional: - * directory-rev The revision when the directory was last modified - * url The subversion URL of the directory - * repo-url The base URL of the repository - * viewvc-url A ViewVC URL pointing to the checked-out revision - * @param string $dir - * @return array|bool - */ - public static function getSvnInfo( $dir ) { - // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html - $entries = $dir . '/.svn/entries'; - - if ( !file_exists( $entries ) ) { - return false; - } - - $lines = file( $entries ); - if ( !count( $lines ) ) { - return false; - } - - // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4) - if ( preg_match( '/^<\?xml/', $lines[0] ) ) { - // subversion is release <= 1.3 - if ( !function_exists( 'simplexml_load_file' ) ) { - // We could fall back to expat... YUCK - return false; - } - - // SimpleXml whines about the xmlns... - MediaWiki\suppressWarnings(); - $xml = simplexml_load_file( $entries ); - MediaWiki\restoreWarnings(); - - if ( $xml ) { - foreach ( $xml->entry as $entry ) { - if ( $xml->entry[0]['name'] == '' ) { - // The directory entry should always have a revision marker. - if ( $entry['revision'] ) { - return array( 'checkout-rev' => intval( $entry['revision'] ) ); - } - } - } - } - - return false; - } - - // Subversion is release 1.4 or above. - if ( count( $lines ) < 11 ) { - return false; - } - - $info = array( - 'checkout-rev' => intval( trim( $lines[3] ) ), - 'url' => trim( $lines[4] ), - 'repo-url' => trim( $lines[5] ), - 'directory-rev' => intval( trim( $lines[10] ) ) - ); - - if ( isset( self::$viewvcUrls[$info['repo-url']] ) ) { - $viewvc = str_replace( - $info['repo-url'], - self::$viewvcUrls[$info['repo-url']], - $info['url'] - ); - - $viewvc .= '/?pathrev='; - $viewvc .= urlencode( $info['checkout-rev'] ); - $info['viewvc-url'] = $viewvc; - } - - return $info; - } - - /** - * Retrieve the revision number of a Subversion working directory. - * - * @param string $dir Directory of the svn checkout - * - * @return int Revision number - */ - public static function getSvnRevision( $dir ) { - $info = self::getSvnInfo( $dir ); - - if ( $info === false ) { - return false; - } elseif ( isset( $info['checkout-rev'] ) ) { - return $info['checkout-rev']; - } else { - return false; - } - } - /** * @param string $dir Directory of the git checkout * @return bool|string Sha1 of commit HEAD points to diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 639af0f454..bf906d5a1e 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3498,7 +3498,6 @@ "version-hook-subscribedby": "Subscribed by", "version-version": "($1)", "version-no-ext-name": "[no name]", - "version-svn-revision": "r$1", "version-license": "MediaWiki License", "version-ext-license": "License", "version-ext-colheader-name": "Extension", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 61aaeaa6d3..d66e43e4e3 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3673,7 +3673,6 @@ "version-hook-subscribedby": "Shown in [[Special:Version]]", "version-version": "{{Optional}}\nUsed in [[Special:Version]]. Preceded by the MediaWiki extension name.\n\nParameters:\n* $1 - version number of the extension", "version-no-ext-name": "Used in [[Special:Version]], in the rows of the main table when a name for an extension is not provided.", - "version-svn-revision": "{{Identical|Revision}}{{optional}}\nUsed in [[Special:Version]], preceeding the Subversion revision numbers of the extensions loaded inside brackets, like this: \"({{int:version-revision}} r012345\"). Parameters:\n* $1 - (Unused) directory revision number or empty string\n* $2 - checkout revision number", "version-license": "Used specifically for the MediaWiki software.\n\nUsed as heading in [[Special:Version]].", "version-ext-license": "Used in [[Special:Version]].\n\nUsed as label for the link pointing to the extension's license page. e.g. [[Special:Version/License/Maps]]\n{{Identical|License}}", "version-ext-colheader-name": "Column header for the name of an extension.\n{{Identical|Extension}}", -- 2.20.1