Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Bug 19465: username/password isn't handled like described in documentation #5

Merged
merged 4 commits into from about 2 years ago

2 participants

Alexander Opitz Michiel Rook
Alexander Opitz
opi99 commented
  • Bug 19465 - Add username/password as default option.
  • Bug 19465 - Add config-dir/config-option to default options.
  • Bug 19465 - Update documentation (as url and path are optional arguments and no default options).
  • Bug 18635 - Add Command changelist
  • Bug 19470 - Convert VersionControl_SVN_Comand_List::parseOutputArray into xml parser

Please close the bugs on pear.php.net as I've no rights for that.
Thanks Alex//

PS: I hope phing is compatible to my changes. :-)
PPS: Will fix Bug 19472 in the next days, afterwards it would be nice to get a 0.5.0 release, so I can release Xinc 2.2 :-)

https://pear.php.net/bugs/bug.php?id=19472

Michiel Rook mrook merged commit 26c051b into from
Michiel Rook mrook closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
15 SVN.php
@@ -239,17 +239,16 @@ public static function declareErrorMessages()
239 239 * <code>
240 240 *
241 241 * array(
242   - * 'url' => 'Subversion repository URL',
243 242 * 'username' => 'Subversion repository login',
244 243 * 'password' => 'Subversion repository password',
245   - * 'config_dir' => 'Path to a Subversion configuration directory',
  244 + * 'config-dir' => 'Path to a Subversion configuration directory',
246 245 * // [DEFAULT: null]
247   - * 'dry_run' => true/false,
248   - * // [DEFAULT: false]
249   - * 'encoding' => 'Language encoding to use for commit messages',
  246 + * 'config-option' => 'Set Subversion user configuration',
250 247 * // [DEFAULT: null]
251   - * 'svn_path' => 'Path to the svn client binary installed as part of Subversion',
  248 + * 'binaryPath' => 'Path to the svn client binary installed as part of Subversion',
252 249 * // [DEFAULT: /usr/local/bin/svn]
  250 + * 'fetchmode' => Type of returning of run function.
  251 + * // [DEFAULT: VERSIONCONTROL_SVN_FETCHMODE_ASSOC]
253 252 * )
254 253 *
255 254 * </code>
@@ -260,8 +259,6 @@ public static function declareErrorMessages()
260 259 * require_once 'VersionControl/SVN.php';
261 260 *
262 261 * $options = array(
263   - * 'url' => 'https://www.example.com/repos',
264   - * 'path' => 'your_project',
265 262 * 'username' => 'your_login',
266 263 * 'password' => 'your_password',
267 264 * );
@@ -269,7 +266,7 @@ public static function declareErrorMessages()
269 266 * // Run a log command
270 267 * $svn = VersionControl_SVN::factory('log', $options);
271 268 *
272   - * print_r($svn->run());
  269 + * print_r($svn->run(array('path_to_your_svn'));
273 270 * ?>
274 271 * </code>
275 272 *
50 SVN/Command.php
@@ -87,7 +87,7 @@
87 87 /**
88 88 * Location of the svn client binary installed as part of Subversion
89 89 *
90   - * @var string $binaryPath
  90 + * @var string $binaryPath
91 91 */
92 92 public $binaryPath = '/usr/local/bin/svn';
93 93
@@ -150,11 +150,39 @@
150 150 *
151 151 * If the specified fetchmode isn't available, raw output will be returned.
152 152 *
153   - * @var int
  153 + * @var int $fetchmode
154 154 */
155 155 public $fetchmode = VERSIONCONTROL_SVN_FETCHMODE_ASSOC;
156 156
157 157 /**
  158 + * Default username to use for connections.
  159 + *
  160 + * @var string $username
  161 + */
  162 + public $username = '';
  163 +
  164 + /**
  165 + * Default password to use for connections.
  166 + *
  167 + * @var string $password
  168 + */
  169 + public $password = '';
  170 +
  171 + /**
  172 + * Default config-dir to use for connections.
  173 + *
  174 + * @var string $configDir
  175 + */
  176 + public $configDir = '';
  177 +
  178 + /**
  179 + * Default config-option to use for connections.
  180 + *
  181 + * @var string $configOption
  182 + */
  183 + public $configOption = '';
  184 +
  185 + /**
158 186 * SVN subcommand to run.
159 187 *
160 188 * @var string $commandName
@@ -188,6 +216,8 @@
188 216 protected $validSwitchesValue = array(
189 217 'username',
190 218 'password',
  219 + 'config-dir',
  220 + 'config-option',
191 221 );
192 222
193 223 /**
@@ -197,8 +227,6 @@
197 227 'no-auth-cache',
198 228 'non-interactive',
199 229 'trust-server-cert',
200   - 'config-dir',
201   - 'config-option',
202 230 );
203 231
204 232 /**
@@ -339,6 +367,20 @@ protected function preProcessSwitches()
339 367 $this->switches['xml'] = true;
340 368 }
341 369 $this->switches['non-interactive'] = true;
  370 +
  371 + $this->fillSwitch('username', $this->username);
  372 + $this->fillSwitch('password', $this->password);
  373 + $this->fillSwitch('config-dir', $this->configDir);
  374 + $this->fillSwitch('config-option', $this->configOption);
  375 + }
  376 +
  377 + protected function fillSwitch($switchName, $value)
  378 + {
  379 + if (!isset($this->switches[$switchName])
  380 + && '' !== $value
  381 + ) {
  382 + $this->switches[$switchName] = $value;
  383 + }
342 384 }
343 385
344 386
91 SVN/Command/Changelist.php
... ... @@ -0,0 +1,91 @@
  1 +<?php
  2 +/* vim: set expandtab tabstop=4 shiftwidth=4: */
  3 +/**
  4 + * +----------------------------------------------------------------------+
  5 + * | This LICENSE is in the BSD license style. |
  6 + * | http://www.opensource.org/licenses/bsd-license.php |
  7 + * | |
  8 + * | Redistribution and use in source and binary forms, with or without |
  9 + * | modification, are permitted provided that the following conditions |
  10 + * | are met: |
  11 + * | |
  12 + * | * Redistributions of source code must retain the above copyright |
  13 + * | notice, this list of conditions and the following disclaimer. |
  14 + * | |
  15 + * | * Redistributions in binary form must reproduce the above |
  16 + * | copyright notice, this list of conditions and the following |
  17 + * | disclaimer in the documentation and/or other materials provided |
  18 + * | with the distribution. |
  19 + * | |
  20 + * | * Neither the name of Clay Loveless nor the names of contributors |
  21 + * | may be used to endorse or promote products derived from this |
  22 + * | software without specific prior written permission. |
  23 + * | |
  24 + * | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  25 + * | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  26 + * | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
  27 + * | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
  28 + * | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
  29 + * | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  30 + * | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
  31 + * | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
  32 + * | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  33 + * | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
  34 + * | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
  35 + * | POSSIBILITY OF SUCH DAMAGE. |
  36 + * +----------------------------------------------------------------------+
  37 + *
  38 + * PHP version 5
  39 + *
  40 + * @category VersionControl
  41 + * @package VersionControl_SVN
  42 + * @author Clay Loveless <clay@killersoft.com>
  43 + * @author Alexander Opitz <opitz.alexander@gmail.com>
  44 + * @copyright 2004-2007 Clay Loveless
  45 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  46 + * @link http://pear.php.net/package/VersionControl_SVN
  47 + */
  48 +
  49 +require_once 'VersionControl/SVN/Command.php';
  50 +
  51 +/**
  52 + * Subversion Changelist command manager class
  53 + *
  54 + * @category VersionControl
  55 + * @package VersionControl_SVN
  56 + * @author Clay Loveless <clay@killersoft.com>
  57 + * @author Alexander Opitz <opitz.alexander@gmail.com>
  58 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  59 + * @version @version@
  60 + * @link http://pear.php.net/package/VersionControl_SVN
  61 + */
  62 +class VersionControl_SVN_Command_Changelist extends VersionControl_SVN_Command
  63 +{
  64 + /**
  65 + * Constuctor of command. Adds available switches.
  66 + */
  67 + public function __construct()
  68 + {
  69 + parent::__construct();
  70 +
  71 + $this->validSwitchesValue = array_merge(
  72 + $this->validSwitchesValue,
  73 + array(
  74 + 'depth',
  75 + 'targets',
  76 + 'cl', 'changelist',
  77 + )
  78 + );
  79 +
  80 + $this->validSwitches = array_merge(
  81 + $this->validSwitches,
  82 + array(
  83 + 'q', 'quiet',
  84 + 'R', 'recursive',
  85 + 'remove',
  86 + )
  87 + );
  88 + }
  89 +}
  90 +
  91 +?>
96 SVN/Command/List.php
@@ -172,100 +172,6 @@ public function __construct()
172 172 )
173 173 );
174 174 }
175   -
176   - /**
177   - * Helper method for parseOutput that parses output into an associative or numbered array
178   - *
179   - * @param array $items Item list from the svn list command (already split into an array
180   - * by exec)
181   - * @return array
182   - * @access public
183   - */
184   - function parseOutputArray($items)
185   - {
186   - $parsed = array();
187   -
188   - // check switches for verbose output
189   - $verbose = false;
190   - if ((isset($this->switches['v']) && $this->switches['v'] === true) ||
191   - (isset($this->switches['verbose']) && $this->switches['verbose'] === true)) {
192   - $verbose = true;
193   - }
194   -
195   -
196   - if ($verbose) {
197   - // Must trim off verbose information PRIOR to natcasesort
198   - $path_items = array();
199   - $item_vdata = array();
200   - foreach ($items as $item) {
201   - // Regex should work with svn list's "%b %d %H:%M" and "%b %d %Y" date formats
202   - preg_match("/\s*(\d+) \s?(\S+)\s+(\d+)? (\w{3} +\d{2} +\d{2}:?\d{2}) (.*)/", $item, $matches);
203   - $path_items[] = $matches[5];
204   - $item_vdata[] = array(
205   - 'revision' => $matches[1],
206   - 'author' => $matches[2],
207   - 'size' => $matches[3],
208   - 'date' => $matches[4]
209   - );
210   - }
211   - $items = $path_items;
212   - }
213   - natcasesort($items);
214   -
215   - if ($this->fetchmode == VERSIONCONTROL_SVN_FETCHMODE_ASSOC) {
216   - $branch_arrays = array();
217   - foreach ($items as $key => $path) {
218   - $dir = dirname($path);
219   - $branches = explode('/', $path);
220   - $branch = array();
221   - $last = end($branches);
222   - $type = 'F';
223   - if ($last == '') {
224   - // Directories have an empty item in the last array slot
225   - $type = 'D';
226   - $name = prev($branches);
227   - }
228   - foreach ($branches as $leaf) {
229   - if ($leaf == $last) {
230   - if ($type == 'D') {
231   - $branch[$dir] = array('name' => array($name), 'type' => array($type));
232   - } else {
233   - $branch[$dir] = array('name' => array($leaf), 'type' => array($type));
234   - }
235   - } else {
236   - $branch[$dir] = array('name' => array($leaf), 'type' => array('D'));
237   - }
238   - if ($verbose) {
239   - $branch[$dir] = array_merge($branch[$dir], $item_vdata[$key]);
240   - }
241   - }
242   - $branch_arrays[] = $branch;
243   - }
244   -
245   - foreach ($branch_arrays as $branch) {
246   - $parsed = array_merge_recursive($parsed, $branch);
247   - }
248   - } else {
249   - foreach ($items as $key => $path) {
250   - $item = array();
251   - if (substr($path, -1) == '/') {
252   - $item['type'] = 'D';
253   - $path = substr($path, 0, -1);
254   - } else {
255   - $item['type'] = 'F';
256   - }
257   - $item['name'] = $path;
258   - if ($verbose) {
259   - $item = array_merge($item, $item_vdata[$key]);
260   - }
261   - $parsed[] = $item;
262   - }
263   - }
264   -
265   - return $parsed;
266   - }
267   -
268 175 }
269 176
270   -// }}
271   -?>
  177 +?>
