Skip to content

Feature: list revisions in every story, as accept, reject and compare already act on every story #165

Description

@hadim

A caller checking that no tracked change is left before releasing a file reads Document.revisions or
rdocx revision list. Both list main-story revisions only, as documented (the CLI says "no revisions in
main story"), so this is a request rather than a defect. compare() writes revisions into headers and
footers, and accept_all() / rdocx revision accept accept them there, so the listing says "none" while
the file still carries tracked changes, and the count reported by accept differs from the list.

import os, subprocess, sys, zipfile
import rdocx
from docx import Document

RDOCX = sys.argv[1] if len(sys.argv) > 1 else "rdocx"
d = Document(); d.add_paragraph("Body."); d.sections[0].footer.paragraphs[0].text = "Footer lorem ipsum"; d.save("rs_a.docx")
d = Document("rs_a.docx"); d.sections[0].footer.paragraphs[0].text = "Footer lorem IPSUM"; d.save("rs_b.docx")
for f in ("rs_red.docx", "rs_acc.docx"):
    if os.path.exists(f):
        os.remove(f)
subprocess.run([RDOCX, "compare", "rs_a.docx", "rs_b.docx", "--author", "R", "--timestamp", "2026-09-27T12:00:00Z", "-o", "rs_red.docx"], check=True, capture_output=True)
x = zipfile.ZipFile("rs_red.docx").read("word/footer1.xml")
print("footer1.xml of the redline: w:ins", x.count(b"<w:ins "), "w:del", x.count(b"<w:del "))
print("Document.revisions:", rdocx.Document.open("rs_red.docx").revisions)
print("rdocx revision list:", subprocess.run([RDOCX, "revision", "list", "rs_red.docx"], capture_output=True, text=True).stdout.strip())
print("rdocx revision accept:", subprocess.run([RDOCX, "revision", "accept", "rs_red.docx", "-o", "rs_acc.docx"], capture_output=True, text=True).stdout.strip().splitlines()[0])
footer1.xml of the redline: w:ins 1 w:del 1
Document.revisions: ()
rdocx revision list: (no revisions in main story)
rdocx revision accept: accept: 2 revision element(s)

rdocx compare --json has the same shape: "main_story_revisions": 0 next to
"scope": "all-supported-stories", and nothing about the footer. What would help: Revision carrying the
story it belongs to (as StoryItem already does), the listing covering every story compare() and accept
can reach, and the compare summary counting per story. The scope was recorded when revisions was bound
for #94 (PR #109: "a resolution count can be larger than the snapshot length"); this asks to widen the
listing to match.

Environment: main at 9a7ed714 (S75), release build, linux x86_64, python-docx 1.2.0 for the fixtures.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions