Skip to content

Commit 54bf454

Browse files
authored
Merge pull request #1027 from frej/update-hg-fast-export-info
Update Ch9 section about Mercurial imports to match current hg-fast-export release
2 parents c87e21a + 7f501cb commit 54bf454

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

book/09-git-and-other-scms/sections/import-hg.asc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Since Mercurial and Git have fairly similar models for representing versions, an
55

66
[source,console]
77
----
8-
$ git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export
8+
$ git clone https://github.com/frej/fast-export.git
99
----
1010

1111
The first step in the conversion is to get a full clone of the Mercurial repository you want to convert:
@@ -38,18 +38,22 @@ Joe Smith <[email protected]>
3838
----
3939

4040
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.
41-
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.
41+
Hg-fast-export lets us fix this by turning each line into a rule: `"<input>"="<output>"`, mapping an `<input>` to an `<output>`.
42+
Inside the `<input>` and `<output>` strings, all escape sequences understood by the python `string_escape` encoding are supported.
43+
If the author mapping file does not contain a matching `<input>`, that author will be sent on to Git unmodified.
4244
If all the usernames look fine, we won't need this file at all.
4345
In this example, we want our file to look like this:
4446

4547
[source]
4648
----
47-
bob=Bob Jones <[email protected]>
48-
bob@localhost=Bob Jones <[email protected]>
49-
50-
bob jones <bob <AT> company <DOT> com>=Bob Jones <[email protected]>
49+
"bob"="Bob Jones <[email protected]>"
50+
"bob@localhost"="Bob Jones <[email protected]>"
51+
52+
"bob jones <bob <AT> company <DOT> com>"="Bob Jones <[email protected]>"
5153
----
5254

55+
The same kind of mapping file can be used to rename branches and tags when the Mercurial name is not allowed by Git.
56+
5357
The next step is to create our new Git repository, and run the export script:
5458

5559
[source,console]
@@ -59,7 +63,7 @@ $ cd /tmp/converted
5963
$ /tmp/fast-export/hg-fast-export.sh -r /tmp/hg-repo -A /tmp/authors
6064
----
6165

62-
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.
66+
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 (branch and tag mapping files are specified by the `-B` and `-T` flags respectively).
6367
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).
6468
This takes a bit (though it's _much_ faster than it would be over the network), and the output is fairly verbose:
6569

0 commit comments

Comments
 (0)