Author: dmacvicar Date: Wed Jul 18 14:17:48 2007 New Revision: 6062 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6062&view=rev Log: - allow / in aliases (#292628) Modified: trunk/libzypp/package/libzypp.changes trunk/libzypp/tests/zypp/RepoManager_test.cc trunk/libzypp/zypp/RepoManager.cc Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=6062&r1=6061&r2=6062&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Wed Jul 18 14:17:48 2007 @@ -7,6 +7,11 @@ - revision 6058 ------------------------------------------------------------------- +Wed Jul 18 14:16:59 CEST 2007 - duncan@suse.de + +- allow / in alias (#292628) + +------------------------------------------------------------------- Tue Jul 17 15:57:03 CEST 2007 - ma@suse.de - Fixed OnMediLocation to use safe defaults. Added setLocaltion and Modified: trunk/libzypp/tests/zypp/RepoManager_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/RepoManager_test.cc?rev=6062&r1=6061&r2=6062&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/RepoManager_test.cc (original) +++ trunk/libzypp/tests/zypp/RepoManager_test.cc Wed Jul 18 14:17:48 2007 @@ -62,6 +62,10 @@ repos = manager.knownRepositories(); BOOST_CHECK_EQUAL(repos.size(), (unsigned) 6); + RepoInfo office_dup; + office_dup.setAlias("office"); + BOOST_CHECK_THROW(manager.addRepository(office_dup), RepoAlreadyExistsException); + // delete the office repo inside the propietary_1.repo RepoInfo office; office.setAlias("office"); Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=6062&r1=6061&r2=6062&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Wed Jul 18 14:17:48 2007 @@ -682,6 +682,33 @@ //////////////////////////////////////////////////////////////////////////// + /** + * \short Generate a related filename from a repo info + * + * From a repo info, it will try to use the alias as a filename + * escaping it if necessary. Other fallbacks can be added to + * this function in case there is no way to use the alias + */ + static std::string generate_filename( const RepoInfo &info ) + { + std::string fnd="/"; + std::string rep="_"; + std::string filename = info.alias(); + // replace slashes with underscores + size_t pos = filename.find(fnd); + while(pos!=string::npos) + { + filename.replace(pos,fnd.length(),rep); + pos = filename.find(fnd,pos+rep.length()); + } + filename = Pathname(filename).extend(".repo").asString(); + MIL << "generating filename for repo [" << info.alias() << "] : '" << filename << "'" << endl; + return filename; + } + + + //////////////////////////////////////////////////////////////////////////// + void RepoManager::addRepository( const RepoInfo &info, const ProgressData::ReceiverFnc & progressrcv ) { @@ -708,7 +735,7 @@ filesystem::assert_dir(_pimpl->options.knownReposPath); Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath, - Pathname(info.alias()).extend(".repo").asString()); + generate_filename(info)); // now we have a filename that does not exists MIL << "Saving repo in " << repofile << endl; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org