Skip to content

Commit

Permalink
Merge pull request #16 from opi99/master
Browse files Browse the repository at this point in the history
Fix bug #20031
  • Loading branch information
mrook committed Aug 11, 2013
2 parents f6afd4b + 1e1f96d commit 2c64b4f
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 69 deletions.
104 changes: 54 additions & 50 deletions VersionControl/SVN/Command.php
Expand Up @@ -92,17 +92,10 @@ abstract class VersionControl_SVN_Command
* @var string $binaryPath * @var string $binaryPath
*/ */
public $binaryPath = '/usr/local/bin/svn'; public $binaryPath = '/usr/local/bin/svn';

/**
* Legacy / compatibility location of the svn client binary
*
* @var string $svn_path
*/
public $svn_path = '';


/** /**
* String to prepend to command string. Helpful for setting exec() * String to prepend to command string. Helpful for setting exec()
* environment variables, such as: * environment variables, such as:
* export LANG=en_US.utf8 && * export LANG=en_US.utf8 &&
* ... to support non-ASCII file and directory names. * ... to support non-ASCII file and directory names.
* *
Expand All @@ -118,16 +111,7 @@ abstract class VersionControl_SVN_Command
public $switches = array(); public $switches = array();


/** /**
* Switches required by this subcommand. * Runtime options being used.
* See {@link http://svnbook.red-bean.com/svnbook/ Version Control with Subversion},
* Subversion Complete Reference for details on arguments for this subcommand.
*
* @var array $requiredSwitches
*/
public $requiredSwitches = array();

/**
* Runtime options being used.
* *
* @var array $options * @var array $options
*/ */
Expand All @@ -142,16 +126,7 @@ abstract class VersionControl_SVN_Command
public $args = array(); public $args = array();


/** /**
* Minimum number of args required by this subcommand. * Preferred fetchmode. Note that not all subcommands have output available for
* See {@link http://svnbook.red-bean.com/svnbook/ Version Control with Subversion},
* Subversion Complete Reference for details on arguments for this subcommand.
*
* @var int $minArgs
*/
public $minArgs = 0;

/**
* Preferred fetchmode. Note that not all subcommands have output available for
* each preferred fetchmode. The default cascade is: * each preferred fetchmode. The default cascade is:
* *
* VERSIONCONTROL_SVN_FETCHMODE_ASSOC * VERSIONCONTROL_SVN_FETCHMODE_ASSOC
Expand Down Expand Up @@ -191,6 +166,38 @@ abstract class VersionControl_SVN_Command
*/ */
public $configOption = null; public $configOption = null;


/**
* Default no-auth-cache to use for connections.
*
* @var string $noAuthCache
*/
public $noAuthCache = null;

/**
* Default trust-server-cert to use for connections.
*
* @var string $trustServerCert
*/
public $trustServerCert = false;

/**
* Switches required by this subcommand.
* See {@link http://svnbook.red-bean.com/svnbook/ Version Control with Subversion},
* Subversion Complete Reference for details on arguments for this subcommand.
*
* @var array $requiredSwitches
*/
protected $requiredSwitches = array();

/**
* Minimum number of args required by this subcommand.
* See {@link http://svnbook.red-bean.com/svnbook/ Version Control with Subversion},
* Subversion Complete Reference for details on arguments for this subcommand.
*
* @var int $minArgs
*/
protected $minArgs = 0;

