-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1027 from frej/update-hg-fast-export-info
Update Ch9 section about Mercurial imports to match current hg-fast-export release
- Loading branch information
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ Since Mercurial and Git have fairly similar models for representing versions, an | |
|
||
[source,console] | ||
---- | ||
$ git clone http://repo.or.cz/r/fast-export.git /tmp/fast-export | ||
$ git clone https://github.com/frej/fast-export.git | ||
---- | ||
|
||
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]> | |
---- | ||
|
||
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. | ||
Hg-fast-export lets us fix this by turning each line into a rule: `"<input>"="<output>"`, mapping an `<input>` to an `<output>`. | ||
Inside the `<input>` and `<output>` strings, all escape sequences understood by the python `string_escape` encoding are supported. | ||
If the author mapping file does not contain a matching `<input>`, that author will be sent on to Git unmodified. | ||
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: | ||
|
||
[source] | ||
---- | ||
bob=Bob Jones <[email protected]> | ||
bob@localhost=Bob Jones <[email protected]> | ||
bob <[email protected]>=Bob Jones <[email protected]> | ||
bob jones <bob <AT> company <DOT> com>=Bob Jones <[email protected]> | ||
"bob"="Bob Jones <[email protected]>" | ||
"bob@localhost"="Bob Jones <[email protected]>" | ||
"bob <[email protected]>"="Bob Jones <[email protected]>" | ||
"bob jones <bob <AT> company <DOT> com>"="Bob Jones <[email protected]>" | ||
---- | ||
|
||
The same kind of mapping file can be used to rename branches and tags when the Mercurial name is not allowed by Git. | ||
|
||
The next step is to create our new Git repository, and run the export script: | ||
|
||
[source,console] | ||
|
@@ -59,7 +63,7 @@ $ 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 `-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). | ||
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: | ||
|
||
|