From e1109d299d83e5663a3a8d137307728defb32e38 Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 11:48:48 +0200 Subject: [PATCH 1/7] Fix some whitespaces. --- VersionControl/SVN/Command.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index 4e0d906..a253e60 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -92,7 +92,7 @@ abstract class VersionControl_SVN_Command * @var string $binaryPath */ public $binaryPath = '/usr/local/bin/svn'; - + /** * Legacy / compatibility location of the svn client binary * @@ -315,9 +315,7 @@ public function prepare() $this->postProcessSwitches($invalidSwitches); - $this->preparedCmd = implode( - ' ', array_merge($cmdParts, $this->args) - ); + $this->preparedCmd = implode(' ', array_merge($cmdParts, $this->args)); } /** @@ -364,7 +362,7 @@ protected function preProcessSwitches() } else { $this->switches['xml'] = false; } - + $this->switches['non-interactive'] = true; $this->fillSwitch('username', $this->username); @@ -405,7 +403,7 @@ public function checkCommandRequirements() VersionControl_SVN_Exception::MIN_ARGS ); } - + // Check for presence of required switches if (sizeof($this->requiredSwitches) > 0) { $missing = array(); @@ -447,7 +445,7 @@ 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 +470,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( From e11ad6180b56806abf183892d5b30ea18d3a27be Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:04:15 +0200 Subject: [PATCH 2/7] More whitespaces and DocBlock. --- VersionControl/SVN/Command.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index a253e60..f4f0650 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -101,8 +101,8 @@ abstract class VersionControl_SVN_Command 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. * @@ -127,7 +127,7 @@ abstract class VersionControl_SVN_Command public $requiredSwitches = array(); /** - * Runtime options being used. + * Runtime options being used. * * @var array $options */ @@ -151,7 +151,7 @@ abstract class VersionControl_SVN_Command 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 @@ -371,6 +371,14 @@ protected function preProcessSwitches() $this->fillSwitch('config-option', $this->configOption); } + /** + * 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]) @@ -395,7 +403,7 @@ public function checkCommandRequirements() $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( @@ -418,7 +426,7 @@ public function checkCommandRequirements() } } if (!$found) { - $missing[] = '('.$req.')'; + $missing[] = '(' . $req . ')'; } } $num_missing = count($missing); @@ -437,7 +445,7 @@ 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()) @@ -511,8 +519,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) { From 95e0de190f702d0e60755f87754dc8e6716c6683 Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:19:38 +0200 Subject: [PATCH 3/7] Bug #20031: Unused source. --- VersionControl/SVN/Command.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index f4f0650..b7ca54f 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -397,13 +397,6 @@ 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( From cde0e35ac4f020a00d3ce271bf47e4c71e86048c Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:22:07 +0200 Subject: [PATCH 4/7] Bug #20031: Remove legacy svn_path option. --- VersionControl/SVN/Command.php | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index b7ca54f..163cde6 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -93,13 +93,6 @@ abstract class VersionControl_SVN_Command */ 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: @@ -443,10 +436,6 @@ public function checkCommandRequirements() */ 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'); From be105bdad9bc2a2cbe773517d7944076a68eb176 Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:30:48 +0200 Subject: [PATCH 5/7] Bug #20031: Change minArgs and requiredSwitches from public to protected. --- VersionControl/SVN/Command.php | 4 ++-- VersionControl/SVN/Command/Add.php | 2 +- VersionControl/SVN/Command/Blame.php | 2 +- VersionControl/SVN/Command/Cat.php | 2 +- VersionControl/SVN/Command/Checkout.php | 2 +- VersionControl/SVN/Command/Commit.php | 2 +- VersionControl/SVN/Command/Delete.php | 2 +- VersionControl/SVN/Command/Diff.php | 2 +- VersionControl/SVN/Command/Export.php | 2 +- VersionControl/SVN/Command/Import.php | 4 ++-- VersionControl/SVN/Command/Merge.php | 2 +- VersionControl/SVN/Command/Mkdir.php | 4 ++-- VersionControl/SVN/Command/Propdel.php | 2 +- VersionControl/SVN/Command/Propget.php | 2 +- VersionControl/SVN/Command/Propset.php | 2 +- VersionControl/SVN/Command/Resolved.php | 2 +- VersionControl/SVN/Command/Revert.php | 2 +- VersionControl/SVN/Command/Switch.php | 2 +- 18 files changed, 21 insertions(+), 21 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index 163cde6..d62f808 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -117,7 +117,7 @@ abstract class VersionControl_SVN_Command * * @var array $requiredSwitches */ - public $requiredSwitches = array(); + protected $requiredSwitches = array(); /** * Runtime options being used. @@ -141,7 +141,7 @@ abstract class VersionControl_SVN_Command * * @var int $minArgs */ - public $minArgs = 0; + protected $minArgs = 0; /** * Preferred fetchmode. Note that not all subcommands have output available for diff --git a/VersionControl/SVN/Command/Add.php b/VersionControl/SVN/Command/Add.php index 6ff5408..014bf9f 100644 --- a/VersionControl/SVN/Command/Add.php +++ b/VersionControl/SVN/Command/Add.php @@ -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. diff --git a/VersionControl/SVN/Command/Blame.php b/VersionControl/SVN/Command/Blame.php index ff53e1e..bca587c 100644 --- a/VersionControl/SVN/Command/Blame.php +++ b/VersionControl/SVN/Command/Blame.php @@ -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 diff --git a/VersionControl/SVN/Command/Cat.php b/VersionControl/SVN/Command/Cat.php index da968d4..e1244f7 100644 --- a/VersionControl/SVN/Command/Cat.php +++ b/VersionControl/SVN/Command/Cat.php @@ -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. diff --git a/VersionControl/SVN/Command/Checkout.php b/VersionControl/SVN/Command/Checkout.php index ff1af0f..79758f4 100644 --- a/VersionControl/SVN/Command/Checkout.php +++ b/VersionControl/SVN/Command/Checkout.php @@ -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. diff --git a/VersionControl/SVN/Command/Commit.php b/VersionControl/SVN/Command/Commit.php index 17e31b1..338b59d 100644 --- a/VersionControl/SVN/Command/Commit.php +++ b/VersionControl/SVN/Command/Commit.php @@ -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. diff --git a/VersionControl/SVN/Command/Delete.php b/VersionControl/SVN/Command/Delete.php index 2a02e9a..716da84 100644 --- a/VersionControl/SVN/Command/Delete.php +++ b/VersionControl/SVN/Command/Delete.php @@ -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. diff --git a/VersionControl/SVN/Command/Diff.php b/VersionControl/SVN/Command/Diff.php index 2961552..d090041 100644 --- a/VersionControl/SVN/Command/Diff.php +++ b/VersionControl/SVN/Command/Diff.php @@ -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 diff --git a/VersionControl/SVN/Command/Export.php b/VersionControl/SVN/Command/Export.php index 0adfead..96b2ae9 100644 --- a/VersionControl/SVN/Command/Export.php +++ b/VersionControl/SVN/Command/Export.php @@ -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. diff --git a/VersionControl/SVN/Command/Import.php b/VersionControl/SVN/Command/Import.php index 9618486..9317552 100644 --- a/VersionControl/SVN/Command/Import.php +++ b/VersionControl/SVN/Command/Import.php @@ -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. diff --git a/VersionControl/SVN/Command/Merge.php b/VersionControl/SVN/Command/Merge.php index a37c933..65f78ce 100644 --- a/VersionControl/SVN/Command/Merge.php +++ b/VersionControl/SVN/Command/Merge.php @@ -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. diff --git a/VersionControl/SVN/Command/Mkdir.php b/VersionControl/SVN/Command/Mkdir.php index 2f46f8d..2328f38 100644 --- a/VersionControl/SVN/Command/Mkdir.php +++ b/VersionControl/SVN/Command/Mkdir.php @@ -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. diff --git a/VersionControl/SVN/Command/Propdel.php b/VersionControl/SVN/Command/Propdel.php index a691b18..935eb61 100644 --- a/VersionControl/SVN/Command/Propdel.php +++ b/VersionControl/SVN/Command/Propdel.php @@ -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. diff --git a/VersionControl/SVN/Command/Propget.php b/VersionControl/SVN/Command/Propget.php index e965975..dd941b7 100644 --- a/VersionControl/SVN/Command/Propget.php +++ b/VersionControl/SVN/Command/Propget.php @@ -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 diff --git a/VersionControl/SVN/Command/Propset.php b/VersionControl/SVN/Command/Propset.php index cb2539e..07b3d2f 100644 --- a/VersionControl/SVN/Command/Propset.php +++ b/VersionControl/SVN/Command/Propset.php @@ -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. diff --git a/VersionControl/SVN/Command/Resolved.php b/VersionControl/SVN/Command/Resolved.php index 1e5eb59..2d28449 100644 --- a/VersionControl/SVN/Command/Resolved.php +++ b/VersionControl/SVN/Command/Resolved.php @@ -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. diff --git a/VersionControl/SVN/Command/Revert.php b/VersionControl/SVN/Command/Revert.php index ae2b23d..d7a922a 100644 --- a/VersionControl/SVN/Command/Revert.php +++ b/VersionControl/SVN/Command/Revert.php @@ -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. diff --git a/VersionControl/SVN/Command/Switch.php b/VersionControl/SVN/Command/Switch.php index 29f7d2b..4463ff5 100644 --- a/VersionControl/SVN/Command/Switch.php +++ b/VersionControl/SVN/Command/Switch.php @@ -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. From 72e147d97b44f7498810b3171da8a42baf3b939c Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:42:26 +0200 Subject: [PATCH 6/7] Bug #20031: Add no-auth-cache and trust-server-cert as global options as noAuthCache and trustServerCert. --- VersionControl/SVN/Command.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index d62f808..bc6e3e8 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -184,6 +184,20 @@ abstract class VersionControl_SVN_Command */ 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; + /** * SVN subcommand to run. * @@ -362,6 +376,8 @@ protected function preProcessSwitches() $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); } /** From 1e1f96d1858224ba3de49b11c668248ce8232cff Mon Sep 17 00:00:00 2001 From: Alexander Opitz Date: Thu, 8 Aug 2013 12:43:16 +0200 Subject: [PATCH 7/7] Bug #20031: resort protected and public vars. --- VersionControl/SVN/Command.php | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/VersionControl/SVN/Command.php b/VersionControl/SVN/Command.php index bc6e3e8..2c74ee0 100755 --- a/VersionControl/SVN/Command.php +++ b/VersionControl/SVN/Command.php @@ -110,15 +110,6 @@ abstract class VersionControl_SVN_Command */ 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 - */ - protected $requiredSwitches = array(); - /** * Runtime options being used. * @@ -134,15 +125,6 @@ abstract class VersionControl_SVN_Command */ 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 - */ - protected $minArgs = 0; - /** * Preferred fetchmode. Note that not all subcommands have output available for * each preferred fetchmode. The default cascade is: @@ -198,6 +180,24 @@ abstract class VersionControl_SVN_Command */ 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. *