Index: trunk/extensions/ExtensionDistributor/svn-invoker.php |
— | — | @@ -71,36 +71,58 @@ |
72 | 72 | } |
73 | 73 | $version = $command->version; |
74 | 74 | $extension = $command->extension; |
| 75 | + $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension"; |
75 | 76 | |
76 | | - // svn up |
77 | | - $dir = "$wgExtDistWorkingCopy/$version/extensions/$extension"; |
78 | | - $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1"; |
79 | | - $retval = - 1; |
80 | | - $result = svnShellExec( $cmd, $retval ); |
81 | | - if ( $retval ) { |
82 | | - svnError( 'extdist-svn-error', $result ); |
| 77 | + // Determine last changed revision in the checkout |
| 78 | + $localRev = svnGetRev( $dir, &$remoteDir ); |
| 79 | + if ( !$localRev ) { |
83 | 80 | return; |
84 | 81 | } |
| 82 | + |
| 83 | + // Determine last changed revision in the repo |
| 84 | + $remoteRev = svnGetRev( $remoteDir ); |
| 85 | + if ( !$remoteRev ) { |
| 86 | + return; |
| 87 | + } |
| 88 | + |
| 89 | + if ( $remoteRev != $localRev ) { |
| 90 | + // Bad luck, we need to svn up |
| 91 | + $cmd = "svn up --non-interactive " . escapeshellarg( $dir ) . " 2>&1"; |
| 92 | + $retval = - 1; |
| 93 | + $result = svnShellExec( $cmd, $retval ); |
| 94 | + if ( $retval ) { |
| 95 | + svnError( 'extdist-svn-error', $result ); |
| 96 | + return; |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + echo json_encode( array( 'revision' => $remoteRev ) ); |
| 101 | +} |
85 | 102 | |
86 | | - // Determine last changed revision |
| 103 | +// Returns the last changed revision or false |
| 104 | +// @param $dir Path or url of the folder |
| 105 | +// Output param $url Remote location of the folder |
| 106 | +function svnGetRev( $dir, &$url = null ) { |
| 107 | + |
87 | 108 | $cmd = "svn info --non-interactive --xml " . escapeshellarg( $dir ); |
88 | 109 | $retval = - 1; |
89 | 110 | $result = svnShellExec( $cmd, $retval ); |
90 | 111 | if ( $retval ) { |
91 | 112 | svnError( 'extdist-svn-error', $result ); |
92 | | - return; |
| 113 | + return false; |
93 | 114 | } |
94 | 115 | |
95 | 116 | try { |
96 | 117 | $sx = new SimpleXMLElement( $result ); |
97 | 118 | $rev = strval( $sx->entry->commit['revision'] ); |
| 119 | + $url = $sx->entry->url; |
98 | 120 | } catch ( Exception $e ) { |
99 | 121 | $rev = false; |
100 | 122 | } |
101 | 123 | if ( !$rev || strpos( $rev, '/' ) !== false || strpos( $rev, "\000" ) !== false ) { |
102 | 124 | svnError( 'extdist-svn-parse-error', $result ); |
103 | | - return; |
| 125 | + return false; |
104 | 126 | } |
105 | | - |
106 | | - echo json_encode( array( 'revision' => $rev ) ); |
| 127 | + |
| 128 | + return $rev; |
107 | 129 | } |