122 SVN/Parsers/List.php
... ... @@ -0,0 +1,122 @@
  1 +<?php
  2 +/* vim: set expandtab tabstop=4 shiftwidth=4: */
  3 +/**
  4 + * VersionControl_SVN_Info allows for XML formatted output. XML_Parser is used to
  5 + * manipulate that output.
  6 + *
  7 + * +----------------------------------------------------------------------+
  8 + * | This LICENSE is in the BSD license style. |
  9 + * | http://www.opensource.org/licenses/bsd-license.php |
  10 + * | |
  11 + * | Redistribution and use in source and binary forms, with or without |
  12 + * | modification, are permitted provided that the following conditions |
  13 + * | are met: |
  14 + * | |
  15 + * | * Redistributions of source code must retain the above copyright |
  16 + * | notice, this list of conditions and the following disclaimer. |
  17 + * | |
  18 + * | * Redistributions in binary form must reproduce the above |
  19 + * | copyright notice, this list of conditions and the following |
  20 + * | disclaimer in the documentation and/or other materials provided |
  21 + * | with the distribution. |
  22 + * | |
  23 + * | * Neither the name of Clay Loveless nor the names of contributors |
  24 + * | may be used to endorse or promote products derived from this |
  25 + * | software without specific prior written permission. |
  26 + * | |
  27 + * | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
  28 + * | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
  29 + * | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
  30 + * | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
  31 + * | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
  32 + * | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  33 + * | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
  34 + * | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
  35 + * | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
  36 + * | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
  37 + * | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
  38 + * | POSSIBILITY OF SUCH DAMAGE. |
  39 + * +----------------------------------------------------------------------+
  40 + *
  41 + * PHP version 5
  42 + *
  43 + * @category VersionControl
  44 + * @package VersionControl_SVN
  45 + * @author Clay Loveless <clay@killersoft.com>
  46 + * @author Alexander Opitz <opitz.alexander@gmail.com>
  47 + * @copyright 2004-2007 Clay Loveless
  48 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  49 + * @link http://pear.php.net/package/VersionControl_SVN
  50 + */
  51 +
  52 + require_once 'XML/Parser.php';
  53 +
  54 +/**
  55 + * Class VersionControl_SVN_Parser_Info - XML Parser for Subversion Info output
  56 + *
  57 + * @category VersionControl
  58 + * @package VersionControl_SVN
  59 + * @author Clay Loveless <clay@killersoft.com>
  60 + * @author Alexander Opitz <opitz.alexander@gmail.com>
  61 + * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  62 + * @version @version@
  63 + * @link http://pear.php.net/package/VersionControl_SVN
  64 + */
  65 +class VersionControl_SVN_Parser_List extends XML_Parser
  66 +{
  67 + var $commit = array();
  68 + var $entry = array();
  69 + var $list = array();
  70 +
  71 + function startHandler($xp, $element, &$attribs)
  72 + {
  73 + switch ($element) {
  74 + case 'COMMIT':
  75 + $this->commit = array(
  76 + 'REVISION' => $attribs['REVISION']
  77 + );
  78 + break;
  79 + case 'ENTRY':
  80 + $this->entry = array(
  81 + 'KIND' => $attribs['KIND']
  82 + );
  83 + break;
  84 + case 'LIST':
  85 + $this->list = array();
  86 + break;
  87 + case 'NAME':
  88 + case 'AUTHOR':
  89 + case 'DATE':
  90 + case 'ROOT':
  91 + $this->cdata = '';
  92 + break;
  93 + }
  94 + }
  95 +
  96 + function cdataHandler($xp, $data)
  97 + {
  98 + $this->cdata .= $data;
  99 + }
  100 +
  101 + function endHandler($xp, $element)
  102 + {
  103 + switch($element) {
  104 + case 'COMMIT':
  105 + $this->entry['COMMIT'] = $this->commit;
  106 + break;
  107 + case 'ENTRY':
  108 + $this->list[] = $this->entry;
  109 + break;
  110 + case 'LIST':
  111 + break;
  112 + case 'AUTHOR':
  113 + case 'DATE':
  114 + $this->commit[$element] = $this->cdata;
  115 + break;
  116 + case 'NAME':
  117 + $this->entry[$element] = $this->cdata;
  118 + break;
  119 + }
  120 + }
  121 +}
  122 +?>

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.