Dual-licensed under MIT
or the UNLICENSE.
With cargo
:
cargo install hg-git-fast-import
From source:
git clone https://github.com/kilork/hg-git-fast-import.git
cd hg-git-fast-import
cargo install --path .
Prebuild release binaries:
With Snap (*):
sudo snap install hg-git-fast-import
(*) Limitations: Subprocesses are not allowed with strict snap package (hg and git), classic confinement is not requested at the moment, this means you can only export script which would be processed with git.
hg-git-fast-import is a command-line utility, usage info can be access with --help argument:
```bash $ hg-git-fast-import --help hg-git-fast-import 1.3.7 Alexander Korolev kilork@yandex.ru A utility to import single and multiple Mercurial repositories to Git.
USAGE:
hg-git-fast-import
FLAGS: -h, --help Prints help information -V, --version Prints version information
SUBCOMMANDS: build-marks Rebuilds saved state of repo help Prints this message or the help of the given subcommand(s) multi Exports multiple Mercurial repositories to single Git repo in fast-import compatible format single Exports single Mercurial repository to Git fast-import compatible format ```
Import of single repository:
```bash $ hg-git-fast-import single --help hg-git-fast-import-single 1.3.7 Alexander Korolev kilork@yandex.ru Exports single Mercurial repository to Git fast-import compatible format
USAGE:
hg-git-fast-import single [FLAGS] [OPTIONS]
FLAGS: --clean Recreate Git repo before import if it exists. --cron Produce minimal output only if new revisions loaded or error happened. --fix-wrong-branch-names Fix wrong Mercurial branch names (not compatible with git ref format). -h, --help Prints help information --no-clean-closed-branches Do not clean closed Mercurial branches. --source-pull Pull source Mercurial repository before import. --target-pull Pull target Git repository before push. --target-push Push target Git repository after successful import. -V, --version Prints version information --verify Compares resulting Git repo with Mercurial.
OPTIONS:
-a, --authors
ARGS:
Import of multiple repositories:
```bash $ hg-git-fast-import multi --help hg-git-fast-import-multi 1.3.7 Alexander Korolev kilork@yandex.ru Exports multiple Mercurial repositories to single Git repo in fast-import compatible format
USAGE:
hg-git-fast-import multi [FLAGS] [OPTIONS] --config
FLAGS: --clean Recreate Git repo before import if it exists. --cron Produce minimal output only if new revisions loaded or error happened. --fix-wrong-branch-names Fix wrong Mercurial branch names (not compatible with git ref format). -h, --help Prints help information --no-clean-closed-branches Do not clean closed Mercurial branches. --source-pull Pull source Mercurial repository before import. --target-pull Pull target Git repository before push. --target-push Push target Git repository after successful import. -V, --version Prints version information --verify Compares resulting Git repo with Mercurial.
OPTIONS:
-a, --authors
Rebuild saved state of repo:
```bash $ hg-git-fast-import build-marks --help hg-git-fast-import-build-marks 1.3.7 Alexander Korolev kilork@yandex.ru Rebuilds saved state of repo
USAGE:
hg-git-fast-import build-marks [FLAGS] [OPTIONS]
FLAGS: -h, --help Prints help information --no-backup Do not backup old marks. -V, --version Prints version information
OPTIONS:
-a, --authors
ARGS:
For more advanced cases one may supply configuration in toml
format.
```toml
allowunnamedheads = true
offset = 1000
path_prefix = 'prefix1'
tag_prefix = 'prefix2-'
branch_prefix = 'prefix3-'
prefixdefaultbranch = false
[authors] 'aaa 1' = 'Bbb bbb@company.xyz' aaa = 'Bbb bbb@company.xyz' ccc = 'Qqq qqq@another.dom' 'My my_typo@wrong.xyz' = 'My my@normal.xyz'
[branches] 'branch in hg' = 'branch-in-git' 'anotherhg' = 'othergit' ```
See single.toml.
With authors
and branches
subsections one can rename authors and branches during import. Offset creates marks in Git repository. Can be useful if all marks files from imported repositories planned to be analyzed together. allow_unnamed_heads
allows to start import in case of hanged heads in repository, currently this feature has no effect.
```toml
pathgit = "000git"
[[repositories]]
pathhg = "001hg"
pathgit = "001git"
[repositories.config] allowunnamedheads = true offset = 1000 pathprefix = 'prefix1' tagprefix = 'prefix2-' branchprefix = 'prefix3-' prefixdefault_branch = true
[repositories.config.authors] 'aaa' = 'Bbb bbb@company.xyz'
[repositories.config.branches] 'branch1' = 'branch2'
[repositories.mergedbranches] branchin_git = 'branch2'
[[repositories]]
alias = "another002" pathhg = "002hg" pathgit = "002_git"
[repositories.mergedbranches] branchingit = 'branchin_hg'
```
Each of child repositories will be imported in corresponding path_git
from configuration, then single repository from top level path_git
will reference child repositories as remote
. For remote name either alias
either path_prefix
is taken.
See multi.toml.
toml
'aaa 1' = 'Bbb <bbb@company.xyz>'
aaa = 'Bbb <bbb@company.xyz>'
ccc = 'Qqq <qqq@another.dom>'
'My <my_typo@wrong.xyz>' = 'My <my@normal.xyz>'
See authors.toml.
single
mode without repo creation)--verify
)Mercurial
)To setup all dependencies can be a tricky task - it is possible to use docker
for running hg-git-fast-import
.
git clone https://github.com/kilork/hg-git-fast-import.git
cd hg-git-fast-import/docker
./build.sh
docker run -it --rm kilork/hg-git-fast-import hg-git-fast-import --help
To mount current directory with repositories and run hg-git-fast-import
command with docker one can use wrapper hg-git-fast-import/docker/run.sh
:
cd hg-git-fast-import/docker
./run.sh
By default this will mount current directory to /repositories
dir inside docker container. This can be overriden by usage of env variable:
HG_GIT_FAST_IMPORT_VOLUME=~/sandbox:/sandbox ./run.sh single /sandbox/source_hg /sandbox/target_git