/** /**
* SVN subcommand to run. * SVN subcommand to run.
* *
Expand Down Expand Up @@ -315,9 +322,7 @@ public function prepare()


$this->postProcessSwitches($invalidSwitches); $this->postProcessSwitches($invalidSwitches);


$this->preparedCmd = implode( $this->preparedCmd = implode(' ', array_merge($cmdParts, $this->args));
' ', array_merge($cmdParts, $this->args)
);
} }


/** /**
Expand Down Expand Up @@ -364,15 +369,25 @@ protected function preProcessSwitches()
} else { } else {
$this->switches['xml'] = false; $this->switches['xml'] = false;
} }

$this->switches['non-interactive'] = true; $this->switches['non-interactive'] = true;


$this->fillSwitch('username', $this->username); $this->fillSwitch('username', $this->username);
$this->fillSwitch('password', $this->password); $this->fillSwitch('password', $this->password);
$this->fillSwitch('config-dir', $this->configDir); $this->fillSwitch('config-dir', $this->configDir);
$this->fillSwitch('config-option', $this->configOption); $this->fillSwitch('config-option', $this->configOption);
$this->fillSwitch('no-auth-cache', $this->noAuthCache);
$this->fillSwitch('trust-server-cert', $this->trustServerCert);
} }


/**
* Fills the switches array on given name with value if not already set and value is not null.
*
* @param string $switchName Name of the switch.
* @param string $value Value for the switch.
*
* @return void
*/
protected function fillSwitch($switchName, $value) protected function fillSwitch($switchName, $value)
{ {
if (!isset($this->switches[$switchName]) if (!isset($this->switches[$switchName])
Expand All @@ -391,21 +406,14 @@ protected function fillSwitch($switchName, $value)
*/ */
public function checkCommandRequirements() public function checkCommandRequirements()
{ {
// Set up error push parameters to avoid any notices about undefined indexes
$params['options'] = $this->options;
$params['switches'] = $this->switches;
$params['args'] = $this->args;
$params['commandName'] = $this->commandName;
$params['cmd'] = '';

// Check for minimum arguments // Check for minimum arguments
if (sizeof($this->args) < $this->minArgs) { if (sizeof($this->args) < $this->minArgs) {
throw new VersionControl_SVN_Exception( throw new VersionControl_SVN_Exception(
'svn command requires at least ' . $this->minArgs . ' argument(s)', 'svn command requires at least ' . $this->minArgs . ' argument(s)',
VersionControl_SVN_Exception::MIN_ARGS VersionControl_SVN_Exception::MIN_ARGS
); );
} }

// Check for presence of required switches // Check for presence of required switches
if (sizeof($this->requiredSwitches) > 0) { if (sizeof($this->requiredSwitches) > 0) {
$missing = array(); $missing = array();
Expand All @@ -420,7 +428,7 @@ public function checkCommandRequirements()
} }
} }
if (!$found) { if (!$found) {
$missing[] = '('.$req.')'; $missing[] = '(' . $req . ')';
} }
} }
$num_missing = count($missing); $num_missing = count($missing);
Expand All @@ -439,15 +447,11 @@ public function checkCommandRequirements()
* @param array $args Arguments to pass to Subversion * @param array $args Arguments to pass to Subversion
* @param array $switches Switches to pass to Subversion * @param array $switches Switches to pass to Subversion
* *
* @return mixed $fetchmode specified output on success. * @return mixed $fetchmode specified output on success.
* @throws VersionControl_SVN_Exception If command failed. * @throws VersionControl_SVN_Exception If command failed.
*/ */
public function run($args = array(), $switches = array()) public function run($args = array(), $switches = array())
{ {
if ($this->svn_path != '') {
$this->binaryPath = $this->svn_path;
}

if (!file_exists($this->binaryPath)) { if (!file_exists($this->binaryPath)) {
$system = new System(); $system = new System();
$this->binaryPath = $system->which('svn'); $this->binaryPath = $system->which('svn');
Expand All @@ -472,7 +476,7 @@ public function run($args = array(), $switches = array())
$cmd = $this->preparedCmd; $cmd = $this->preparedCmd;


// On Windows, don't use escapeshellcmd, and double-quote $cmd // On Windows, don't use escapeshellcmd, and double-quote $cmd
// so it's executed as // so it's executed as
// cmd /c ""C:\Program Files\SVN\bin\svn.exe" info "C:\Program Files\dev\trunk"" // cmd /c ""C:\Program Files\SVN\bin\svn.exe" info "C:\Program Files\dev\trunk""
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$cmd = str_replace( $cmd = str_replace(
Expand Down Expand Up @@ -513,8 +517,8 @@ public function run($args = array(), $switches = array())
* *
* @param array $out Array of output captured by exec command in {@link run} * @param array $out Array of output captured by exec command in {@link run}
* *
* @return mixed Returns output requested by fetchmode (if available), or * @return mixed Returns output requested by fetchmode (if available), or
* raw output if desired fetchmode is not available. * raw output if desired fetchmode is not available.
*/ */
public function parseOutput($out) public function parseOutput($out)
{ {
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Add.php
Expand Up @@ -132,7 +132,7 @@ class VersionControl_SVN_Command_Add extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Blame.php
Expand Up @@ -128,7 +128,7 @@ class VersionControl_SVN_Command_Blame extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Keep track of whether XML output is available for a command * Keep track of whether XML output is available for a command
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Cat.php
Expand Up @@ -125,7 +125,7 @@ class VersionControl_SVN_Command_Cat extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Checkout.php
Expand Up @@ -139,7 +139,7 @@ class VersionControl_SVN_Command_Checkout extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Commit.php
Expand Up @@ -141,7 +141,7 @@ class VersionControl_SVN_Command_Commit extends VersionControl_SVN_Command
* *
* @var array $requiredSwitches * @var array $requiredSwitches
*/ */
public $requiredSwitches = array('m|message|F|file'); protected $requiredSwitches = array('m|message|F|file');


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Delete.php
Expand Up @@ -142,7 +142,7 @@ class VersionControl_SVN_Command_Delete extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Diff.php
Expand Up @@ -213,7 +213,7 @@ class VersionControl_SVN_Command_Diff extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Keep track of whether XML output is available for a command * Keep track of whether XML output is available for a command
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Export.php
Expand Up @@ -168,7 +168,7 @@ class VersionControl_SVN_Command_Export extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
4 changes: 2 additions & 2 deletions VersionControl/SVN/Command/Import.php
Expand Up @@ -146,7 +146,7 @@ class VersionControl_SVN_Command_Import extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Switches required by this subcommand. * Switches required by this subcommand.
Expand All @@ -155,7 +155,7 @@ class VersionControl_SVN_Command_Import extends VersionControl_SVN_Command
* *
* @var array $requiredSwitches * @var array $requiredSwitches
*/ */
public $requiredSwitches = array('m|message|F|file'); protected $requiredSwitches = array('m|message|F|file');


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Merge.php
Expand Up @@ -206,7 +206,7 @@ class VersionControl_SVN_Command_Merge extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
4 changes: 2 additions & 2 deletions VersionControl/SVN/Command/Mkdir.php
Expand Up @@ -147,7 +147,7 @@ class VersionControl_SVN_Command_Mkdir extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Switches required by this subcommand. * Switches required by this subcommand.
Expand All @@ -156,7 +156,7 @@ class VersionControl_SVN_Command_Mkdir extends VersionControl_SVN_Command
* *
* @var array $requiredSwitches * @var array $requiredSwitches
*/ */
public $requiredSwitches = array('m|message|F|file'); protected $requiredSwitches = array('m|message|F|file');


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Propdel.php
Expand Up @@ -132,7 +132,7 @@ class VersionControl_SVN_Command_Propdel extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Propget.php
Expand Up @@ -139,7 +139,7 @@ class VersionControl_SVN_Command_Propget extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Keep track of whether XML output is available for a command * Keep track of whether XML output is available for a command
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Propset.php
Expand Up @@ -166,7 +166,7 @@ class VersionControl_SVN_Command_Propset extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 3; protected $minArgs = 3;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Resolved.php
Expand Up @@ -123,7 +123,7 @@ class VersionControl_SVN_Command_Resolved extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Revert.php
Expand Up @@ -122,7 +122,7 @@ class VersionControl_SVN_Command_Revert extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down
2 changes: 1 addition & 1 deletion VersionControl/SVN/Command/Switch.php
Expand Up @@ -150,7 +150,7 @@ class VersionControl_SVN_Command_Switch extends VersionControl_SVN_Command
* *
* @var int $minArgs * @var int $minArgs
*/ */
public $minArgs = 1; protected $minArgs = 1;


/** /**
* Constuctor of command. Adds available switches. * Constuctor of command. Adds available switches.
Expand Down

0 comments on commit 2c64b4f

Please sign in to comment.