作为一名经验丰富的 git 用户,我如何学习了解 Mercurial 的工作原理?
我已经使用 git 一段时间了,因为它是我使用过的唯一 DVCS,所以我学会了在很大程度上依赖它在我的工作流程中的工作方式。
我现在在一家新公司,他们使用 Mercurial,所以我需要了解 Mercurial 的模型以及它与 git 的区别,以适应我的工作流程并避免犯下代价高昂的错误。
那么我可以为此使用哪些资源呢?
I've been using git for a while now, and since it is the only DVCS I have ever used, I've learned to rely a lot on the way it works for my workflow.
I'm in a new company now, and they use Mercurial, so I need to understand Mercurial's model and how it differs from git, to adapt my workflow and avoid making costly mistakes.
So what resources can I use for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
相当广泛的与 Mercurial 官方 wiki 的概念差异。
stackoverflow 的另一个问题:最常见 Mercurial 的 Git 等效项命令?
评论跟进:
如果我继续:“模型”、“差异”、“背后的哲学”差异”以及对“工作流程”的影响。在我能想到的差异中,有:
存储在实现上有很大不同,但在概念上没有很大不同(正如您要求的“模型”,我将提供更多详细信息):
Git 将数据存储为“对象”(“提交对象” 、“树对象”、“blob 对象”或“标记对象”,存储为由其名称(SHA1 哈希值)唯一标识的文件。这是某种“文件系统哈希表”。在最新版本中,这些对象可以打包为在
.git/objects
目录下的较小文件。我不会再进一步,我的理解就到此为止,因为我从来没有发现如何知道比特是如何铺设的。您可以使用以下方法在对象内容中进行漂亮的打印:Mercurial 商店每个文件的历史记录分别作为 “revlog(NG)”格式。您可以手动检查
.hg/store/data
(revlogNG) 下的文件名。请注意,特殊字符和大写字符是“tilda-下划线编码”。您可以使用以下方式列出文件的修订版本:
您已经注意到
nodeid
不是hg log
中的那个。现在,检查内容:
修订历史记录(或多或少您在
hg log
中看到的内容)存储在.hg/store/00changelog.i
中(使用hg 检查它debugindex .hg/store/00changelog.i
,您将在nodeid
列中看到与hg log
中相同的 ID)。要显示 ID 为XXXX
的原始历史记录条目,请在终端中输入hg debugdata .hg/store/00changelog.i XXXX
。 (看第一行,稍后将用作YYYY
)树的状态存储在
.hg/store/00manifest.i
中。清单中对应的nodeid
为YYYY
。这将显示附加的“文件名+nodeid”列表。让我们选择文件
foo/bar
并记下附加到它的nodeid
并认为它是ZZZZ
(行foo/barZZZZ
>).最后一步,访问
foo/bar
文件的内容:从基本数据存储分析中可以清楚地看出哲学上的差异:
当 Git 提交时,它会生成(可能很多)新文件(可以稍后打包)。当 Mercurial 提交时,它会附加到现有文件。
在 Git 中,
blobid
可以与treeid
(或commitid
或tagid
)发生冲突,但是这是极不可能的。在 Mercurial 中,一个changesetid
只能与另一个changesetid
发生冲突(清单(树)和文件(blob)也是如此),这是更不可能的。Quite extended concept differences from Mercurial's official wiki.
Another question from stackoverflow: Git equivalents of most common Mercurial commands?
Comment follow up:
If I resume: "model", "differences", "philosophy behind the differences" and influences on the "workflow". In the differences I can think of, there is:
Storage differs greatly in implementation, but not in concepts (as you asked for "model", I will put more details):
Git stores data as "objects" ("commit object", "tree object", "blob object" or "tag object", stored as file uniquely identified by there name which is a SHA1 hash). This is some kind of "filesystem hash table". With recent versions, those objects can be packed to have less small files under the
.git/objects
directory. I will not go further, my understanding stop here as I never found use to know how bits are laid. You can have a pretty printing in the object's content with:Mercurial stores history of each files individually as "filelog" in the "revlog(NG)" format. You can manually inspect file names under
.hg/store/data
(revlogNG). Note that special and uppercase characters are "tilda-underscore encoded".You can list revisions of a file with:
You have already noted that the
nodeid
s are not the one inhg log
.And now, inspect the contents with:
The revision history (more or less what you see with
hg log
) is stored in.hg/store/00changelog.i
(inspect it withhg debugindex .hg/store/00changelog.i
, you will see the same IDs as the one inhg log
in thenodeid
column). To show one raw history entry with idXXXX
, typehg debugdata .hg/store/00changelog.i XXXX
in a terminal. (look at first line, it will be used later asYYYY
)The state of the tree is stored in
.hg/store/00manifest.i
. The correspondingnodeid
in the manifest isYYYY
.This will show a list of "filename+nodeid" appended. Let's choose file
foo/bar
and note thenodeid
appended to it and consider it isZZZZ
(linefoo/barZZZZ
).Last step, access to the content of the
foo/bar
file:For the differences in philosophy clearly visible from this basic data storage analysis:
When Git commits, it make (potentially a lot of) new files (which can be packed later). When Mercurial commits, it appends to existing files.
In Git a
blobid
can collide with atreeid
(orcommitid
ortagid
) but that is highly improbable. In Mercurial, achangesetid
can collide only with anotherchangesetid
(ditto for manifests (tree) and files (blob)) which is even more improbable.