Author: jkupec Date: Sun Apr 13 14:15:55 2008 New Revision: 9587 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9587&view=rev Log: - allow to specify repo list in init_repos() Modified: trunk/zypper/src/zypper-repos.cc trunk/zypper/src/zypper-repos.h Modified: trunk/zypper/src/zypper-repos.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.cc?rev=9587&r1=9586&r2=9587&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.cc (original) +++ trunk/zypper/src/zypper-repos.cc Sun Apr 13 14:15:55 2008 @@ -371,7 +371,9 @@ * Fill gData.repositories with active repos (enabled or specified) and refresh * if autorefresh is on. */ -static void do_init_repos(Zypper & zypper) + +template <class Container> +static void do_init_repos(Zypper & zypper, const Container & container) { MIL << "Going to initialize repositories." << endl; @@ -379,14 +381,19 @@ init_target(zypper); RepoManager manager(zypper.globalOpts().rm_options); - // get repositories specified with --repo or --catalog + // get repositories specified with --repo or --catalog or in the container + list<string> not_found; parsed_opts::const_iterator it; + // --repo if ((it = copts.find("repo")) != copts.end()) get_repos(zypper, it->second.begin(), it->second.end(), gData.repos, not_found); - // rug compatibility + // --catalog - rug compatibility if ((it = copts.find("catalog")) != copts.end()) get_repos(zypper, it->second.begin(), it->second.end(), gData.repos, not_found); + // container + if (!container.empty()) + get_repos(zypper, container.begin(), container.end(), gData.repos, not_found); if (!not_found.empty()) { report_unknown_repos(zypper.out(), not_found); @@ -503,7 +510,8 @@ // ---------------------------------------------------------------------------- -void init_repos(Zypper & zypper) +template <typename Container> +void init_repos(Zypper & zypper, const Container & container) { static bool done = false; //! \todo this has to be done so that it works in zypper shell @@ -511,7 +519,7 @@ return; if ( !zypper.globalOpts().disable_system_sources ) - do_init_repos(zypper); + do_init_repos(zypper, container); done = true; } Modified: trunk/zypper/src/zypper-repos.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/zypper/src/zypper-repos.h?rev=9587&r1=9586&r2=9587&view=diff ============================================================================== --- trunk/zypper/src/zypper-repos.h (original) +++ trunk/zypper/src/zypper-repos.h Sun Apr 13 14:15:55 2008 @@ -16,6 +16,15 @@ void init_target(Zypper & zypper); /** + * The same as \ref init_repos(), but allows to specify repos to initialize. + * + * \param zypper The zypper instance. + * \param container A string container of identifier (alias|#|URI) to init. + */ +template <typename Container> +void init_repos(Zypper & zypper, const Container & container = Container()); + +/** * Reads known enabled repositories and stores them in gData. * This command also refreshes repos with auto-refresh enabled. * @@ -23,7 +32,9 @@ * - ZYPPER_EXIT_ERR_INVALID_ARGS if --repo does not specify a valid repository, * - ZYPPER_EXIT_ERR_ZYPP on error */ -void init_repos(Zypper & zypper); +void init_repos(Zypper & zypper) +{ init_repos(zypper, std::vectorstd::string()); } + /** * List defined repositories. -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org