Permalink
Browse files

Merge pull request #16 from opi99/master

Fix bug #20031
  • Loading branch information...
mrook committed Aug 11, 2013
2 parents f6afd4b + 1e1f96d commit 2c64b4f0da9c2a768af33781dabbd7a509a5dc80
@@ -92,17 +92,10 @@
* @var string $binaryPath
*/
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()
- * environment variables, such as:
+ * String to prepend to command string. Helpful for setting exec()
+ * environment variables, such as:
* export LANG=en_US.utf8 &&
* ... to support non-ASCII file and directory names.
*
@@ -118,16 +111,7 @@
public $switches = array();
/**
- * 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
- */
- public $requiredSwitches = array();
-
- /**
- * Runtime options being used.
+ * Runtime options being used.
*
* @var array $options
*/
@@ -142,16 +126,7 @@
public $args = 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
- */
- public $minArgs = 0;
-
- /**
- * Preferred fetchmode. Note that not all subcommands have output available for
+ * Preferred fetchmode. Note that not all subcommands have output available for
* each preferred fetchmode. The default cascade is:
*
* VERSIONCONTROL_SVN_FETCHMODE_ASSOC
@@ -191,6 +166,38 @@
*/
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.
*
@@ -315,9 +322,7 @@ public function prepare()
$this->postProcessSwitches($invalidSwitches);
- $this->preparedCmd = implode(
- ' ', array_merge($cmdParts, $this->args)
- );
+ $this->preparedCmd = implode(' ', array_merge($cmdParts, $this->args));
}
/**
@@ -364,15 +369,25 @@ protected function preProcessSwitches()
} else {
$this->switches['xml'] = false;
}
-
+
$this->switches['non-interactive'] = true;
$this->fillSwitch('username', $this->username);
$this->fillSwitch('password', $this->password);
$this->fillSwitch('config-dir', $this->configDir);
$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)
{
if (!isset($this->switches[$switchName])
@@ -391,21 +406,14 @@ protected function fillSwitch($switchName, $value)
*/
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
if (sizeof($this->args) < $this->minArgs) {
throw new VersionControl_SVN_Exception(
'svn command requires at least ' . $this->minArgs . ' argument(s)',
VersionControl_SVN_Exception::MIN_ARGS
);
}
-
+
// Check for presence of required switches
if (sizeof($this->requiredSwitches) > 0) {
$missing = array();
@@ -420,7 +428,7 @@ public function checkCommandRequirements()
}
}
if (!$found) {
- $missing[] = '('.$req.')';
+ $missing[] = '(' . $req . ')';
}
}
$num_missing = count($missing);
@@ -439,15 +447,11 @@ public function checkCommandRequirements()
* @param array $args Arguments 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.
*/
public function run($args = array(), $switches = array())
{
- if ($this->svn_path != '') {
- $this->binaryPath = $this->svn_path;
- }
-
if (!file_exists($this->binaryPath)) {
$system = new System();
$this->binaryPath = $system->which('svn');
@@ -472,7 +476,7 @@ public function run($args = array(), $switches = array())
$cmd = $this->preparedCmd;
// 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""
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$cmd = str_replace(
@@ -513,8 +517,8 @@ public function run($args = array(), $switches = array())
*
* @param array $out Array of output captured by exec command in {@link run}
*
- * @return mixed Returns output requested by fetchmode (if available), or
- * raw output if desired fetchmode is not available.
+ * @return mixed Returns output requested by fetchmode (if available), or
+ * raw output if desired fetchmode is not available.
*/
public function parseOutput($out)
{
@@ -132,7 +132,7 @@ class VersionControl_SVN_Command_Add extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -128,7 +128,7 @@ class VersionControl_SVN_Command_Blame extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Keep track of whether XML output is available for a command
@@ -125,7 +125,7 @@ class VersionControl_SVN_Command_Cat extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -139,7 +139,7 @@ class VersionControl_SVN_Command_Checkout extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -141,7 +141,7 @@ class VersionControl_SVN_Command_Commit extends VersionControl_SVN_Command
*
* @var array $requiredSwitches
*/
- public $requiredSwitches = array('m|message|F|file');
+ protected $requiredSwitches = array('m|message|F|file');
/**
* Constuctor of command. Adds available switches.
@@ -142,7 +142,7 @@ class VersionControl_SVN_Command_Delete extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -213,7 +213,7 @@ class VersionControl_SVN_Command_Diff extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Keep track of whether XML output is available for a command
@@ -168,7 +168,7 @@ class VersionControl_SVN_Command_Export extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -146,7 +146,7 @@ class VersionControl_SVN_Command_Import extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Switches required by this subcommand.
@@ -155,7 +155,7 @@ class VersionControl_SVN_Command_Import extends VersionControl_SVN_Command
*
* @var array $requiredSwitches
*/
- public $requiredSwitches = array('m|message|F|file');
+ protected $requiredSwitches = array('m|message|F|file');
/**
* Constuctor of command. Adds available switches.
@@ -206,7 +206,7 @@ class VersionControl_SVN_Command_Merge extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -147,7 +147,7 @@ class VersionControl_SVN_Command_Mkdir extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Switches required by this subcommand.
@@ -156,7 +156,7 @@ class VersionControl_SVN_Command_Mkdir extends VersionControl_SVN_Command
*
* @var array $requiredSwitches
*/
- public $requiredSwitches = array('m|message|F|file');
+ protected $requiredSwitches = array('m|message|F|file');
/**
* Constuctor of command. Adds available switches.
@@ -132,7 +132,7 @@ class VersionControl_SVN_Command_Propdel extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -139,7 +139,7 @@ class VersionControl_SVN_Command_Propget extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Keep track of whether XML output is available for a command
@@ -166,7 +166,7 @@ class VersionControl_SVN_Command_Propset extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 3;
+ protected $minArgs = 3;
/**
* Constuctor of command. Adds available switches.
@@ -123,7 +123,7 @@ class VersionControl_SVN_Command_Resolved extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -122,7 +122,7 @@ class VersionControl_SVN_Command_Revert extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.
@@ -150,7 +150,7 @@ class VersionControl_SVN_Command_Switch extends VersionControl_SVN_Command
*
* @var int $minArgs
*/
- public $minArgs = 1;
+ protected $minArgs = 1;
/**
* Constuctor of command. Adds available switches.

0 comments on commit 2c64b4f

Please sign in to comment.