Commit Graph

34 Commits

Author SHA1 Message Date
Felix Althaus
ac887f310f Make hg-fst-export.sh callable via a symbolic link
Calling hg-fast-export.sh via a symlink used to fail because the
script would look for hg-fast-export.py in the symlink‘s
directory. This patch adds symlink resolution using greadlink with a
fallback to readlink in order to support MacOS. That way you can
safely add a symlink to hg-fast-export.sh somewhere in you PATH.

Fixes https://github.com/frej/fast-export/issues/93
2017-06-02 16:13:20 +02:00
Emilian Bold
fb05ce5b7b Show warning when core.ignoreCase is true
When core.ignoreCase is true, which it is by default on OSX,
fast-import will produce empty changesets for renames that just change
the case of the file name. As this most probably is not the desired
behavior, trigger an error but allow the conversion to proceed if
--force is used.
2017-01-01 15:02:16 +01:00
Frej Drejhammar
01d71a2d3f Make backup copies of state files
If a conversion fails we want the previous state files preserved, both
for debugging but also to allow us to recover.
2016-12-28 12:15:38 +01:00
Frej Drejhammar
1d0f6cb7ca Fix broken support for bare repositories
The change in 6cf9397bd6 broke support for
bare repositories. In a bare repo git rev-parse --show-toplevel would
return an empty string and cwd would then be changed to the user's home
directory. In the home directory git rev-parse --git-dir would either
fail or return an unrelated repo.

Problem reported by Ralf Rösch.
2016-10-01 14:45:48 +02:00
Frej Drejhammar
6cf9397bd6 Do not rely on git internals, support Git >= 2.10
Fast-export has traditionally sourced the internal git-sh-setup from
Git, following the release of Git 2.10 this no longer works. Fast-export
only uses the functionality of git-sh-setup for two things: cd:ing to
the git repo dir and setting up the GIT_REPO environment variable. To
future-proof fast-export start doing what we need by hand in
fast-export.

Acknowledgments to Louis Sautier who reported the problem and tested the
fix.
2016-09-14 14:15:11 +02:00
Han Sangjin
38e81367ec Add filename encoding option --fe
In some locales Mercurial uses different encodings for commit messages
and file names. The --fe option allows the filename encoding to be
overridden.
2015-11-13 11:39:47 +01:00
Frej Drejhammar
3c27c693e1 Allow branches and tags to be remapped
Branch and tag names can now be renamed using a mechanism similar to the
-A option for author names.

-B specifies a mapping file for branch names, and -T a mapping file for
tags.
2015-08-16 17:13:04 +02:00
zed
e87c9cb3b8 Add option for specifying the text encoding used by Mercurial
When a mercurial repository does not use utf-8 for encoding author
strings and commit messages the "-e <encoding>" command line option
can be used to force fast-export to convert incoming meta data from
<encoding> to utf-8.

When "-e <encoding>" is given, we use Python's string
decoding/encoding API to convert meta data on the fly when processing
commits.
2014-10-25 22:39:08 +02:00
Frej Drejhammar
f64c10ba14 Do not rely on "type -p"
Apparently dash (used as bin/sh on Ubuntu) does not support type -p.

Thanks to Esben Madsen for noticing and suggesting a fix.
2014-09-23 15:01:02 +02:00
Christoph Junghans
a7c0da7eca Fix ROOT if hg-fast-export is in PATH
dirname $0 will return "." if hg-fast-export is in the path.
Use "type -p" to find the full path to the script.
2014-09-18 08:16:09 -06:00
Frej Drejhammar
2c21922ad1 Only dump heads in head cache
If there is a tag with the same name as a tag, "git rev-parse <name>"
can give the hash of the tag instead of the branch. "git rev-parse
refs/heads/<name>" must be used to make sure we only find branches.
2014-07-06 14:59:28 +02:00
Piotr Święcicki
1d85321bdb Annotate commits with the hg hash as git notes in the hg namespace
If the --hg-hash argument is given, the converted commits are
annotated with the original hg hash as a git note in the "hg"
namespace.

The notes can be shown by git log using the "--notes=hg" argument.
2014-05-02 16:57:03 +02:00
Kyle J. McKay
779e2f6da8 hg-fast-export.sh/hg-reset.sh: replace egrep with grep
According to the POSIX standard, egrep is an obsolescent equivalent
of grep -E.  In fact, the patterns actually being used with egrep do
not require use of extended regular expressions at all, so a plain
'grep' can be used rather than 'grep -E'.

Replace egrep with grep to improve compatibility across systems.
2014-04-13 15:40:07 +02:00
Kyle J. McKay
0e4142955a hg-fast-export.sh: clean up help text and support --help
Intercept -h/--help before git-sh-setup so the proper script name
can be shown instead of "hg fast-export.sh" which is wrong.

