Skip to content

Commit 6aee4d4

Browse files
committed
Merged in [13109] from lars@netapp.com:
Rename crawl_history to make_rev_history, which is more descriptive. Fix ietf-tools#2224 (thanks, Robert!) by generating graphs for the entire revision history of a doc, both forward and backward in time. - Legacy-Id: 13140 Note: SVN reference [13109] has been migrated to Git commit e14dcda
2 parents 00d5ff8 + e14dcda commit 6aee4d4

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

ietf/doc/utils.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,19 +654,34 @@ def extract_complete_replaces_ancestor_mapping_for_docs(names):
654654
return replaces
655655

656656

657-
def crawl_history(doc):
657+
def make_rev_history(doc):
658658
# return document history data for inclusion in doc.json (used by timeline)
659+
660+
def get_predecessors(doc):
661+
predecessors = []
662+
if hasattr(doc, 'relateddocument_set'):
663+
for alias in doc.related_that_doc('replaces'):
664+
if alias.document not in predecessors:
665+
predecessors.append(alias.document)
666+
predecessors.extend(get_predecessors(alias.document))
667+
return predecessors
668+
659669
def get_ancestors(doc):
660670
ancestors = []
661671
if hasattr(doc, 'relateddocument_set'):
662-
for rel in doc.relateddocument_set.filter(relationship__slug='replaces'):
663-
if rel.target.document not in ancestors:
664-
ancestors.append(rel.target.document)
665-
ancestors.extend(get_ancestors(rel.target.document))
666-
return ancestors
672+
for alias in doc.related_that('replaces'):
673+
if alias.document not in ancestors:
674+
ancestors.append(alias.document)
675+
ancestors.extend(get_ancestors(alias.document))
676+
return ancestors
677+
678+
def get_replaces_tree(doc):
679+
tree = get_predecessors(doc)
680+
tree.extend(get_ancestors(doc))
681+
return tree
667682

668683
history = {}
669-
docs = get_ancestors(doc)
684+
docs = get_replaces_tree(doc)
670685
if docs is not None:
671686
docs.append(doc)
672687
for d in docs:

ietf/doc/views_doc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from ietf.doc.utils import ( add_links_in_new_revision_events, augment_events_with_revision,
5050
can_adopt_draft, get_chartering_type, get_document_content, get_tags_for_stream_id,
5151
needed_ballot_positions, nice_consensus, prettify_std_name, update_telechat, has_same_ballot,
52-
get_initial_notify, make_notify_changed_event, crawl_history, default_consensus,
52+
get_initial_notify, make_notify_changed_event, make_rev_history, default_consensus,
5353
add_events_message_info, get_unicode_document_content, build_doc_meta_block)
5454
from ietf.community.utils import augment_docs_with_tracking_info
5555
from ietf.group.models import Role
@@ -996,7 +996,7 @@ def extract_name(s):
996996
data["ad"] = doc.ad.role_email("ad").formatted_email() if doc.ad else None
997997

998998
latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")
999-
data["rev_history"] = crawl_history(latest_revision.doc if latest_revision else doc)
999+
data["rev_history"] = make_rev_history(latest_revision.doc if latest_revision else doc)
10001000

10011001
if doc.type_id == "draft":
10021002
data["iesg_state"] = extract_name(doc.get_state("draft-iesg"))

0 commit comments

Comments
 (0)