| Crates.io | xml-3dm-cli |
| lib.rs | xml-3dm-cli |
| version | 0.1.0 |
| created_at | 2025-11-26 22:02:10.158924+00 |
| updated_at | 2025-11-26 22:02:10.158924+00 |
| description | 3DM XML Tree Differencing and Merging Tool CLI |
| homepage | https://github.com/06chaynes/3dm-rs |
| repository | https://github.com/06chaynes/3dm-rs |
| max_upload_size | |
| id | 1952451 |
| size | 20,972 |
A command-line tool for structure-aware XML differencing and 3-way merging.
tdm (Tree Diff/Merge) is a CLI tool that performs operations on XML documents:
The tool operates on XML tree structure and handles scenarios like moving and editing the same content.
cargo install --path .
cargo install xml-3dm-cli
Merge two branches that diverged from a common base:
tdm merge <BASE> <BRANCH1> <BRANCH2> [OUTPUT]
# Example
tdm merge original.xml alice-edits.xml bob-edits.xml merged.xml
# Short form
tdm m base.xml branch1.xml branch2.xml
Options:
-c, --copy-threshold <BYTES>: Minimum size for copy detection (default: 128)
Generate a diff showing changes from base to branch:
tdm diff <BASE> <BRANCH> [OUTPUT]
# Example
tdm diff original.xml modified.xml changes.xml
# Short form
tdm d base.xml branch.xml
The diff format uses XML with special copy and insert operations:
<?xml version="1.0" encoding="UTF-8"?>
<diff>
<diff:copy src="3" dst="1" />
<diff:insert dst="2">
<newElement>New content</newElement>
</diff:insert>
</diff>
Apply a diff to reconstruct the modified version:
tdm patch <BASE> <PATCHFILE> [OUTPUT]
# Example
tdm patch original.xml changes.xml reconstructed.xml
# Short form
tdm p base.xml patch.xml
Two reviewers edit a document independently:
# Alice moves a paragraph
# Bob fixes a typo in that paragraph
tdm merge original.xml alice-version.xml bob-version.xml result.xml
# Result: Paragraph is moved with the typo fixed
When changes cannot be automatically merged:
tdm merge base.xml branch1.xml branch2.xml merged.xml
# Output shows conflicts in stderr:
# CONFLICT: Conflicting updates at /document/section[2]/@title
# WARNING: Node deleted in one branch, modified in other
For faster merging on large documents:
tdm merge -c 0 base.xml branch1.xml branch2.xml merged.xml
# Generate diff
tdm diff original.xml modified.xml changes.xml
# Apply diff to reconstruct
tdm patch original.xml changes.xml reconstructed.xml
# Verify
diff modified.xml reconstructed.xml
# (should be identical)
0: Success (merge completed, possibly with warnings)1: Error (parse failure, I/O error, or unresolvable conflicts)Configure tdm as a Git merge driver:
# In .git/config or ~/.gitconfig
[merge "xml3dm"]
name = 3DM XML merge driver
driver = tdm merge %O %A %B %A
recursive = binary
# In .gitattributes
*.xml merge=xml3dm
Licensed under the GNU Lesser General Public License v2.1 or later (LGPL-2.1-or-later).
Based on the original 3DM tool by Tancred Lindholm (Helsinki University of Technology, 2001).
tdm --help
tdm merge --help
tdm diff --help
tdm patch --help