Index: tools/metrics/histograms/extract_histograms.py |
diff --git a/tools/metrics/histograms/extract_histograms.py b/tools/metrics/histograms/extract_histograms.py |
index 9cacd89d7f6306e36bfb3cd2e7bf0b1008cfc907..b8e49ad310e0a73b51870bf3f8d2693928cf87ed 100644 |
--- a/tools/metrics/histograms/extract_histograms.py |
+++ b/tools/metrics/histograms/extract_histograms.py |
@@ -291,6 +291,16 @@ def _ExtractHistogramsFromXmlTree(tree, enums): |
return histograms, have_errors |
+# Finds an <obsolete> node amongst |node|'s immediate children and returns its |
+# content as a string. Returns None if no such node exists. |
+def _GetObsoleteReason(node): |
+ for child in node.childNodes: |
+ if child.localName == 'obsolete': |
+ # There can be at most 1 obsolete element per node. |
+ return _JoinChildNodes(child) |
+ return None |
+ |
+ |
def _UpdateHistogramsWithSuffixes(tree, histograms): |
"""Process <histogram_suffixes> tags and combine with affected histograms. |
@@ -355,11 +365,9 @@ def _UpdateHistogramsWithSuffixes(tree, histograms): |
have_errors = True |
continue |
- obsolete_nodes = histogram_suffixes.getElementsByTagName('obsolete') |
- obsolete_reason = None |
- if obsolete_nodes: |
- # There can be at most 1 obsolete element per histogram_suffixes node |
- obsolete_reason = _JoinChildNodes(obsolete_nodes[0]) |
+ # If the suffix group has an obsolete tag, all suffixes it generates inherit |
+ # its reason. |
+ group_obsolete_reason = _GetObsoleteReason(histogram_suffixes) |
name = histogram_suffixes.getAttribute('name') |
suffix_nodes = histogram_suffixes.getElementsByTagName(suffix_tag) |
@@ -416,6 +424,13 @@ def _UpdateHistogramsWithSuffixes(tree, histograms): |
if owners: |
histograms[new_histogram_name]['owners'] = owners |
+ # If a suffix has an obsolete node, it's marked as obsolete for the |
+ # specified reason, overwriting its group's obsoletion reason if the |
+ # group itself was obsolete as well. |
+ obsolete_reason = _GetObsoleteReason(suffix) |
+ if not obsolete_reason: |
+ obsolete_reason = group_obsolete_reason |
+ |
# If the suffix has an obsolete tag, all histograms it generates |
# inherit it. |
if obsolete_reason: |