r80720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80719‎ | r80720 | r80721 >
Date:22:56, 21 January 2011
Author:reedy
Status:ok
Tags:
Comment:
Fixup style and whitespace from r80691
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/svnImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRepository.php
@@ -270,14 +270,14 @@
271271 $rev1 = $rev - 1;
272272 $rev2 = $rev;
273273
274 - // Check that a valid revision was specified.
 274+ // Check that a valid revision was specified.
275275 $revision = $this->getRevision( $rev );
276276 if ( $revision == null ) {
277277 $data = DIFFRESULT_BadRevision;
278 - }
279 - // Check that there is at least one, and at most $wgCodeReviewMaxDiffPaths
280 - // paths changed in this revision.
281 - else {
 278+ } else {
 279+ // Check that there is at least one, and at most $wgCodeReviewMaxDiffPaths
 280+ // paths changed in this revision.
 281+
282282 $paths = $revision->getModifiedPaths();
283283 if ( !$paths->numRows() ) {
284284 $data = DIFFRESULT_NothingToCompare;
@@ -287,26 +287,26 @@
288288 }
289289 }
290290
291 - // If an error has occurred, return it.
 291+ // If an error has occurred, return it.
292292 if ( $data !== null ) {
293293 wfProfileOut( __METHOD__ );
294294 return $data;
295295 }
296296
297 - // Set up the cache key, which will be used both to check if already in the
298 - // cache, and to write the final result to the cache.
 297+ // Set up the cache key, which will be used both to check if already in the
 298+ // cache, and to write the final result to the cache.
299299 $key = wfMemcKey( 'svn', md5( $this->path ), 'diff', $rev1, $rev2 );
300300
301 - // If not set to explicitly skip the cache, get the current diff from memcached
302 - // directly.
 301+ // If not set to explicitly skip the cache, get the current diff from memcached
 302+ // directly.
303303 if ( $useCache === 'skipcache' ) {
304304 $data = null;
305305 } else {
306306 $data = $wgMemc->get( $key );
307307 }
308308
309 - // If the diff hasn't already been retrieved from the cache, see if we can get
310 - // it from the DB.
 309+ // If the diff hasn't already been retrieved from the cache, see if we can get
 310+ // it from the DB.
311311 if ( !$data && $useCache != 'skipcache' ) {
312312 $dbr = wfGetDB( DB_SLAVE );
313313 $row = $dbr->selectRow( 'code_rev',
@@ -317,7 +317,7 @@
318318 if ( $row ) {
319319 $flags = explode( ',', $row->cr_flags );
320320 $data = $row->cr_diff;
321 - // If the text was fetched without an error, convert it
 321+ // If the text was fetched without an error, convert it
322322 if ( $data !== false && in_array( 'gzip', $flags ) ) {
323323 # Deal with optional compression of archived pages.
324324 # This can be done periodically via maintenance/compressOld.php, and
@@ -327,25 +327,24 @@
328328 }
329329 }
330330
331 - // If the data was not already in the cache or in the DB, we need to retrieve
332 - // it from SVN.
 331+ // If the data was not already in the cache or in the DB, we need to retrieve
 332+ // it from SVN.
333333 if ( !$data && $useCache !== 'cached' ) {
334334 $svn = SubversionAdaptor::newFromRepo( $this->path );
335335 $data = $svn->getDiff( '', $rev1, $rev2 );
336336
337 - // If $data is blank, report the error that no data was returned.
338 - // TODO: Currently we can't tell the difference between an SVN/connection
339 - // failure and an empty diff. See if we can remedy this!
 337+ // If $data is blank, report the error that no data was returned.
 338+ // TODO: Currently we can't tell the difference between an SVN/connection
 339+ // failure and an empty diff. See if we can remedy this!
340340 if ($data == "") {
341341 $data = DIFFRESULT_NoDataReturned;
342 - }
343 - // Otherwise, store the resulting diff to both the temporary cache and
344 - // permanent DB storage.
345 - else {
346 - // Store to cache
 342+ } else {
 343+ // Otherwise, store the resulting diff to both the temporary cache and
 344+ // permanent DB storage.
 345+ // Store to cache
347346 $wgMemc->set( $key, $data, 3600 * 24 * 3 );
348347
349 - // Permanent DB storage
 348+ // Permanent DB storage
350349 $storedData = $data;
351350 $flags = Revision::compressRevisionText( $storedData );
352351 $dbw = wfGetDB( DB_MASTER );
Index: trunk/extensions/CodeReview/svnImport.php
@@ -136,14 +136,14 @@
137137 $options['LIMIT'] = $cacheSize;
138138 }
139139
140 - // Get all rows for this repository that don't already have a diff filled in.
141 - // This is LIMITed according to the $cacheSize setting, above, so only the
142 - // rows that we plan to pre-cache are returned.
143 - // TODO: This was optimised in order to skip rows that already have a diff,
144 - // which is mostly what is required, but there may be situations where
145 - // you want to re-calculate diffs (e.g. if $wgCodeReviewMaxDiffPaths
146 - // changes). If these situations arise we will either want to revert
147 - // this behaviour, or add a --force flag or something.
 140+ // Get all rows for this repository that don't already have a diff filled in.
 141+ // This is LIMITed according to the $cacheSize setting, above, so only the
 142+ // rows that we plan to pre-cache are returned.
 143+ // TODO: This was optimised in order to skip rows that already have a diff,
 144+ // which is mostly what is required, but there may be situations where
 145+ // you want to re-calculate diffs (e.g. if $wgCodeReviewMaxDiffPaths
 146+ // changes). If these situations arise we will either want to revert
 147+ // this behaviour, or add a --force flag or something.
148148 $res = $dbw->select( 'code_rev', 'cr_id',
149149 array( 'cr_repo_id' => $repo->getId(), 'cr_diff IS NULL OR cr_diff = ""' ),
150150 __METHOD__,
@@ -153,7 +153,7 @@
154154 $repo->getRevision( $row->cr_id );
155155 $diff = $repo->getDiff( $row->cr_id ); // trigger caching
156156 $msg = "Diff r{$row->cr_id} ";
157 - if (is_integer($diff)) {
 157+ if ( is_integer( $diff ) ) {
158158 $msg .= "Skipped: ";
159159 switch ($diff) {
160160 case DIFFRESULT_BadRevision:
@@ -173,14 +173,12 @@
174174 $msg .= "Unknown reason!";
175175 break;
176176 }
177 - }
178 - else {
 177+ } else {
179178 $msg .= "done";
180179 }
181180 $this->output( $msg . "\n" );
182181 }
183 - }
184 - else {
 182+ } else {
185183 $this->output( "Pre-caching skipped.\n" );
186184 }
187185 $this->output( "Done!\n" );

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

Status & tagging log