diff --git a/book/09-git-and-other-scms/sections/import-hg.asc b/book/09-git-and-other-scms/sections/import-hg.asc index 4acf4537..c8040b42 100644 --- a/book/09-git-and-other-scms/sections/import-hg.asc +++ b/book/09-git-and-other-scms/sections/import-hg.asc @@ -1,23 +1,23 @@ ==== Mercurial (((Mercurial)))(((Importing, from Mercurial))) -Since Mercurial and Git have fairly similar models for representing versions, and since Git is a bit more flexible, converting a repository from Mercurial to Git is fairly straightforward, using a tool called "hg-fast-export", which you'll need a copy of: +因为 Mercurial 与 Git 在表示版本时有着非常相似的模型,也因为 Git 拥有更加强大的灵活性,将一个仓库从 Mercurial 转换到 Git 是相当直接的,使用一个叫作“hg-fast-export”的工具,需要从这里拷贝一份: [source,console] ---- $ git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export ---- -The first step in the conversion is to get a full clone of the Mercurial repository you want to convert: +转换的第一步就是要先得到想要转换的 Mercurial 仓库的完整克隆: [source,console] ---- $ hg clone /tmp/hg-repo ---- -The next step is to create an author mapping file. -Mercurial is a bit more forgiving than Git for what it will put in the author field for changesets, so this is a good time to clean house. -Generating this is a one-line command in a `bash` shell: +下一步就是创建一个作者映射文件。 +Mercurial 对放入到变更集作者字段的内容比 Git 更宽容一些,所以这是一个清理的好机会。 +只需要用到 `bash` 终端下的一行命令: [source,console] ---- @@ -25,7 +25,7 @@ $ cd /tmp/hg-repo $ hg log | grep user: | sort | uniq | sed 's/user: *//' > ../authors ---- -This will take a few seconds, depending on how long your project's history is, and afterwards the `/tmp/authors` file will look something like this: +这会花费几秒钟,具体要看项目提交历史有多少,最终 `/tmp/authors` 文件看起来会像这样: [source] ---- @@ -37,10 +37,10 @@ Bob Jones Joe Smith ---- -In this example, the same person (Bob) has created changesets under four different names, one of which actually looks correct, and one of which would be completely invalid for a Git commit. -Hg-fast-export lets us fix this by adding `={new name and email address}` at the end of every line we want to change, and removing the lines for any usernames that we want to leave alone. -If all the usernames look fine, we won't need this file at all. -In this example, we want our file to look like this: +在这个例子中,同一个人(Bob)使用不同的名字创建变更集,其中一个实际上是正确的,另一个完全不符合 Git 提交的规范。 +Hg-fast-export 通过向我们想要修改的行尾添加 `={new name and email address}` 来修正这个问题,移除任何我们想要保留的用户名所在的行。 +如果所有的用户名看起来都是正确的,那我们根本就不需要这个文件。 +在本例中,我们会使文件看起来像这样: [source] ---- @@ -50,7 +50,7 @@ bob jones company com>=Bob Jones bob =Bob Jones ---- -The next step is to create our new Git repository, and run the export script: +下一步是创建一个新的 Git 仓库,然后运行导出脚本: [source,console] ---- @@ -59,9 +59,9 @@ $ cd /tmp/converted $ /tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors ---- -The `-r` flag tells hg-fast-export where to find the Mercurial repository we want to convert, and the `-A` flag tells it where to find the author-mapping file. -The script parses Mercurial changesets and converts them into a script for Git's "fast-import" feature (which we'll discuss in detail a bit later on). -This takes a bit (though it's _much_ faster than it would be over the network), and the output is fairly verbose: +`-r` 选项告诉 hg-fast-export 去哪里寻找我们想要转换的 Mercurial 仓库,`-A` 标记告诉它在哪找到作者映射文件。 +这个脚本会分析 Mercurial 变更集然后将它们转换成 Git“fast-import”功能(我们将在之后详细讨论)需要的脚本。 +这会花一点时间(尽管它比通过网格 _更_ 快),输出相当的冗长: [source,console] ---- @@ -109,9 +109,9 @@ $ git shortlog -sn 365 Joe Smith ---- -That's pretty much all there is to it. -All of the Mercurial tags have been converted to Git tags, and Mercurial branches and bookmarks have been converted to Git branches. -Now you're ready to push the repository up to its new server-side home: +那看起来非常好。 +所有 Mercurial 标签都已被转换成 Git 标签,Mercurial 分支与书签都被转换成 Git 分支。 +现在已经准备好将仓库推送到新的服务器那边: [source,console] ----