Index: trunk/extensions/CodeReview/backend/CodeRepository.php |
— | — | @@ -270,14 +270,14 @@ |
271 | 271 | $rev1 = $rev - 1; |
272 | 272 | $rev2 = $rev; |
273 | 273 | |
274 | | - // Check that a valid revision was specified. |
| 274 | + // Check that a valid revision was specified. |
275 | 275 | $revision = $this->getRevision( $rev ); |
276 | 276 | if ( $revision == null ) { |
277 | 277 | $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 | + |
282 | 282 | $paths = $revision->getModifiedPaths(); |
283 | 283 | if ( !$paths->numRows() ) { |
284 | 284 | $data = DIFFRESULT_NothingToCompare; |
— | — | @@ -287,26 +287,26 @@ |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | | - // If an error has occurred, return it. |
| 291 | + // If an error has occurred, return it. |
292 | 292 | if ( $data !== null ) { |
293 | 293 | wfProfileOut( __METHOD__ ); |
294 | 294 | return $data; |
295 | 295 | } |
296 | 296 | |
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. |
299 | 299 | $key = wfMemcKey( 'svn', md5( $this->path ), 'diff', $rev1, $rev2 ); |
300 | 300 | |
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. |
303 | 303 | if ( $useCache === 'skipcache' ) { |
304 | 304 | $data = null; |
305 | 305 | } else { |
306 | 306 | $data = $wgMemc->get( $key ); |
307 | 307 | } |
308 | 308 | |
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. |
311 | 311 | if ( !$data && $useCache != 'skipcache' ) { |
312 | 312 | $dbr = wfGetDB( DB_SLAVE ); |
313 | 313 | $row = $dbr->selectRow( 'code_rev', |
— | — | @@ -317,7 +317,7 @@ |
318 | 318 | if ( $row ) { |
319 | 319 | $flags = explode( ',', $row->cr_flags ); |
320 | 320 | $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 |
322 | 322 | if ( $data !== false && in_array( 'gzip', $flags ) ) { |
323 | 323 | # Deal with optional compression of archived pages. |
324 | 324 | # This can be done periodically via maintenance/compressOld.php, and |
— | — | @@ -327,25 +327,24 @@ |
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
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. |
333 | 333 | if ( !$data && $useCache !== 'cached' ) { |
334 | 334 | $svn = SubversionAdaptor::newFromRepo( $this->path ); |
335 | 335 | $data = $svn->getDiff( '', $rev1, $rev2 ); |
336 | 336 | |
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! |
340 | 340 | if ($data == "") { |
341 | 341 | $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 |
347 | 346 | $wgMemc->set( $key, $data, 3600 * 24 * 3 ); |
348 | 347 | |
349 | | - // Permanent DB storage |
| 348 | + // Permanent DB storage |
350 | 349 | $storedData = $data; |
351 | 350 | $flags = Revision::compressRevisionText( $storedData ); |
352 | 351 | $dbw = wfGetDB( DB_MASTER ); |
Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -136,14 +136,14 @@ |
137 | 137 | $options['LIMIT'] = $cacheSize; |
138 | 138 | } |
139 | 139 | |
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. |
148 | 148 | $res = $dbw->select( 'code_rev', 'cr_id', |
149 | 149 | array( 'cr_repo_id' => $repo->getId(), 'cr_diff IS NULL OR cr_diff = ""' ), |
150 | 150 | __METHOD__, |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | $repo->getRevision( $row->cr_id ); |
155 | 155 | $diff = $repo->getDiff( $row->cr_id ); // trigger caching |
156 | 156 | $msg = "Diff r{$row->cr_id} "; |
157 | | - if (is_integer($diff)) { |
| 157 | + if ( is_integer( $diff ) ) { |
158 | 158 | $msg .= "Skipped: "; |
159 | 159 | switch ($diff) { |
160 | 160 | case DIFFRESULT_BadRevision: |
— | — | @@ -173,14 +173,12 @@ |
174 | 174 | $msg .= "Unknown reason!"; |
175 | 175 | break; |
176 | 176 | } |
177 | | - } |
178 | | - else { |
| 177 | + } else { |
179 | 178 | $msg .= "done"; |
180 | 179 | } |
181 | 180 | $this->output( $msg . "\n" ); |
182 | 181 | } |
183 | | - } |
184 | | - else { |
| 182 | + } else { |
185 | 183 | $this->output( "Pre-caching skipped.\n" ); |
186 | 184 | } |
187 | 185 | $this->output( "Done!\n" ); |