cvs: pear-core /PEAR Command.php /PEAR/Command Channels.php Common.php Config.php Registry.php Remote.php /scripts pearcmd.php /tests
phpt_test.php.inc

From: Date: Fri, 26 Nov 2004 19:33:53 +0000
Subject: cvs: pear-core /PEAR Command.php /PEAR/Command Channels.php Common.php Config.php Registry.php Remote.php /scripts pearcmd.php /tests
phpt_test.php.inc
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-cvs+get-26528@lists.php.net to get a copy of this message
cellog Fri Nov 26 14:33:53 2004 EDT Modified files: /pear-core/PEAR Command.php /pear-core/PEAR/Command Channels.php Common.php Config.php Registry.php Remote.php /pear-core/scripts pearcmd.php /pear-core/tests phpt_test.php.inc Log: fix erroneous reset in PEAR_Command_Common fix duplicate short opts add \n in assertEquals add beginnings of dry run for pear add checks in PEAR_Command::registerCommand() for both duplicate commands and duplicate shortcuts

http://cvs.php.net/diff.php/pear-core/PEAR/Command.php?r1=1.25&r2=1.26&ty=u Index: pear-core/PEAR/Command.php diff -u pear-core/PEAR/Command.php:1.25 pear-core/PEAR/Command.php:1.26 --- pear-core/PEAR/Command.php:1.25 Fri Nov 26 01:23:07 2004 +++ pear-core/PEAR/Command.php Fri Nov 26 14:33:53 2004 @@ -16,7 +16,7 @@ // | Author: Stig Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Command.php,v 1.25 2004/11/26 06:23:07 cellog Exp $ +// $Id: Command.php,v 1.26 2004/11/26 19:33:53 cellog Exp $ require_once "PEAR.php"; @@ -272,11 +272,20 @@ } $implements = $GLOBALS['_PEAR_Command_objects'][$class]->getCommands(); foreach ($implements as $command => $desc) { + if (isset($GLOBALS['_PEAR_Command_commandlist'][$command])) { + return PEAR::raiseError('Command "' . $command . '" already registered in ' . + 'class "' . $GLOBALS['_PEAR_Command_commandlist'][$command] . '"'); + } $GLOBALS['_PEAR_Command_commandlist'][$command] = $class; $GLOBALS['_PEAR_Command_commanddesc'][$command] = $desc; } $shortcuts = $GLOBALS['_PEAR_Command_objects'][$class]->getShortcuts(); foreach ($shortcuts as $shortcut => $command) { + if (isset($GLOBALS['_PEAR_Command_shortcuts'][$shortcut])) { + return PEAR::raiseError('Command shortcut "' . $shortcut . '" already ' . + 'registered to command "' . $command . '" in class "' . + $GLOBALS['_PEAR_Command_commandlist'][$command] . '"'); + } $GLOBALS['_PEAR_Command_shortcuts'][$shortcut] = $command; } } http://cvs.php.net/diff.php/pear-core/PEAR/Command/Channels.php?r1=1.9&r2=1.10&ty=u Index: pear-core/PEAR/Command/Channels.php diff -u pear-core/PEAR/Command/Channels.php:1.9 pear-core/PEAR/Command/Channels.php:1.10 --- pear-core/PEAR/Command/Channels.php:1.9 Tue Nov 16 23:19:10 2004 +++ pear-core/PEAR/Command/Channels.php Fri Nov 26 14:33:53 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Channels.php,v 1.9 2004/11/17 04:19:10 cellog Exp $ +// $Id: Channels.php,v 1.10 2004/11/26 19:33:53 cellog Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Registry.php'; @@ -49,7 +49,7 @@ 'channel-delete' => array( 'summary' => 'Remove a Channel From the List', 'function' => 'doDelete', - 'shortcut' => 'cd', + 'shortcut' => 'cde', 'options' => array(), 'doc' => '<channel name> Delete a channel from the registry. You may not http://cvs.php.net/diff.php/pear-core/PEAR/Command/Common.php?r1=1.25&r2=1.26&ty=u Index: pear-core/PEAR/Command/Common.php diff -u pear-core/PEAR/Command/Common.php:1.25 pear-core/PEAR/Command/Common.php:1.26 --- pear-core/PEAR/Command/Common.php:1.25 Sun Jul 4 00:25:08 2004 +++ pear-core/PEAR/Command/Common.php Fri Nov 26 14:33:53 2004 @@ -16,7 +16,7 @@ // | Author: Stig Sæther Bakken <ssb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Common.php,v 1.25 2004/07/04 04:25:08 cellog Exp $ +// $Id: Common.php,v 1.26 2004/11/26 19:33:53 cellog Exp $ require_once "PEAR.php"; @@ -132,10 +132,10 @@ { $short_args = ""; $long_args = array(); - if (empty($this->commands[$command])) { + if (empty($this->commands[$command]) || empty($this->commands[$command]['options'])) { return; } - reset($this->commands[$command]); + reset($this->commands[$command]['options']); while (list($option, $info) = each($this->commands[$command]['options'])) { $larg = $sarg = ''; if (isset($info['arg'])) { http://cvs.php.net/diff.php/pear-core/PEAR/Command/Config.php?r1=1.33&r2=1.34&ty=u Index: pear-core/PEAR/Command/Config.php diff -u pear-core/PEAR/Command/Config.php:1.33 pear-core/PEAR/Command/Config.php:1.34 --- pear-core/PEAR/Command/Config.php:1.33 Wed Nov 24 16:32:43 2004 +++ pear-core/PEAR/Command/Config.php Fri Nov 26 14:33:53 2004 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Config.php,v 1.33 2004/11/24 21:32:43 cellog Exp $ +// $Id: Config.php,v 1.34 2004/11/26 19:33:53 cellog Exp $ require_once "PEAR/Command/Common.php"; require_once "PEAR/Config.php"; @@ -107,7 +107,7 @@ 'config-create' => array( 'summary' => 'Create a Default configuration file', 'function' => 'doConfigCreate', - 'shortcut' => 'cc', + 'shortcut' => 'coc', 'options' => array(), 'doc' => '<root path> <filename> Create a default configuration file with all directory configuration http://cvs.php.net/diff.php/pear-core/PEAR/Command/Registry.php?r1=1.48&r2=1.49&ty=u Index: pear-core/PEAR/Command/Registry.php diff -u pear-core/PEAR/Command/Registry.php:1.48 pear-core/PEAR/Command/Registry.php:1.49 --- pear-core/PEAR/Command/Registry.php:1.48 Mon Nov 15 17:11:56 2004 +++ pear-core/PEAR/Command/Registry.php Fri Nov 26 14:33:53 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Registry.php,v 1.48 2004/11/15 22:11:56 cellog Exp $ +// $Id: Registry.php,v 1.49 2004/11/26 19:33:53 cellog Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Registry.php'; @@ -48,7 +48,7 @@ 'list-installed' => array( 'summary' => 'List All Installed Packages In All Channels', 'function' => 'doListAll', - 'shortcut' => 'la', + 'shortcut' => 'lin', 'options' => array(), 'doc' => ' List all installed packages in all channels. http://cvs.php.net/diff.php/pear-core/PEAR/Command/Remote.php?r1=1.47&r2=1.48&ty=u Index: pear-core/PEAR/Command/Remote.php diff -u pear-core/PEAR/Command/Remote.php:1.47 pear-core/PEAR/Command/Remote.php:1.48 --- pear-core/PEAR/Command/Remote.php:1.47 Mon Nov 15 17:11:56 2004 +++ pear-core/PEAR/Command/Remote.php Fri Nov 26 14:33:53 2004 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: Remote.php,v 1.47 2004/11/15 22:11:56 cellog Exp $ +// $Id: Remote.php,v 1.48 2004/11/26 19:33:53 cellog Exp $ require_once 'PEAR/Command/Common.php'; require_once 'PEAR/Common.php'; @@ -41,14 +41,7 @@ 'summary' => 'List Available Upgrades', 'function' => 'doListUpgrades', 'shortcut' => 'lu', - 'options' => array( - 'channel' => - array( - 'shortopt' => 'c', - 'doc' => 'specify a channel other than the default channel', - 'arg' => 'CHAN', - ) - ), + 'options' => array(), 'doc' => '[preferred_state] List releases on the server of packages you have installed where a newer version is available with the same release state (stable etc.) @@ -419,71 +412,67 @@ function doListUpgrades($command, $options, $params) { - include_once "PEAR/Registry.php"; $savechannel = $channel = $this->config->get('default_channel'); - if (isset($options['channel'])) { - $reg = &$this->config->getRegistry(); - $channel = $options['channel']; - if ($reg->channelExists($channel)) { - $this->config->set('default_channel', $channel); - } else { - return $this->raiseError("Channel '$channel' does not exist"); - } - } - $remote = &$this->config->getRemote(); $reg = &$this->config->getRegistry(); - if (empty($params[1])) { - $state = $this->config->get('preferred_state'); - } else { - $state = $params[1]; - } - $caption = 'Available Upgrades'; - if (empty($state) || $state == 'any') { - $latest = $remote->call("package.listLatestReleases"); - } else { - $latest = $remote->call("package.listLatestReleases", $state); - $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')'; - } - $caption .= ':'; - if (PEAR::isError($latest)) { - $this->config->set('default_channel', $savechannel); - return $latest; - } - $inst = array_flip($reg->listPackages($channel)); - $data = array( - 'caption' => $caption, - 'border' => 1, - 'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'), - ); - foreach ((array)$latest as $pkg => $info) { - $package = strtolower($pkg); - if (!isset($inst[$package])) { - // skip packages we don't have installed + foreach ($reg->listChannels() as $channel) { + if ($channel == '__uri') { continue; } - extract($info); - $pkginfo = $reg->packageInfo($package, null, $channel); - $inst_version = $pkginfo['version']; - $inst_state = $pkginfo['release_state']; - if (version_compare("$version", "$inst_version", "le")) { - // installed version is up-to-date - continue; + $this->config->set('default_channel', $channel); + $remote = &$this->config->getRemote(); + if (empty($params[1])) { + $state = $this->config->get('preferred_state'); + } else { + $state = $params[1]; } - if ($filesize >= 20480) { - $filesize += 1024 - ($filesize % 1024); - $fs = sprintf("%dkB", $filesize / 1024); - } elseif ($filesize > 0) { - $filesize += 103 - ($filesize % 103); - $fs = sprintf("%.1fkB", $filesize / 1024.0); + $caption = $channel . ' Available Upgrades'; + if (empty($state) || $state == 'any') { + $latest = $remote->call("package.listLatestReleases"); } else { - $fs = " -"; // XXX center instead + $latest = $remote->call("package.listLatestReleases", $state); + $caption .= ' (' . implode(', ', PEAR_Common::betterStates($state, true)) . ')'; + } + $caption .= ':'; + if (PEAR::isError($latest)) { + $this->config->set('default_channel', $savechannel); + return $latest; + } + $inst = array_flip($reg->listPackages($channel)); + $data = array( + 'caption' => $caption, + 'border' => 1, + 'headline' => array('Channel', 'Package', 'Local', 'Remote', 'Size'), + ); + foreach ((array)$latest as $pkg => $info) { + $package = strtolower($pkg); + if (!isset($inst[$package])) { + // skip packages we don't have installed + continue; + } + extract($info); + $pkginfo = $reg->packageInfo($package, null, $channel); + $inst_version = $pkginfo['version']; + $inst_state = $pkginfo['release_state']; + if (version_compare("$version", "$inst_version", "le")) { + // installed version is up-to-date + continue; + } + if ($filesize >= 20480) { + $filesize += 1024 - ($filesize % 1024); + $fs = sprintf("%dkB", $filesize / 1024); + } elseif ($filesize > 0) { + $filesize += 103 - ($filesize % 103); + $fs = sprintf("%.1fkB", $filesize / 1024.0); + } else { + $fs = " -"; // XXX center instead + } + $data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs); + } + if (empty($data['data'])) { + $this->ui->outputData('No upgrades available'); + } else { + $this->ui->outputData($data, $command); } - $data['data'][] = array($channel, $pkg, "$inst_version ($inst_state)", "$version ($state)", $fs); - } - if (empty($data['data'])) { - $this->ui->outputData('No upgrades available'); - } else { - $this->ui->outputData($data, $command); } $this->config->set('default_channel', $savechannel); return true; http://cvs.php.net/diff.php/pear-core/scripts/pearcmd.php?r1=1.15&r2=1.16&ty=u Index: pear-core/scripts/pearcmd.php diff -u pear-core/scripts/pearcmd.php:1.15 pear-core/scripts/pearcmd.php:1.16 --- pear-core/scripts/pearcmd.php:1.15 Sun Oct 31 14:27:47 2004 +++ pear-core/scripts/pearcmd.php Fri Nov 26 14:33:53 2004 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: pearcmd.php,v 1.15 2004/10/31 19:27:47 cellog Exp $ +// $Id: pearcmd.php,v 1.16 2004/11/26 19:33:53 cellog Exp $ ob_end_clean(); /** @@ -26,6 +26,10 @@ */ if ('@include_path@' != '@'.'include_path'.'@') { ini_set('include_path', '@include_path@'); + $raw = false; +} else { + // this is a raw, uninstalled pear, either a cvs checkout, or php distro + $raw = true; } ini_set('allow_url_fopen', true); if (!ini_get('safe_mode')) { @@ -38,8 +42,12 @@ set_error_handler('error_handler'); $pear_package_version = "@pear_version@"; +if ($raw) { + $pear_package_version = '1.4.0a1'; +} require_once 'PEAR.php'; +require_once 'PEAR/Frontend.php'; require_once 'PEAR/Config.php'; require_once 'PEAR/Command.php'; require_once 'Console/Getopt.php'; @@ -102,6 +110,19 @@ $verbose = $config->get("verbose"); $cmdopts = array(); +if ($raw) { + if (!$config->isDefinedLayer('user') && !$config->isDefinedLayer('system')) { + $found = false; + foreach ($opts as $opt) { + if ($opt[0] == 'd' || $opt[0] == 'D') { + $found = true; // the user knows what they are doing, and are setting config values + } + } + if (!$found) { + // no prior runs, try to install PEAR + } + } +} foreach ($opts as $opt) { $param = !empty($opt[1]) ? $opt[1] : true; switch ($opt[0]) { @@ -165,7 +186,7 @@ $cmd = PEAR_Command::factory($command, $config); PEAR::popErrorHandling(); if (PEAR::isError($cmd)) { - usage(null, @$options[1][1]); + usage(null, @$options[1][0]); } $short_args = $long_args = null; @@ -222,6 +243,7 @@ $put = "Usage: $progname [options] command [command-options] <parameters>\n". "Type \"$progname help options\" to list all options.\n". + "Type \"$progname help shortcuts\" to list all command shortcuts.\n". "Type \"$progname help <command>\" to get the help for the specified command.\n". "Commands:\n"; $maxlen = max(array_map("strlen", $all_commands)); http://cvs.php.net/diff.php/pear-core/tests/phpt_test.php.inc?r1=1.7&r2=1.8&ty=u Index: pear-core/tests/phpt_test.php.inc diff -u pear-core/tests/phpt_test.php.inc:1.7 pear-core/tests/phpt_test.php.inc:1.8 --- pear-core/tests/phpt_test.php.inc:1.7 Sun Nov 21 22:24:51 2004 +++ pear-core/tests/phpt_test.php.inc Fri Nov 26 14:33:53 2004 @@ -264,6 +264,7 @@ var_export($control); echo "\nReceived:\n"; var_export($test); + echo "\n"; return false; } return true;
« previous php.pear.cvs (#26528) next »