Commit Graph

47 Commits

Author SHA1 Message Date
Frej Drejhammar
507c17cc1b Revert "Handle --force option correctly in any position"
This reverts commit 0c5617bf8d.

The changes turned out to require bash. Traditionally we have tried to
stay compatible with plain old sh, so this is a revert.

Closes #195.
2020-01-31 17:01:04 +01:00
Alexander Regueiro
0c5617bf8d Handle --force option correctly in any position 2020-01-29 18:13:54 +00:00
Frej Drejhammar
1181a0af47 Allow name sanitizer to be disabled with --no-auto-sanitize
Make it possible to completely disable the name sanitizer by the
--no-auto-sanitize flag. Previously the sanitizer was run on user
remapped names. As the sanitizer rewrites perfectly legal git
names (such as __.*) this is probably not what the user wants.

Closes #155.
2019-09-13 14:56:32 +02:00
Frej Drejhammar
f57fba000b Try to do the right thing on non PEP394 compliant systems
PEP 394 [1] tells us that on systems with both a python 2 and 3
installed, the python 2 interpreter should be installed as python2.

Unfortunately not all distributions adheres to PEP 394 (I'm looking at
you, Windows) so to handle that we first try to find a 'python2', then
fall back on plain 'python'. In order to not silently pick a python 3
by mistake, we check sys.version_info using the the interpreter we
found.

[1] https://www.python.org/dev/peps/pep-0394/
2019-09-01 18:31:18 +02:00
Johan Henkens
e895ce087f Add plugin system 2018-12-05 13:25:47 -08:00
Frej Drejhammar
ac60034ba3 Adhere to PEP 394
From PEP 394 [1]:

* python2 will refer to some version of Python 2.x.

* end users should be aware that python refers to python3 on at least
  Arch Linux (that change is what prompted the creation of this PEP),
  so python should be used in the shebang line only for scripts that
  are source compatible with both Python 2 and 3.

So to make sure that we run correctly on a system where python refers
to python3 and avoid problems like issue #11 we change the shebangs.

[1] https://www.python.org/dev/peps/pep-0394/
2018-08-11 15:07:19 +02:00
Anton Tykhyy
89db1d93cf Add --filter-contents 2018-06-17 21:09:59 +03:00
Martin Freund
90483e02e5 Quote $PYTHON variable to support paths with spaces 2018-01-24 11:43:22 +01:00
Frej Drejhammar
cc8fefe008 Change syntax of mapping files
This is done to allow escape sequences in the key and value strings.
2017-10-02 13:05:14 +02:00
Frej Drejhammar
2536f87544 Avoid nuisance error printout from readlink test
2>&1 > /dev/null does not do what I expected, > /dev/null 2>&1 does.
2017-08-25 11:28:52 +02:00
Frej Drejhammar
17c8a22066 Don't break if the destination directory name contains a space 2017-08-18 16:19:27 +02:00
Frej Drejhammar
7aa82e8234 Eliminate bashism
'>&' is apparently a bashism, change '>& /dev/null' to '2>&1 > /dev/null'.

Problem reported by KatolaZ <katolaz@freaknet.org>.

Resolves #99 and closes #100.
2017-06-24 11:58:36 +02:00
Frej Drejhammar
02bb982dd9 Behave nicely when the found readlink does not understand '-f'
Instead of just crashing when the found readlink does not understand
'-f', fall back to the pre ac887f310f
behaviour and print an error message if we fail to find
hg-fast-export.py.
2017-06-05 18:41:44 +02:00
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