From 50ec8f2f1e2f02b47c40beda8b45164e28bf906d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E9=A3=99?= Date: Mon, 6 Jul 2015 14:22:44 +0800 Subject: [PATCH 1/5] Translate 09-git-and-other-scms import-hg --- .../sections/import-hg.asc | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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..4328c2d2 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] ---- From e519c3ebf4204c1097bcfff851cb68e2e7ebbf41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E9=A3=99?= Date: Mon, 6 Jul 2015 14:25:19 +0800 Subject: [PATCH 2/5] Translate 09-git-and-other-scms import-hg v2 --- book/09-git-and-other-scms/sections/import-hg.asc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 4328c2d2..67b173d4 100644 --- a/book/09-git-and-other-scms/sections/import-hg.asc +++ b/book/09-git-and-other-scms/sections/import-hg.asc @@ -1,14 +1,14 @@ ==== Mercurial (((Mercurial)))(((Importing, from Mercurial))) -因为 Mercurial 与 Git 在表示版本时有着非常相似的模型,但是因为 Git 更灵活一点,将一个仓库从 Mercurial 转换到 Git 是相当直接的,使用一个叫作“hg-fast-export”的工具,你需要从这里拷贝一份: +因为 Mercurial 与 Git 在表示版本时有着非常相似的模型,但是因为 Git 更灵活一点,将一个仓库从 Mercurial 转换到 Git 是相当直接的,使用一个叫作“hg-fast-export”的工具,需要从这里拷贝一份: [source,console] ---- $ git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export ---- -转换的第一步就是要先得到你想要转换的 Mercurial 仓库的完整克隆: +转换的第一步就是要先得到想要转换的 Mercurial 仓库的完整克隆: [source,console] ---- @@ -16,7 +16,7 @@ $ hg clone /tmp/hg-repo ---- 下一步就是创建一个作者映射文件。 -Mercurial 在它放入到变更集作者字段的内容比 Git 更宽容一些,所以这是一个打扫屋子的好机会。 +Mercurial 对放入到变更集作者字段的内容比 Git 更宽容一些,所以这是一个打扫屋子的好机会。 生成映射是 `bash` 终端下的一行命令: [source,console] @@ -25,7 +25,7 @@ $ cd /tmp/hg-repo $ hg log | grep user: | sort | uniq | sed 's/user: *//' > ../authors ---- -这会花费几秒钟,具体要看你的项目提交历史有多少,最终 `/tmp/authors` 文件看起来会像这样: +这会花费几秒钟,具体要看项目提交历史有多少,最终 `/tmp/authors` 文件看起来会像这样: [source] ---- @@ -111,7 +111,7 @@ $ git shortlog -sn 那看起来非常好。 所有 Mercurial 标签都已被转换成 Git 标签,Mercurial 分支与书签都被转换成 Git 分支。 -现在你已经准备好推送仓库到新的服务器那边: +现在已经准备好推送仓库到新的服务器那边: [source,console] ---- From ec949345976a7bd3f65b83d0b5a1319fcf61639f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E9=A3=99?= Date: Sat, 25 Jul 2015 22:18:40 +0800 Subject: [PATCH 3/5] Review 09-git-and-other-scms import-hg --- book/09-git-and-other-scms/sections/import-hg.asc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 67b173d4..f1a8ee34 100644 --- a/book/09-git-and-other-scms/sections/import-hg.asc +++ b/book/09-git-and-other-scms/sections/import-hg.asc @@ -1,7 +1,7 @@ ==== Mercurial (((Mercurial)))(((Importing, from Mercurial))) -因为 Mercurial 与 Git 在表示版本时有着非常相似的模型,但是因为 Git 更灵活一点,将一个仓库从 Mercurial 转换到 Git 是相当直接的,使用一个叫作“hg-fast-export”的工具,需要从这里拷贝一份: +因为 Mercurial 与 Git 在表示版本时有着非常相似的模型,也因为 Git 拥有更加强大的灵活性,将一个仓库从 Mercurial 转换到 Git 是相当直接的,使用一个叫作“hg-fast-export”的工具,需要从这里拷贝一份: [source,console] ---- From 5abd0e918c068332dce29c717a52820a8d772576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E9=A3=99?= Date: Tue, 11 Aug 2015 14:34:32 +0800 Subject: [PATCH 4/5] Review 09-git-and-other-scms import-hg v2 --- book/09-git-and-other-scms/sections/import-hg.asc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f1a8ee34..7c185e4f 100644 --- a/book/09-git-and-other-scms/sections/import-hg.asc +++ b/book/09-git-and-other-scms/sections/import-hg.asc @@ -111,7 +111,7 @@ $ git shortlog -sn 那看起来非常好。 所有 Mercurial 标签都已被转换成 Git 标签,Mercurial 分支与书签都被转换成 Git 分支。 -现在已经准备好推送仓库到新的服务器那边: +现在已经准备好将仓库推送到新的服务器那边: [source,console] ---- From a3416232614200b469d2563d3a3b357da8702fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=82=E9=A3=99?= Date: Sat, 15 Aug 2015 00:33:12 +0800 Subject: [PATCH 5/5] Review 09-git-and-other-scms import-hg v3 --- book/09-git-and-other-scms/sections/import-hg.asc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 7c185e4f..c8040b42 100644 --- a/book/09-git-and-other-scms/sections/import-hg.asc +++ b/book/09-git-and-other-scms/sections/import-hg.asc @@ -16,8 +16,8 @@ $ hg clone /tmp/hg-repo ---- 下一步就是创建一个作者映射文件。 -Mercurial 对放入到变更集作者字段的内容比 Git 更宽容一些,所以这是一个打扫屋子的好机会。 -生成映射是 `bash` 终端下的一行命令: +Mercurial 对放入到变更集作者字段的内容比 Git 更宽容一些,所以这是一个清理的好机会。 +只需要用到 `bash` 终端下的一行命令: [source,console] ---- @@ -59,8 +59,8 @@ $ cd /tmp/converted $ /tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors ---- -`-r` 标记告诉 hg-fast-export 去哪里寻找我们想要转换的 Mercurial 仓库,`-A` 标记告诉它在哪找到作者映射文件。 -这个脚本分析 Mercurial 变更集然后将它们转换成 Git“fast-import”功能(我们将在之后详细讨论)需要的脚本。 +`-r` 选项告诉 hg-fast-export 去哪里寻找我们想要转换的 Mercurial 仓库,`-A` 标记告诉它在哪找到作者映射文件。 +这个脚本会分析 Mercurial 变更集然后将它们转换成 Git“fast-import”功能(我们将在之后详细讨论)需要的脚本。 这会花一点时间(尽管它比通过网格 _更_ 快),输出相当的冗长: [source,console]