To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / extra / fast-export / README.md @ 1579:aba122ac2d40
History | View | Annotate | Download (3.51 KB)
| 1 |
hg-fast-export.(sh|py) - mercurial to git converter using git-fast-import |
|---|---|
| 2 |
========================================================================= |
| 3 |
|
| 4 |
Legal |
| 5 |
----- |
| 6 |
|
| 7 |
Most hg-* scripts are licensed under the [MIT license] |
| 8 |
(http://www.opensource.org/licenses/mit-license.php) and were written |
| 9 |
by Rocco Rutte <pdmef@gmx.net> with hints and help from the git list and |
| 10 |
\#mercurial on freenode. hg-reset.py is licensed under GPLv2 since it |
| 11 |
copies some code from the mercurial sources. |
| 12 |
|
| 13 |
The current maintainer is Frej Drejhammar <frej.drejhammar@gmail.com>. |
| 14 |
|
| 15 |
Usage |
| 16 |
----- |
| 17 |
|
| 18 |
Using hg-fast-export is quite simple for a mercurial repository <repo>: |
| 19 |
|
| 20 |
``` |
| 21 |
mkdir repo-git # or whatever |
| 22 |
cd repo-git |
| 23 |
git init |
| 24 |
hg-fast-export.sh -r <repo> |
| 25 |
``` |
| 26 |
|
| 27 |
Please note that hg-fast-export does not automatically check out the |
| 28 |
newly imported repository. You probably want to follow up the import |
| 29 |
with a `git checkout`-command. |
| 30 |
|
| 31 |
Incremental imports to track hg repos is supported, too. |
| 32 |
|
| 33 |
Using hg-reset it is quite simple within a git repository that is |
| 34 |
hg-fast-export'ed from mercurial: |
| 35 |
|
| 36 |
``` |
| 37 |
hg-reset.sh -R <revision> |
| 38 |
``` |
| 39 |
|
| 40 |
will give hints on which branches need adjustment for starting over |
| 41 |
again. |
| 42 |
|
| 43 |
When a mercurial repository does not use utf-8 for encoding author |
| 44 |
strings and commit messages the `-e <encoding>` command line option |
| 45 |
can be used to force fast-export to convert incoming meta data from |
| 46 |
<encoding> to utf-8. This encoding option is also applied to file names. |
| 47 |
|
| 48 |
In some locales Mercurial uses different encodings for commit messages |
| 49 |
and file names. In that case, you can use `--fe <encoding>` command line |
| 50 |
option which overrides the -e option for file names. |
| 51 |
|
| 52 |
As mercurial appears to be much less picky about the syntax of the |
| 53 |
author information than git, an author mapping file can be given to |
| 54 |
hg-fast-export to fix up malformed author strings. The file is |
| 55 |
specified using the -A option. The file should contain lines of the |
| 56 |
form `FromAuthor=ToAuthor`. The example authors.map below will |
| 57 |
translate `User <garbage<user@example.com>` to `User <user@example.com>`. |
| 58 |
|
| 59 |
``` |
| 60 |
-- Start of authors.map -- |
| 61 |
User <garbage<user@example.com>=User <user@example.com> |
| 62 |
-- End of authors.map -- |
| 63 |
``` |
| 64 |
|
| 65 |
Tag and Branch Naming |
| 66 |
--------------------- |
| 67 |
|
| 68 |
As Git and Mercurial have differ in what is a valid branch and tag |
| 69 |
name the -B and -T options allow a mapping file to be specified to |
| 70 |
rename branches and tags (respectively). The syntax of the mapping |
| 71 |
file is the same as for the author mapping. |
| 72 |
|
| 73 |
Notes/Limitations |
| 74 |
----------------- |
| 75 |
|
| 76 |
hg-fast-export supports multiple branches but only named branches with |
| 77 |
exactly one head each. Otherwise commits to the tip of these heads |
| 78 |
within the branch will get flattened into merge commits. |
| 79 |
|
| 80 |
As each git-fast-import run creates a new pack file, it may be |
| 81 |
required to repack the repository quite often for incremental imports |
| 82 |
(especially when importing a small number of changesets per |
| 83 |
incremental import). |
| 84 |
|
| 85 |
The way the hg API and remote access protocol is designed it is not |
| 86 |
possible to use hg-fast-export on remote repositories |
| 87 |
(http/ssh). First clone the repository, then convert it. |
| 88 |
|
| 89 |
Design |
| 90 |
------ |
| 91 |
|
| 92 |
hg-fast-export.py was designed in a way that doesn't require a 2-pass |
| 93 |
mechanism or any prior repository analysis: if just feeds what it |
| 94 |
finds into git-fast-import. This also implies that it heavily relies |
| 95 |
on strictly linear ordering of changesets from hg, i.e. its |
| 96 |
append-only storage model so that changesets hg-fast-export already |
| 97 |
saw never get modified. |
| 98 |
|
| 99 |
Submitting Patches |
| 100 |
------------------ |
| 101 |
|
| 102 |
Please use the issue-tracker at github |
| 103 |
https://github.com/frej/fast-export to report bugs and submit |
| 104 |
patches. |