skillfed

merge3

Python implementation of 3-way merge

merge3 v0.0.16 90.0K downloads/30d#13,621 on PyPI11
Copyleft license GPL-2.0-or-later Active released

What it is and what it does

merge3 is a pure-Python implementation of the 3-way merge algorithm used in version control systems. It takes three text sequences—a common base and two independent modifications—and produces a merged result that incorporates both changes. When changes conflict, it marks the conflicting regions with annotated conflict markers so you can see which branch contributed which lines.

The package works with sequences of lines (typically strings) rather than raw files, giving you control over how to split and process text. It can be used as a library from Python code or invoked as a command-line tool. With no external dependencies and support for modern Python versions, it's lightweight and straightforward to integrate into tools that need to resolve text merges programmatically.

Use it for:

  • Implement merge logic in a custom version control or document collaboration tool
  • Resolve text conflicts when merging branches in a non-Git workflow
  • Build a three-way diff viewer that shows how changes from two sources combine
  • Automate merging of configuration or data files from multiple sources
  • Test merge behavior in applications that handle concurrent text edits

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Implements 3-way merge of text sequences, combining changes from two independent branches against a common base to produce a merged result with conflict markers.

Yes, if you need 3-way merge logic and accept the GPL-2.0-or-later copyleft constraint. The package is actively maintained, has no dependencies, and works across modern Python versions. It's a solid choice for tools that must resolve text conflicts programmatically. No if your project cannot adopt copyleft licensing.

Install

merge3 on PyPI

pip

pip install merge3

uv

uv add merge3

poetry

poetry add merge3

Installing merge3

Before you install

Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent commits and broad Python version support from 3.9 through 3.14.

License in practice

GPL-2.0-or-later copyleft license: any derivative work or distribution must be released under compatible terms. Review your project's licensing model before integrating.

Quickstart

import merge3
m3 = merge3.Merge3(
    ['common\n', 'base\n'],
    ['common\n', 'a\n'],
    ['common\n', 'b\n']
)
result = list(m3.merge_annotated())

Requires Python 3.9 or later.

Verify before relying

  • Whether conflict markers are customizable or follow a fixed format
  • Performance characteristics on large text sequences or files
  • Whether the package handles binary data or is text-only

Package facts

License GPL-2.0-or-later (copyleft)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 303 days since the last release
Last repo commit
First released
Downloads 90,017/month — #13,621 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: merge3-0.0.16-py3-none-any.whl

Development Status :: 4 - BetaOperating System :: POSIXProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

3-way merge textmerge conflict resolutiondiff merge algorithmtext merge base other thisline-based mergemerge annotated outputversion control merge
merge-algorithmversion-controlconflict-resolution

More Text Processing packages