Index: trunk/extensions/CodeReview/backend/CodeRepository.php |
— | — | @@ -523,21 +523,31 @@ |
524 | 524 | |
525 | 525 | /** |
526 | 526 | * @static |
527 | | - * @param int $error |
528 | | - * @return string |
| 527 | + * @param $diff int (error code) or string (diff text), as returned from getDiff() |
| 528 | + * @return string (error message, or empty string if valid diff) |
529 | 529 | */ |
530 | | - public static function getDiffErrorMessage( $error ) { |
531 | | - switch( $error ) { |
532 | | - case self::DIFFRESULT_BadRevision: |
533 | | - return 'Bad revision specified.'; |
534 | | - case self::DIFFRESULT_TooManyPaths: |
535 | | - return 'Too many paths returned to diff'; |
536 | | - case self::DIFFRESULT_NoDataReturned: |
537 | | - return 'No data returned for diff'; |
538 | | - case self::DIFFRESULT_NotInCache: |
539 | | - return 'Not in cache'; |
540 | | - default: |
541 | | - return 'Unknown'; |
| 530 | + public static function getDiffErrorMessage( $diff ) { |
| 531 | + global $wgCodeReviewMaxDiffPaths; |
| 532 | + |
| 533 | + if ( is_integer( $diff ) ) { |
| 534 | + switch( $diff ) { |
| 535 | + case self::DIFFRESULT_BadRevision: |
| 536 | + return 'Bad revision'; |
| 537 | + case self::DIFFRESULT_NothingToCompare: |
| 538 | + return 'Nothing to compare'; |
| 539 | + case self::DIFFRESULT_TooManyPaths: |
| 540 | + return 'Too many paths ($wgCodeReviewMaxDiffPaths = ' |
| 541 | + . $wgCodeReviewMaxDiffPaths . ')'; |
| 542 | + case self::DIFFRESULT_NoDataReturned: |
| 543 | + return 'No data returned - no diff data, or connection lost'; |
| 544 | + case self::DIFFRESULT_NotInCache: |
| 545 | + return 'Not in cache'; |
| 546 | + default: |
| 547 | + return 'Unknown reason!'; |
| 548 | + } |
542 | 549 | } |
| 550 | + |
| 551 | + // TODO: Should this return "", $diff or a message string, e.g. "OK"? |
| 552 | + return ""; |
543 | 553 | } |
544 | 554 | } |
Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | * @param $start Int Revision to begin the import from (Default: null, means last stored revision); |
52 | 52 | */ |
53 | 53 | private function importRepo( $repoName, $start = null, $cacheSize = 0 ) { |
54 | | - global $wgCodeReviewImportBatchSize, $wgCodeReviewMaxDiffPaths; |
| 54 | + global $wgCodeReviewImportBatchSize; |
55 | 55 | |
56 | 56 | $repo = CodeRepository::newFromName( $repoName ); |
57 | 57 | |
— | — | @@ -154,25 +154,7 @@ |
155 | 155 | $diff = $repo->getDiff( $row->cr_id ); // trigger caching |
156 | 156 | $msg = "Diff r{$row->cr_id} "; |
157 | 157 | if ( is_integer( $diff ) ) { |
158 | | - $msg .= "Skipped: "; |
159 | | - switch ($diff) { |
160 | | - case CodeRepository::DIFFRESULT_BadRevision: |
161 | | - $msg .= "Bad revision"; |
162 | | - break; |
163 | | - case CodeRepository::DIFFRESULT_NothingToCompare: |
164 | | - $msg .= "Nothing to compare"; |
165 | | - break; |
166 | | - case CodeRepository::DIFFRESULT_TooManyPaths: |
167 | | - $msg .= "Too many paths (\$wgCodeReviewMaxDiffPaths = " |
168 | | - . $wgCodeReviewMaxDiffPaths . ")"; |
169 | | - break; |
170 | | - case CodeRepository::DIFFRESULT_NoDataReturned: |
171 | | - $msg .= "No data returned - no diff data, or connection lost."; |
172 | | - break; |
173 | | - default: |
174 | | - $msg .= "Unknown reason!"; |
175 | | - break; |
176 | | - } |
| 158 | + $msg .= "Skipped: " . CodeRepository::getDiffErrorMessage( $diff ); |
177 | 159 | } else { |
178 | 160 | $msg .= "done"; |
179 | 161 | } |