r43641 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43640‎ | r43641 | r43642 >
Date:21:37, 17 November 2008
Author:skizzerz
Status:ok (Comments)
Tags:
Comment:
* Add user and password globals so that those using SubversionShell and closed svn can see diffs
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/Subversion.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -101,5 +101,11 @@
102102 // The name of a repo which represents the code running on this wiki, used to highlight active revisions
103103 $wgWikiSVN = 'MediaWiki';
104104
 105+// If you are running a closed svn, fill the following two lines with the username and password
 106+// of a user allowed to access it. Otherwise, leave it false.
 107+// This is only necessary if using the shell method to access Subversion
 108+$wgSubversionUser = false;
 109+$wgSubversionPassword = false;
 110+
105111 // Leave this off by default until it works right
106112 $wgCodeReviewENotif = false;
Index: trunk/extensions/CodeReview/Subversion.php
@@ -98,7 +98,8 @@
9999 if( $rev )
100100 $path .= "@$rev";
101101 $command = sprintf(
102 - "svn cat %s",
 102+ "svn cat %s %s",
 103+ $this->getExtraArgs(),
103104 wfEscapeShellArg( $this->mRepo . $path ) );
104105
105106 return wfShellExec( $command );
@@ -106,9 +107,10 @@
107108
108109 function getDiff( $path, $rev1, $rev2 ) {
109110 $command = sprintf(
110 - "svn diff -r%d:%d %s",
 111+ "svn diff -r%d:%d %s %s",
111112 intval( $rev1 ),
112113 intval( $rev2 ),
 114+ $this->getExtraArgs(),
113115 wfEscapeShellArg( $this->mRepo . $path ) );
114116
115117 return wfShellExec( $command );
@@ -116,9 +118,10 @@
117119
118120 function getLog( $path, $startRev=null, $endRev=null ) {
119121 $command = sprintf(
120 - "svn log -v -r%s:%s --non-interactive %s",
 122+ "svn log -v -r%s:%s --non-interactive %s %s",
121123 wfEscapeShellArg( $this->_rev( $startRev, 'BASE' ) ),
122124 wfEscapeShellArg( $this->_rev( $endRev, 'HEAD' ) ),
 125+ $this->getExtraArgs(),
123126 wfEscapeShellArg( $this->mRepo . $path ) );
124127
125128 $lines = explode( "\n", wfShellExec( $command ) );
@@ -210,8 +213,9 @@
211214
212215 function getDirList( $path, $rev = null ) {
213216 $command = sprintf(
214 - "svn list --xml -r%s --non-interactive %s",
 217+ "svn list --xml -r%s --non-interactive %s %s",
215218 wfEscapeShellArg( $this->_rev( $rev, 'HEAD' ) ),
 219+ $this->getExtraArgs(),
216220 wfEscapeShellArg( $this->mRepo . $path ) );
217221 $document = new DOMDocument();
218222
@@ -252,6 +256,18 @@
253257 }
254258 return $result;
255259 }
 260+
 261+ /**
 262+ * Returns a string of extra arguments to be passed into the shell commands
 263+ */
 264+ private function getExtraArgs() {
 265+ global $wgSubversionUser, $wgSubversionPassword;
 266+ if($wgSubversionUser && $wgSubversionPassword) {
 267+ return '--username ' . wfEscapeShellArg($wgSubversionUser)
 268+ . ' --password ' . wfEscapeShellArg($wgSubversionPassword);
 269+ }
 270+ return '';
 271+ }
256272 }
257273
258274 /**

Comments

#Comment by Aaron Schulz (talk | contribs)   01:22, 18 November 2008
  • looks* ok

Status & tagging log