Reorder the long option descriptions to be in the same order as
the short usage since, as the help says, "argument order matters."
2014-03-16 16:00:42 +01:00
Kyle J. McKay
5fad4e4b99 hg-fast-export: support new --hgtags option
Add support for a new --hgtags option.  When given, any .hgtags
files that may be present are exported.

Normally this is not desirable.  However, when attempting to mimic
the actions of other hg exporters that always export any .hgtags
files this option can help produce matching export data.
2014-03-16 16:00:42 +01:00
Kyle J. McKay
8ed62c9cf7 hg-fast-export.sh: Do not ignore hg-fast-export.py exit code
Originally 9643aa5d did this by using a bashism even though the
/bin/sh interpreter is being used.

Then ea55929e attempted to compensate for this by disabling the
bashism when the interpreter was not actually bash which results
in the hg-fast-export.py exit code still being ignored in that case.

Instead check the error code without requiring a bashism.
2014-03-16 16:00:42 +01:00
Kyle J. McKay
8b6c6e5cff Revert "Don't ignore hg-fast-export.py exit code"
This reverts commit 9643aa5df2.
2014-03-16 16:00:42 +01:00
Kyle J. McKay
cb55f74437 Revert "Make bashism conditional on the shell being bash"
This reverts commit aaccfba9a0.
2014-03-16 16:00:42 +01:00
Frej Drejhammar
aaccfba9a0 Make bashism conditional on the shell being bash
This avoids breakage due to 9643aa5d on shells other than bash.
2013-09-15 12:29:09 +02:00
Frej Drejhammar
b85743f67e Give a proper error message when the hg repo is not known
hg-fast-export.sh always passes the --repo flag to hg-fast-export.py.
If, for some reason, we have a state file where the repo-url is an
empty string the checks in hg-fast-export.py will not work and the
user will be confused. Therefore we check that the url is specified
before calling hg-fast-export.py.
2013-09-08 14:32:08 +02:00
Matthijs van der Vleuten
9643aa5df2 Don't ignore hg-fast-export.py exit code 2013-09-04 09:43:17 +02:00
David Wragg
32c481a98f Add usage info for the --force option 2012-01-23 16:17:44 +00:00
David Wragg
fab6d6f025 hg-fast-export.sh should fail if git-fast-import fails
Previously, git-fast-import could fail, and exit with a non-zero status.
But the exit status of hg-fast-export.sh would not reflect this.
2011-06-13 13:05:47 +01:00
David Wragg
b51166f006 Support passing --force to git-fast-import 2011-06-13 12:34:13 +01:00
Frej Drejhammar
276f54c38f Merge branch 'from-jmcmullan' into develop
Conflicts:
	hg-fast-export.py
2008-12-20 19:57:39 +01:00
Fabrizio Chiarello
a984e233c2 hg-fast-export: add option to track remote branches under a custom namespace
Add -o, --origin <name> to allow user to set a namespace used
when importing remote branches.

Signed-off-by: Fabrizio Chiarello <ponch@autistici.org>
2008-12-20 19:51:02 +01:00
Jason S. McMullan
b4833029a4 hg export: Support tag movement
HG tag movement is now supported with this patch.

This patch creates a .git/hg2git-mapping file, which maps
HG revision numbers to HG hashes. Combined with the
.git/hg2git-marks file, which maps HG revisions to GIT hashes,
we can now reprocess all tags at the end of each hg export
operation.
2008-12-11 09:05:05 -05:00
Rocco Rutte
fdbb1decaa hg2git: Update copyrights and maintainership information.
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-11-25 11:25:22 +01:00
Fabrizio Chiarello
1ab60e492b hg-fast-export: Make default branch customizable
Add -M, --default-branch <branch_name> to allow user to set
the default branch where to pull into

Signed-off-by: Fabrizio Chiarello <ponch@autistici.org>
2008-09-19 08:03:44 +02:00
Jonathan Nieder
8be4e6b3d0 hg-fast-export: work still if git-commands are not in PATH
In git 1.6.0, most git tools with a dash in the name will no
longer be installed in $bindir.  This patch makes hg-fast-export
use the "git <command>" form so it will work even if "git" is
the only piece of git machinery in the user's PATH.

On the other hand, the "git <command>" form does not help for
sourcing a shell script (with ".").  So use the full path to
source "git-sh-setup".

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
2008-07-31 07:18:16 +02:00
Rocco Rutte
258f03a9ba Fix shell substitution typo
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 08:28:41 +00:00
Rocco Rutte
4cc1d7cf17 Allow for $PYTHON environment variable specifying python binary to use
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 09:34:40 +02:00
Rocco Rutte
3919be7d55 hg-fast-export.sh Use hg-fast-export.py, not dead hg2git.py
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-03-14 10:56:18 +00:00
Rocco Rutte
c84790da82 Use MIT license, adjust hg2git script names to match fast-export repo style
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-03-14 10:29:24 +00:00