Hello community, here is the log from the commit of package crmsh for openSUSE:Factory checked in at 2014-03-10 12:31:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/crmsh (Old) and /work/SRC/openSUSE:Factory/.crmsh.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "crmsh" Changes: -------- --- /work/SRC/openSUSE:Factory/crmsh/crmsh.changes 2014-03-07 07:04:40.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.crmsh.new/crmsh.changes 2014-03-10 12:31:24.000000000 +0100 @@ -1,0 +2,6 @@ +Sat Mar 8 20:03:30 UTC 2014 - [email protected] + +- high: xmlutil: Improved XML comparison function (bnc#866434) +- upstream cs: 4bb659cf287e + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ crmsh.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/.hg_archival.txt new/crmsh/.hg_archival.txt --- old/crmsh/.hg_archival.txt 2014-03-06 17:19:54.000000000 +0100 +++ new/crmsh/.hg_archival.txt 2014-03-08 14:13:37.000000000 +0100 @@ -1,5 +1,5 @@ repo: 13c3bd69e935090cd25213c474cafc3f01b5910b -node: dad87af7e64ba415b13edce29dceb53747139720 +node: 4bb659cf287e386310ecb8894f2c4f5ab95755d4 branch: default latesttag: 1.2.6-rc1 -latesttagdistance: 457 +latesttagdistance: 462 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/cibconfig.py new/crmsh/modules/cibconfig.py --- old/crmsh/modules/cibconfig.py 2014-03-06 17:19:54.000000000 +0100 +++ new/crmsh/modules/cibconfig.py 2014-03-08 14:13:37.000000000 +0100 @@ -53,7 +53,7 @@ from xmlutil import remove_id_used_attributes, get_top_cib_nodes, set_id_used_attr from xmlutil import merge_attributes, is_cib_element, sanity_check_meta, add_missing_attr from xmlutil import is_simpleconstraint, is_template, rmnode, is_defaults, is_live_cib -from xmlutil import get_rsc_operations, delete_rscref, xml_cmp, lookup_node, RscState +from xmlutil import get_rsc_operations, delete_rscref, xml_equals, lookup_node, RscState from xmlutil import cibtext2elem from cliformat import get_score, nvpairs2list, abs_pos_score, cli_acl_roleref, nvpair_format from cliformat import cli_acl_rule, cli_pairs, rsc_set_constraint, get_kind @@ -410,15 +410,15 @@ not_allowed = id_set & self.locked_ids rscstat = RscState() if not_allowed: - common_err("elements %s already exist" % - ','.join(list(not_allowed))) + common_err("Elements %s already exist" % + ', '.join(list(not_allowed))) rc = False delete_set = self.obj_ids - id_set cannot_delete = [x for x in delete_set if not rscstat.can_delete(x)] if cannot_delete: - common_err("cannot delete running resources: %s" % - ','.join(cannot_delete)) + common_err("Cannot delete running resources: %s" % + ', '.join(cannot_delete)) rc = False return rc @@ -526,6 +526,7 @@ return rc mk_set = id_set - self.obj_ids upd_set = id_set & self.obj_ids + rc = cib_factory.set_update(edit_d, mk_set, upd_set, del_set, upd_type="cli", method=method) if not rc: @@ -1110,8 +1111,7 @@ xml2 = self.cli2node(cli_text) if xml2 is None: return False - rc = xml_cmp(self.node, xml2, show=True) - return rc + return xml_equals(self.node, xml2, show=True) def _verify_op_attributes(self, op_node): ''' @@ -3098,7 +3098,7 @@ id_store.replace_xml(newnode, obj.node) return False oldnode = obj.node - if xml_cmp(oldnode, newnode): + if xml_equals(oldnode, newnode): if newnode.getparent() is not None: newnode.getparent().remove(newnode) return True # the new and the old versions are equal @@ -3140,20 +3140,25 @@ for cli in processing_sort_cli([edit_d[x] for x in mk_set]): obj = self.create_from_cli(cli) if not obj: + common_debug("create_from_cli '%s' failed" % (cli)) return False test_l.append(obj) for id in upd_set: obj = self.find_object(id) if not obj: + common_debug("%s not found!" % (id)) return False if not self.update_from_cli(obj, edit_d[id], method): + common_debug("update_from_cli failed: %s, %s, %s" % (obj, edit_d[id], method)) return False test_l.append(obj) if not self.delete(*list(del_set)): + common_debug("delete %s failed" % (list(del_set))) return False rc = True for obj in test_l: if not self.test_element(obj): + common_debug("test_element failed for %s" % (obj)) rc = False return rc & self.check_structure() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crmsh/modules/xmlutil.py new/crmsh/modules/xmlutil.py --- old/crmsh/modules/xmlutil.py 2014-03-06 17:19:54.000000000 +0100 +++ new/crmsh/modules/xmlutil.py 2014-03-08 14:13:37.000000000 +0100 @@ -1281,26 +1281,20 @@ checker = doctestcompare.LXMLOutputChecker() -def xml_cmp_unordered(a, b): - "used by xml_cmp to compare xml trees without ordering" +def xml_equals_unordered(a, b): + "used by xml_equals to compare xml trees without ordering" def fail(msg): common_debug("%s!=%s: %s" % (a.tag, b.tag, msg)) return False def tagflat(x): - if isinstance(x.tag, basestring): - return x.tag - return x.text - - def sorter(a, b): - return cmp('|'.join([tagflat(a), str(a.attrib)]), - '|'.join([tagflat(b), str(b.attrib)])) + return isinstance(x.tag, basestring) and x.tag or x.text + + def sortby(v): + return tagflat(v) + ''.join(sorted(v.attrib.keys())) def safe_strip(text): - "strip which handles None by returning ''" - if text is None: - return '' - return text.strip() + return text is not None and text.strip() or '' if a.tag != b.tag: return fail("tags differ: %s != %s" % (a.tag, b.tag)) @@ -1312,11 +1306,13 @@ return fail("tails differ: %s != %s" % (a.tail, b.tail)) if len(a) != len(b): return fail("number of children differ") - return not any(not xml_cmp_unordered(a, b) for a, b in - zip(sorted(a, sorter), sorted(b, sorter))) + sorted_children = zip(sorted(a, key=sortby), sorted(b, key=sortby)) + if sorted_children: + return all(xml_equals_unordered(a, b) for a, b in sorted_children) + return True -def xml_cmp(n, m, show=False): +def xml_equals(n, m, show=False): if n.tag in xml_hash_d: n_hash_l = xml_hash_d[n.tag](n) m_hash_l = xml_hash_d[n.tag](m) @@ -1328,7 +1324,7 @@ rc = False else: #rc = checker.compare_docs(n, m) - rc = xml_cmp_unordered(n, m) + rc = xml_equals_unordered(n, m) if not rc and show and config.core.debug: # somewhat strange, but that's how this works from doctest import Example -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
