diff options
author | 2011-02-08 20:02:21 -0600 | |
---|---|---|
committer | 2011-02-19 13:01:33 +0000 | |
commit | f5d65636d94446685ce18063a93533c80268c18e (patch) | |
tree | 002d657dc81024ed8a6600f7bcaa3230a104ebae | |
parent | 90ce30774e0fd3e30ad2258b8e0709dec665f052 (diff) | |
download | paludis-f5d65636d94446685ce18063a93533c80268c18e.tar.gz paludis-f5d65636d94446685ce18063a93533c80268c18e.tar.xz |
support multiple versions per slot line in unwritten
3 files changed, 73 insertions, 21 deletions
diff --git a/paludis/repositories/unwritten/unwritten_repository_TEST.cc b/paludis/repositories/unwritten/unwritten_repository_TEST.cc index 408099abf..2d9aa17c5 100644 --- a/paludis/repositories/unwritten/unwritten_repository_TEST.cc +++ b/paludis/repositories/unwritten/unwritten_repository_TEST.cc @@ -30,6 +30,7 @@ #include <paludis/filtered_generator.hh> #include <paludis/filter.hh> #include <paludis/package_id.hh> +#include <paludis/metadata_key.hh> #include <paludis/package_database.hh> #include <test/test_framework.hh> #include <test/test_runner.hh> @@ -39,6 +40,14 @@ using namespace paludis; using namespace paludis::unwritten_repository; using namespace test; +namespace +{ + std::string visit(const PackageID & id) + { + return id.short_description_key()->value(); + } +} + namespace test_cases { struct UnwrittenRepositoryCreationTest : TestCase @@ -88,9 +97,30 @@ namespace test_cases "cat-one/pkg-one-1:0::unwritten " "cat-one/pkg-one-2:0::unwritten " "cat-one/pkg-one-3:0::unwritten " + "cat-one/pkg-three-1:1::unwritten " + "cat-one/pkg-three-2:1::unwritten " + "cat-one/pkg-three-3:1::unwritten " + "cat-one/pkg-three-4:2::unwritten " + "cat-one/pkg-three-5:2::unwritten " + "cat-one/pkg-three-6:2::unwritten " "cat-one/pkg-two-1:1::unwritten " "cat-one/pkg-two-2:2::unwritten" ); + + TEST_CHECK_EQUAL( + join(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), " ", visit), + "Description for pkg-one-1:0 " + "Description for pkg-one-2:0 " + "Description for pkg-one-3:0 " + "Description for pkg-three:1 " + "Description for pkg-three:1 " + "Description for pkg-three:1 " + "Description for pkg-three:2 " + "Description for pkg-three:2 " + "Description for pkg-three:2 " + "Description for pkg-two-1:1 " + "Description for pkg-two-2:2" + ); } } test_contents; } diff --git a/paludis/repositories/unwritten/unwritten_repository_TEST_setup.sh b/paludis/repositories/unwritten/unwritten_repository_TEST_setup.sh index 820c61c77..dec5f75bb 100755 --- a/paludis/repositories/unwritten/unwritten_repository_TEST_setup.sh +++ b/paludis/repositories/unwritten/unwritten_repository_TEST_setup.sh @@ -16,16 +16,21 @@ format = unwritten-1 cat-one/ pkg-one/ :0 1 - description = Monkey + description = Description for pkg-one-1:0 :0 2 - description = Monkey + description = Description for pkg-one-2:0 :0 3 - description = Monkey + description = Description for pkg-one-3:0 pkg-two/ :1 1 - description = Monkey + description = Description for pkg-two-1:1 :2 2 - description = Monkey + description = Description for pkg-two-2:2 + pkg-three/ + :1 1 2 3 + description = Description for pkg-three:1 + :2 4 5 6 + description = Description for pkg-three:2 END cd .. diff --git a/paludis/repositories/unwritten/unwritten_repository_file.cc b/paludis/repositories/unwritten/unwritten_repository_file.cc index c1fc8e9c2..33ecfae85 100644 --- a/paludis/repositories/unwritten/unwritten_repository_file.cc +++ b/paludis/repositories/unwritten/unwritten_repository_file.cc @@ -204,7 +204,7 @@ UnwrittenRepositoryFile::_load(const FSPath & f) CategoryNamePart category("x"); PackageNamePart package("x"); std::shared_ptr<MetadataValueKey<SlotName> > slot; - VersionSpec version("0", { }); + std::list<VersionSpec> versions; std::shared_ptr<UnwrittenRepositoryFileEntry> entry; while (std::getline(file, line)) { @@ -252,23 +252,33 @@ UnwrittenRepositoryFile::_load(const FSPath & f) { slot = std::make_shared<LiteralMetadataValueKey<SlotName>>("SLOT", "Slot", mkt_internal, SlotName(token)); - if (line_parser.consume( - (+simple_parser::any_except(" \t") >> token) - )) - version = VersionSpec(token, user_version_spec_options()); - else - throw UnwrittenRepositoryConfigurationError( - "Cannot parse body slot+version line '" + line + " in '" + stringify(f) + "'"); - - if (! line_parser.eof()) - throw UnwrittenRepositoryConfigurationError( - "Cannot parse body slot+version line '" + line + " in '" + stringify(f) + "'"); - if (entry) { - _imp->entries.push_back(*entry); + for (std::list<VersionSpec>::const_iterator v(versions.begin()), v_end(versions.end()) ; + v != v_end ; ++v) + { + entry->version() = *v; + _imp->entries.push_back(*entry); + } + versions.clear(); entry.reset(); } + + while (! line_parser.eof()) + { + if (line_parser.consume( + (+simple_parser::any_except(" \t") >> token) & + (*simple_parser::any_of(" \t")) + )) + versions.push_back(VersionSpec(token, user_version_spec_options())); + else + throw UnwrittenRepositoryConfigurationError( + "Cannot parse body slot+version line '" + line + " in '" + stringify(f) + "'"); + } + + if (versions.empty()) + throw UnwrittenRepositoryConfigurationError( + "Cannot parse body slot+version line '" + line + " in '" + stringify(f) + "'"); } else if (line_parser.consume( (+simple_parser::any_of(" \t")) & @@ -296,7 +306,7 @@ UnwrittenRepositoryFile::_load(const FSPath & f) n::removed_by() = std::shared_ptr<const MetadataValueKey<std::string> >(), n::removed_from() = std::shared_ptr<const MetadataCollectionKey<Set<std::string> > >(), n::slot() = slot, - n::version() = version + n::version() = VersionSpec("0", { }) )); if (token == "description") @@ -356,7 +366,14 @@ UnwrittenRepositoryFile::_load(const FSPath & f) } if (entry) - _imp->entries.push_back(*entry); + { + for (std::list<VersionSpec>::const_iterator v(versions.begin()), v_end(versions.end()) ; + v != v_end ; ++v) + { + entry->version() = *v; + _imp->entries.push_back(*entry); + } + } } template class Pimp<UnwrittenRepositoryFile>; |