From 4f8a15f7a699d09e551bbfe9119ce086e73685b5 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 18 Nov 2007 11:21:29 +0000 Subject: [PATCH] Include inherited attributes when merging. When copying from a local feed in the form: The 'main' attribute wasn't copied. --- merge.py | 10 ++++++---- tests/testlocal.py | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/merge.py b/merge.py index 4c67f64..00d8632 100644 --- a/merge.py +++ b/merge.py @@ -132,14 +132,16 @@ def merge(data, local): xmltools.insert_element(req, group) new_impl = master_doc.importNode(impl, True) + + # Attributes might have been set on a parent group; move to the impl + for name in new_impl_context.attribs: + #print "Set", name, value + new_impl.setAttributeNS(name[0], name[1], new_impl_context.attribs[name]) + for name, value in new_impl.attributes.itemsNS(): if name in group_context.attribs and group_context.attribs[name] == value: #print "Deleting duplicate attribute", name, value new_impl.removeAttributeNS(name[0], name[1]) - else: - # Might have been on a parent group; move to the impl - #print "Set", name, value - new_impl.setAttributeNS(name[0], name[1], value) xmltools.insert_element(new_impl, group) diff --git a/tests/testlocal.py b/tests/testlocal.py index 92d7055..56fc1c3 100755 --- a/tests/testlocal.py +++ b/tests/testlocal.py @@ -97,6 +97,8 @@ class TestLocal(unittest.TestCase): assert master.implementations['sha1=004'].requires[0].metadata.get('meta', None) == 'foo' assert master.implementations['sha1=003'].requires[0].metadata.get('meta', None) == None + assert master.implementations['sha1=003'].main == 'hello' + def testMergeBest(self): master_xml = tap(merge.merge(header + """\n -- 2.11.4.GIT