git、mercurial、bazaar 源代码库的可理解性
我想阅读一种流行的版本控制工具的源代码,以了解版本控制的工作原理。我想读一本最具可读性的书。
我不知道对此有什么客观、定量的衡量标准,所以本着 WTFs/min 的精神漫画,我想问一下读过这些工具源码的人,你们估计每个项目有多少WTF/min?
I'd like to read the source code of one of the popular revision control tools to learn how revision control works. I'd like to read the one that is most readable.
I don't know of an objective, quantitative measure of this, so in the spirit of the WTFs/min comic, I'd like to ask those who have read the source codes of these tools, how many WTFs/min do you estimate each project has?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您很好地阅读了 C(以及一些 Perl 和 bash),那么 adymitruk 是对的。 Git 是一个不错的选择。
但是,如果您更熟悉 Python,请阅读 Mercurial 的源代码。许多WTF/分钟将来自于您对编写 DVCS 的语言和风格的熟悉程度。Git 是用 C、Perl 和 Bourne shell 编写的,Mercurial 是 Python(带有一点 C IIRC),并且Bzr 是用 Python、Pyrex 和 C 编写的。
您还需要考虑您选择的工具是什么。如果您使用 Git,您将了解每个文件正在实现什么。 Mercurial 或 Bzr 也是如此。
基本上,在选择使用(或学习)什么工具或语言时,一个好的公理是:遵循您所知道的。您正在尝试学习如何实现 DVCS,而不是如何使用特定的系统或语言:)
If you read C well (and some Perl and bash too), adymitruk is right. Git is a good choice.
However, if you're more comfortable with Python, read Mercurial's source. Many of the WTFs/min are going to come from your familiarity with the language and style that the DVCS is written in. Git is written in C, Perl, and Bourne shell, Mercurial is Python (with a bit of C IIRC), and Bzr is written in Python, Pyrex, and C.
You'll also want to take into account what your tool of choice is. If you use Git, you'll understand what each file is implementing. Likewise with Mercurial or Bzr.
Basically, when choosing what tool or language to use (or study), a good axiom is this: go with what you know. You're trying to learn how to implement a DVCS, not how to use a particular system or language :)
在可理解且美观的代码方面,还有什么比 Python 更好的呢?
去水银吧。我已经做到了,这绝对是可爱的:)
What can be much better than Python in the context of understandable and beautiful code?
Go for Mercurial. I have done it and It's absolutely lovely :)
Git 是您最好的选择,因为它是分层的。命令基于较低级别的命令。这将使您从概念上理解我的想法。您可以自己重新执行较低级别的命令。最后,实现低级的来操作文件本身。
Git 的设计经过深思熟虑,将为您提供最佳的学习途径。
另外,请查看 Scott Chacon 的 git 内部帖子和屏幕截图。
Git is your best option because it is layered. Commands are based on lower level commands. This will allow you to understand what I'd going on conceptually. You can re implement commands yourself from the lower level ones. Finally, implement the low level ones to manipulate the files themselves.
Git was designed with a lot of thought put into it and will give you the best learning avenue.
Also, take a look at Scott Chacon's git internals posts and screen casts.
在深入研究代码之前,首先了解架构概述以了解要深入的地方是很有用的。
对于集市,以下内容可能会有所帮助:
http://doc.bazaar.canonical.com/bzr .2.3/en/user-guide/core_concepts.html
http://doc.bazaar.canonical.com/bzr.2.3/developers /overview.html
我发现 bazaar 代码库组织良好、干净且可读,
可能是因为它是 python 并且每个代码更改都会经过审查
因此,代码文档通常会根据审查进行修改,这通常会使事情变得更加清晰。
如果你遇到困难,你可以随时在 IRC 或邮件列表上提问,但我根本不需要做那么多。
Before diving into the code it is useful to first get a architectural overview to know where to dive in.
For bazaar the following might help:
http://doc.bazaar.canonical.com/bzr.2.3/en/user-guide/core_concepts.html
http://doc.bazaar.canonical.com/bzr.2.3/developers/overview.html
I found the bazaar code base well organised, clean and readable,
probably because it is python and each code change gets reviewed
so code documentation is normally amended as per review which in general makes things a lot clearer.
If you get stuck you can always ask on IRC or the mailinglist, but I have not needed to do that much at all.
我想知道看看坏例子有多大价值,以了解不该做什么,而不是仅仅看好例子。我从未研究过 Subversion 或 CVS 的源代码,但可能值得仔细研究一下它们并了解它们为什么不如您提到的 DVCS 那样有效。
I wonder how much value there is in looking at bad examples, to get an idea of what not to do, rather than just looking at good examples. I've never looked at the source of Subversion or CVS but it might be worth looking through them and understanding why they don't work as well as the DVCSes you mentioned.