summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-24 17:19:32 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2012-02-28 16:01:20 +0100
commit8eb49978a2454c154e94588c9e0e53bcb110253d (patch)
tree64f60c6559b4aba07c0600590edc54de030b0235
parent63d549196a60549aaffea1511467be193969f390 (diff)
Resolves fdo#46074: Fix Partial::contains for paths that go past a leaf node
Paths that already "failed" at the root node were not reported as CONTAINS_NOT, so that they were erroneously migrated, but with broken content (values of set member properties were nil). Signed-off-by: Caolán McNamara <caolanm@redhat.com> Signed-off-by: Michael Meeks <michael.meeks@suse.com> Signed-off-by: Bjoern Michaelsen <bjoern.michaelsen@canonical.com>
-rw-r--r--configmgr/source/partial.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/configmgr/source/partial.cxx b/configmgr/source/partial.cxx
index 7922e2c7505a..088de36dc029 100644
--- a/configmgr/source/partial.cxx
+++ b/configmgr/source/partial.cxx
@@ -76,6 +76,12 @@ Partial::Partial(
std::set< rtl::OUString > const & includedPaths,
std::set< rtl::OUString > const & excludedPaths)
{
+ // The Partial::Node tree built up here encodes the following information:
+ // * Inner node, startInclude: an include starts here that contains excluded
+ // sub-trees
+ // * Inner node, !startInclude: contains in-/excluded sub-trees
+ // * Leaf node, startInclude: an include starts here
+ // * Leaf node, !startInclude: an exclude starts here
for (std::set< rtl::OUString >::const_iterator i(includedPaths.begin());
i != includedPaths.end(); ++i)
{
@@ -119,12 +125,19 @@ Partial::~Partial() {}
Partial::Containment Partial::contains(Path const & path) const {
//TODO: For set elements, the segment names recorded in the node tree need
// not match the corresponding path segments, so this function can fail.
+
+ // * If path ends at a leaf node or goes past a leaf node:
+ // ** If that leaf node is startInclude: => CONTAINS_NODE
+ // ** If that leaf node is !startInclude: => CONTAINS_NOT
+ // * If path ends at inner node:
+ // ** If there is some startInclude along its trace: => CONTAINS_NODE
+ // ** If there is no startInclude along its trace: => CONTAINS_SUBNODES
Node const * p = &root_;
bool includes = false;
for (Path::const_iterator i(path.begin()); i != path.end(); ++i) {
Node::Children::const_iterator j(p->children.find(*i));
if (j == p->children.end()) {
- break;
+ return p->startInclude ? CONTAINS_NODE : CONTAINS_NOT;
}
p = &j->second;
includes |= p->startInclude;