版本控制的未来:一个连贯的愿景
The Future of Version Control

原始链接: https://bramcohen.com/p/manyana

Manyana是一个新项目,展示了基于无冲突复制数据类型(CRDT)的版本控制未来。与容易出现复杂、不透明冲突的传统系统不同,Manyana确保合并*总是*成功,通过用信息性标记标出重叠的更改来解决冲突——清晰地显示*什么*更改以及*谁*做的。 这种方法提供了几个优势:永久行顺序、非阻塞冲突解决,以及编织到文件结构中的统一历史记录,无需复杂的共同祖先计算。值得注意的是,可以在不丢失历史上下文的情况下实现变基。 目前,Manyana是一个470行的Python演示,专注于单个文件,证明CRDTs可以克服用户体验挑战并提供卓越的版本控制体验。虽然诸如cherry-picking之类的功能尚未实现,但该项目的设计,详述于其README中,为下一代、功能齐全的版本控制系统提供了一个蓝图,并以公共领域许可证发布。

Bram Cohen 提出了一种新的版本控制方案,其灵感来源于他早期的 Codeville 项目(2000 年代初)。两种系统都使用“编织”(weave)来存储和合并——这一概念源自较早的版本控制系统,如 SCCS。 这种方法与无冲突复制数据类型 (CRDT) 相似,但 Cohen 的工作比 CRDT 早了近十年。虽然“编织”旨在实现比 Git 等系统更清晰的合并和更少的冲突,但由于创建全面的测试用例的难度,证明其明确的优势一直具有挑战性。 一位评论员指出 Cohen 持续致力于解决版本控制的复杂性,并探索该领域的创新解决方案。这场讨论凸显了长期以来改进现有版本控制方法论的努力。
相关文章

原文

I’m releasing Manyana, a project which I believe presents a coherent vision for the future of version control — and a compelling case for building it.

It’s based on the fundamentally sound approach of using CRDTs for version control, which is long overdue but hasn’t happened yet because of subtle UX issues. A CRDT merge always succeeds by definition, so there are no conflicts in the traditional sense — the key insight is that changes should be flagged as conflicting when they touch each other, giving you informative conflict presentation on top of a system which never actually fails. This project works that out.

One immediate benefit is much more informative conflict markers. Two people branch from a file containing a function. One deletes the function. The other adds a line in the middle of it. A traditional VCS gives you this:

<<<<<<< left
=======
def calculate(x):
    a = x * 2
    logger.debug(f"a={a}")
    b = a + 1
    return b
>>>>>>> right

Two opaque blobs. You have to mentally reconstruct what actually happened.

Manyana gives you this:

<<<<<<< begin deleted left
def calculate(x):
    a = x * 2
======= begin added right
    logger.debug(f"a={a}")
======= begin deleted left
    b = a + 1
    return b
>>>>>>> end conflict

Each section tells you what happened and who did it. Left deleted the function. Right added a line in the middle. You can see the structure of the conflict instead of staring at two blobs trying to figure it out.

CRDTs (Conflict-Free Replicated Data Types) give you eventual consistency: merges never fail, and the result is always the same no matter what order branches are merged in — including many branches mashed together by multiple people working independently. That one property turns out to have profound implications for every aspect of version control design.

Line ordering becomes permanent. When two branches insert code at the same point, the CRDT picks an ordering and it sticks. This prevents problems when conflicting sections are both kept but resolved in different orders on different branches.

Conflicts are informative, not blocking. The merge always produces a result. Conflicts are surfaced for review when concurrent edits happen “too near” each other, but they never block the merge itself. And because the algorithm tracks what each side did rather than just showing the two outcomes, the conflict presentation is genuinely useful.

History lives in the structure. The state is a weave — a single structure containing every line which has ever existed in the file, with metadata about when it was added and removed. This means merges don’t need to find a common ancestor or traverse the DAG. Two states go in, one state comes out, and it’s always correct.

One idea I’m particularly excited about: rebase doesn’t have to destroy history. Conventional rebase creates a fictional history where your commits happened on top of the latest main. In a CRDT system, you can get the same effect — replaying commits one at a time onto a new base — while keeping the full history. The only addition needed is a “primary ancestor” annotation in the DAG.

This matters because aggressive rebasing quickly produces merge topologies with no single common ancestor, which is exactly where traditional 3-way merge falls apart. CRDTs don’t care — the history is in the weave, not reconstructed from the DAG.

Manyana is a demo, not a full-blown version control system. It’s about 470 lines of Python which operate on individual files. Cherry-picking and local undo aren’t implemented yet, though the README lays out a vision for how those can be done well.

What it is is a proof that CRDT-based version control can handle the hard UX problems and come out with better answers than the tools we’re all using today — and a coherent design for building the real thing.

The code is public domain. The full design document is in the README.

联系我们 contact @ memedata.com