Index: trunk/extensions/CodeReview/backend/Subversion.php |
— | — | @@ -19,6 +19,8 @@ |
20 | 20 | $this->mRepo = $repo; |
21 | 21 | } |
22 | 22 | |
| 23 | + abstract function canConnect(); |
| 24 | + |
23 | 25 | abstract function getFile( $path, $rev = null ); |
24 | 26 | |
25 | 27 | abstract function getDiff( $path, $rev1, $rev2 ); |
— | — | @@ -54,6 +56,12 @@ |
55 | 57 | * Using the SVN PECL extension... |
56 | 58 | */ |
57 | 59 | class SubversionPecl extends SubversionAdaptor { |
| 60 | + |
| 61 | + function canConnect() { |
| 62 | + // TODO! |
| 63 | + return true; |
| 64 | + } |
| 65 | + |
58 | 66 | function getFile( $path, $rev = null ) { |
59 | 67 | return svn_cat( $this->mRepo . $path, $rev ); |
60 | 68 | } |
— | — | @@ -94,6 +102,22 @@ |
95 | 103 | * Using the thingy-bobber |
96 | 104 | */ |
97 | 105 | class SubversionShell extends SubversionAdaptor { |
| 106 | + |
| 107 | + function canConnect() { |
| 108 | + $command = sprintf( |
| 109 | + "svn info %s %s", |
| 110 | + $this->getExtraArgs(), |
| 111 | + wfEscapeShellArg( $this->mRepo ) ); |
| 112 | + |
| 113 | + $Result = wfShellExec( $command ); |
| 114 | + if ( $Result == "" ) |
| 115 | + return false; |
| 116 | + elseif ( strpos( $Result, "No repository found" ) !== false ) |
| 117 | + return false; |
| 118 | + else |
| 119 | + return true; |
| 120 | + } |
| 121 | + |
98 | 122 | function getFile( $path, $rev = null ) { |
99 | 123 | if ( $rev ) |
100 | 124 | $path .= "@$rev"; |
— | — | @@ -282,6 +306,11 @@ |
283 | 307 | $this->mTimeout = $timeout; |
284 | 308 | } |
285 | 309 | |
| 310 | + function canConnect() { |
| 311 | + // TODO! |
| 312 | + return true; |
| 313 | + } |
| 314 | + |
286 | 315 | function getFile( $path, $rev = null ) { |
287 | 316 | throw new MWException( "NYI" ); |
288 | 317 | } |
Index: trunk/extensions/CodeReview/svnImport.php |
— | — | @@ -31,6 +31,10 @@ |
32 | 32 | } |
33 | 33 | |
34 | 34 | echo "Syncing repo {$args[0]} from r$start to HEAD...\n"; |
| 35 | + |
| 36 | +if ( !$svn->canConnect() ) |
| 37 | + die( "Unable to connect to repository.\n" ); |
| 38 | + |
35 | 39 | while ( true ) { |
36 | 40 | $log = $svn->getLog( '', $start, $start + $chunkSize - 1 ); |
37 | 41 | if ( empty( $log ) ) { |