11 Commits

Author SHA1 Message Date
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
Frej Drejhammar
c252e6748e documentation: Point users to the issue tracker for support questions 2017-06-02 16:18:43 +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
Frej Drejhammar
4bb50bb3fb Fix crash when a branch name starts with '/'
If a branch name starts with '/' it will be split into ['', ...] and
then mapped over with dot(), only dot() does not handle the empty
string. Teach dot() to handle the empty string.

This fixes the underlying problem in issue #91.
2017-05-14 14:32:59 +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
4 changed files with 73 additions and 5 deletions

View File

@@ -12,6 +12,18 @@ copies some code from the mercurial sources.
The current maintainer is Frej Drejhammar <frej.drejhammar@gmail.com>.
Support
-------
If you have problems with hg-fast-export or have found a bug, please
create an issue at the [github issue tracker]
(https://github.com/frej/fast-export/issues). Before creating a new
issue, check that your problem has not already been addressed in an
already closed issue. Do not contact the maintainer directly unless
you want to report a security bug. That way the next person having the
same problem can benefit from the time spent solving the problem the
first time.
Usage
-----

View File

@@ -158,6 +158,7 @@ def sanitize_name(name,what="branch", mapping={}):
# work to do manually, write a tool that does it for you.
def dot(name):
if not name: return name
if name[0] == '.': return '_'+name[1:]
return name

View File

@@ -3,7 +3,22 @@
# Copyright (c) 2007, 2008 Rocco Rutte <pdmef@gmx.net> and others.
# License: MIT <http://www.opensource.org/licenses/mit-license.php>
ROOT="$(dirname "$(which "$0")")"
READLINK="readlink"
if command -v greadlink > /dev/null; then
READLINK="greadlink" # Prefer greadlink over readlink
fi
if ! $READLINK -f "$(which "$0")" > /dev/null 2>&1 ; then
ROOT="$(dirname "$(which "$0")")"
if [ ! -f "$ROOT/hg-fast-export.py" ] ; then
echo "hg-fast-exports requires a readlink implementation which knows" \
" how to canonicalize paths in order to be called via a symlink."
exit 1
fi
else
ROOT="$(dirname "$($READLINK -f "$(which "$0")")")"
fi
REPO=""
PFX="hg2git"
SFX_MAPPING="mapping"
@@ -48,8 +63,24 @@ case "$1" in
echo "$LONG_USAGE"
exit 0
esac
. "$(git --exec-path)/git-sh-setup"
cd_to_toplevel
IS_BARE=$(git rev-parse --is-bare-repository) \
|| (echo "Could not find git repo" ; exit 1)
if test "z$IS_BARE" != ztrue; then
# This is not a bare repo, cd to the toplevel
TOPLEVEL=$(git rev-parse --show-toplevel) \
|| (echo "Could not find git repo toplevel" ; exit 1)
cd "$TOPLEVEL" || exit 1
fi
GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1)
IGNORECASEWARN=""
IGNORECASE=`git config core.ignoreCase`
if [ "true" = "$IGNORECASE" ]; then
IGNORECASEWARN="true"
fi;
while case "$#" in 0) break ;; esac
do
@@ -64,6 +95,7 @@ do
--force)
# pass --force to git-fast-import and hg-fast-export.py
GFI_OPTS="$GFI_OPTS --force"
IGNORECASEWARN="";
break
;;
-*)
@@ -77,6 +109,22 @@ do
shift
done
if [ ! -z "$IGNORECASEWARN" ]; then
echo "Error: The option core.ignoreCase is set to true in the git"
echo "repository. This will produce empty changesets for renames that just"
echo "change the case of the file name."
echo "Use --force to skip this check or change the option with"
echo "git config core.ignoreCase false"
exit 1
fi;
# Make a backup copy of each state file
for i in $SFX_STATE $SFX_MARKS $SFX_MAPPING $SFX_HEADS ; do
if [ -f "$GIT_DIR/$PFX-$i" ] ; then
cp "$GIT_DIR/$PFX-$i" "$GIT_DIR/$PFX-$i~"
fi
done
# for convenience: get default repo from state file
if [ x"$REPO" = x -a -f "$GIT_DIR/$PFX-$SFX_STATE" ] ; then
REPO="`grep '^:repo ' "$GIT_DIR/$PFX-$SFX_STATE" | cut -d ' ' -f 2`"

View File

@@ -24,8 +24,15 @@ Options:
-r Mercurial repository to use
"
. "$(git --exec-path)/git-sh-setup"
cd_to_toplevel
IS_BARE=$(git rev-parse --is-bare-repository) \
|| (echo "Could not find git repo" ; exit 1)
if test "z$IS_BARE" != ztrue; then
# This is not a bare repo, cd to the toplevel
TOPLEVEL=$(git rev-parse --show-toplevel) \
|| (echo "Could not find git repo toplevel" ; exit 1)
cd $TOPLEVEL || exit 1
fi
GIT_DIR=$(git rev-parse --git-dir) || (echo "Could not find git repo" ; exit 1)
while case "$#" in 0) break ;; esac
do