r82479 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82478‎ | r82479 | r82480 >
Date:20:07, 19 February 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Move constants to be class constants

Fixes up fixme on r80691
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/svnImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -115,12 +115,8 @@
116116 $wgGroupPermissions['svnadmins']['repoadmin'] = true;
117117
118118 // Constants returned from CodeRepository::getDiff() when no diff can be calculated.
119 -define("DIFFRESULT_BadRevision", 0);
120 -define("DIFFRESULT_NothingToCompare", 1);
121 -define("DIFFRESULT_TooManyPaths", 2);
122 -define("DIFFRESULT_NoDataReturned", 3);
123 -define("DIFFRESULT_NotInCache", 4);
124119
 120+
125121 // If you can't directly access the remote SVN repo, you can set this
126122 // to an offsite proxy running this fun little proxy tool:
127123 // http://svn.wikimedia.org/viewvc/mediawiki/trunk/tools/codereview-proxy/
Index: trunk/extensions/CodeReview/backend/CodeRepository.php
@@ -5,6 +5,12 @@
66 */
77 class CodeRepository {
88
 9+ const DIFFRESULT_BadRevision = 0;
 10+ const DIFFRESULT_NothingToCompare = 1;
 11+ const DIFFRESULT_TooManyPaths = 2;
 12+ const DIFFRESULT_NoDataReturned = 3;
 13+ const DIFFRESULT_NotInCache = 4;
 14+
915 /**
1016 * Local cache of Wiki user -> SVN user mappings
1117 * @var Array
@@ -264,16 +270,16 @@
265271 // Check that a valid revision was specified.
266272 $revision = $this->getRevision( $rev );
267273 if ( $revision == null ) {
268 - $data = DIFFRESULT_BadRevision;
 274+ $data = self::DIFFRESULT_BadRevision;
269275 } else {
270276 // Check that there is at least one, and at most $wgCodeReviewMaxDiffPaths
271277 // paths changed in this revision.
272278
273279 $paths = $revision->getModifiedPaths();
274280 if ( !$paths->numRows() ) {
275 - $data = DIFFRESULT_NothingToCompare;
 281+ $data = self::DIFFRESULT_NothingToCompare;
276282 } elseif ( $wgCodeReviewMaxDiffPaths > 0 && $paths->numRows() > $wgCodeReviewMaxDiffPaths ) {
277 - $data = DIFFRESULT_TooManyPaths;
 283+ $data = self::DIFFRESULT_TooManyPaths;
278284 }
279285 }
280286
@@ -323,7 +329,7 @@
324330 // If the calling code is forcing a cache check, report that it wasn't
325331 // in the cache.
326332 if ( $useCache === 'cached' ) {
327 - $data = DIFFRESULT_NotInCache;
 333+ $data = self::DIFFRESULT_NotInCache;
328334
329335 // Otherwise, retrieve the diff using SubversionAdaptor.
330336 } else {
@@ -334,7 +340,7 @@
335341 // TODO: Currently we can't tell the difference between an SVN/connection
336342 // failure and an empty diff. See if we can remedy this!
337343 if ($data == "") {
338 - $data = DIFFRESULT_NoDataReturned;
 344+ $data = self::DIFFRESULT_NoDataReturned;
339345 } else {
340346 // Otherwise, store the resulting diff to both the temporary cache and
341347 // permanent DB storage.
Index: trunk/extensions/CodeReview/svnImport.php
@@ -156,17 +156,17 @@
157157 if ( is_integer( $diff ) ) {
158158 $msg .= "Skipped: ";
159159 switch ($diff) {
160 - case DIFFRESULT_BadRevision:
 160+ case CodeRepository::DIFFRESULT_BadRevision:
161161 $msg .= "Bad revision";
162162 break;
163 - case DIFFRESULT_NothingToCompare:
 163+ case CodeRepository::DIFFRESULT_NothingToCompare:
164164 $msg .= "Nothing to compare";
165165 break;
166 - case DIFFRESULT_TooManyPaths:
 166+ case CodeRepository::DIFFRESULT_TooManyPaths:
167167 $msg .= "Too many paths (\$wgCodeReviewMaxDiffPaths = "
168168 . $wgCodeReviewMaxDiffPaths . ")";
169169 break;
170 - case DIFFRESULT_NoDataReturned:
 170+ case CodeRepository::DIFFRESULT_NoDataReturned:
171171 $msg .= "No data returned - no diff data, or connection lost.";
172172 break;
173173 default:

Follow-up revisions

RevisionCommit summaryAuthorDate
r114010Removed comment that should have been removed when the global constants it re...happydog11:44, 16 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80691[CodeReview] Modified CodeRepository::getDiff() so it now returns a bit more ...happydog17:16, 21 January 2011

Comments

#Comment by HappyDog (talk | contribs)   12:39, 23 March 2011

Thanks for doing this, Reedy. I wasn't sure how class constants worked and haven't had time to investigate further. It's all fairly obvious, it turns out :-)

Status & tagging log