aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Brett Witherspoon <spoonb@exherbo.org> 2011-02-08 20:02:21 -0600
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2011-02-19 13:01:33 +0000
commitf5d65636d94446685ce18063a93533c80268c18e (patch)
tree002d657dc81024ed8a6600f7bcaa3230a104ebae
parent90ce30774e0fd3e30ad2258b8e0709dec665f052 (diff)
downloadpaludis-f5d65636d94446685ce18063a93533c80268c18e.tar.gz
paludis-f5d65636d94446685ce18063a93533c80268c18e.tar.xz
support multiple versions per slot line in unwritten
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_TEST.cc30
-rwxr-xr-xpaludis/repositories/unwritten/unwritten_repository_TEST_setup.sh15
-rw-r--r--paludis/repositories/unwritten/unwritten_repository_file.cc49
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 408099a..2d9aa17 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 820c61c..dec5f75 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 c1fc8e9..33ecfae 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>;