Commit Graph

491 Commits

Author SHA1 Message Date
Gabriel
51d5f893db Add a section about system requirements to the README
Add @rinu's suggestion on how to run fast-export on Windows to the
README, this fixes #121.
2018-06-10 15:44:46 +02:00
ceqi
19aa906308 Update usage section example commands
Change <repo> to <local-repo> so that it's clear that we invoke from a local repository;
Add 'git checkout HEAD' command as we need to run it as the final step.

Thanks
v180317
2018-02-13 13:37:58 +00:00
Frej Drejhammar
50dc10770b Warn contributors from doing work that will no be merged
From time to time contributors spend time doing work that will not be
accepted as it duplicates functionality that is already provided with
the mapping files. Try to dissuade them from doing that by explaining
the reasons in the comment.
2018-02-01 07:03:03 +01:00
Martin Freund
90483e02e5 Quote $PYTHON variable to support paths with spaces v180126 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.
v171002
2017-10-02 13:05:14 +02:00
Frej Drejhammar
e174c2a0b7 Refactor load_mapping() to move line parsing to inner function
This is done in preparation to allowing mappings to contain quoted
characters.
2017-09-29 18:50:41 +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.
v170826
2017-08-25 11:28:52 +02:00
Frej Drejhammar
17c8a22066 Don't break if the destination directory name contains a space v170818 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.
v170624
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.
v170617
2017-06-05 18:41:44 +02:00
Frej Drejhammar
c252e6748e documentation: Point users to the issue tracker for support questions v170604 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.
v170101
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.
v160914
2016-09-14 14:15:11 +02:00
Frej Drejhammar
c614ae776b Fix "Branch ... modified outside hg-fast-export..." for sanitized branch names
The heads cache contains sanitized names, but we try to look up
unsanitized names, this is wrong. Switch to looking up the sanitized
name.
v160415
2016-04-15 15:46:47 +02:00
Frej Drejhammar
f8792d9c5c Switch from os.popen() to subprocess.check_output() for running git rev-parse
os.popen() uses the shell, this is dangerous when the branch-name
contains characters which are interpreted by the shell, therefore switch
to subprocess.check_output() which doesn't involve the shell.

This closes issue #66.
2016-04-15 15:43:21 +02:00
Frej Drejhammar
7224e420a7 Warn if one of the marks, mapping, or heads files are empty 2016-04-03 15:48:03 +02:00
Frej Drejhammar
b7cc6ab3bf verify_heads() needs to be aware of the branch renaming map
As all branches created on the git side are transformed by
sanitize_name(), this should be a safe backwards compatible change. If a
user is doing incremental imports and sanitize_name() now suddenly
modifies the branch name, verify_heads() would already have complained
on the first incremental run.

Thanks goes to Steve Tousignant<s.tousignant@gmail.com> for discovering
the problem.
2016-04-02 15:01:45 +02:00
Frej Drejhammar
6d8b4dbb11 Warn if opening a mapping file fails 2016-04-02 14:59:47 +02:00
Frej Drejhammar
832ee29bfa Refactor sanitize_name() to know about renaming map
Handle the lookup table for branch and tag renaming inside
sanitize_name().
2016-04-02 14:57:19 +02:00
Frej Drejhammar
46bf316a3c Explain why it is a bad idea to change sanitize_name()
This is a piece of code which frequently attracts pull requests which
are summarily rejected. As there is no "git blame" for rejected pull
requests, try to avoid misguided work by adding a comment at the
relevant place.
2016-04-02 12:28:03 +02:00
Frej Drejhammar
2d9b147a3e Remove obsolete and unsupported SVN tools
Hat tip to Sebastian Pipping for giving me a nudge to remove them.
2016-01-29 17:20:45 +01:00
Frej Drejhammar
f75057e49a Make --hg-hash work in incremental mode
When an import is restarted the first new note commit must use
refs/notes/hg^0 as the parent. As refs/notes/hg is only updated at the
end of a session we cannot have it present in all note commits. Neither
can we generate new marks for note commits as that would require a new
mapping scheme from hg versions numbers to git marks. A new mapping
scheme would break existing incremental import setups.

We therefore restructure the code to do the notes at the end of an
import session, thus only requiring a refs/notes/hg^0 reference in the
first commit.
2016-01-10 14:00:02 +01:00
Mark Raymond
042f0728cc Use backquotes 2015-12-12 10:34:02 +00:00
Mark Raymond
e7ea819a1f Use GitHub markdown 2015-12-12 10:25:31 +00:00
Mark Raymond
7d26b1a212 Rename README to README.md 2015-12-12 10:13:52 +00: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
Frej Drejhammar
a542b6aa97 refactor: Make author map loading more generic
This is the first step in adding mappings for branches and tags.
2015-08-16 13:09:51 +02:00
Frej Drejhammar
b9b6f2a57a Survive corrupt source repositories
Apparently a bug (http://bz.selenic.com/show_bug.cgi?id=3511) in
multiple released versions of Mercurial could produce commits where
files had absolute paths.

As a "healthy" repo should not contain any absolute paths, it should be
safe to always strip a leading '/' from the path and let the conversion
continue.
2015-08-15 20:26:02 +02:00
zed
d202200fd9 Make -e option apply to imported filenames
When the -e option is given, convert imported filenames just as we do
for metadata and author information.
2014-11-01 15:54:05 +01: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
frej
8a8bd170f7 Merge pull request #37 from ottxor/master
Fix ROOT if hg-fast-export is in PATH
2014-09-19 13:39:31 +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
Chris
29e19d696f Update README with note about no working directory
If you run the commands listed in usage

```bash
  mkdir repo-git # or whatever
  cd repo-git
  git init
  hg-fast-export.sh -r <repo>
```

you are not given a working directory to start working in. I was
caught off-guard by this when I ran `git status` and everything in the
repo was listed as deleted. A quick google search indicates I'm not
the only one who was surprised.
2014-05-30 13:36:48 +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
1be636db36 hg-fast-export.py: do not sort merge commit parents
In a merge commit, the first parent is always the same parent that
would be recorded if the commit were not a merge and the other
parent(s) record the commit(s) being merged in.

Preserving this order is important so that log --first-parent works
properly and also so that the merge history is not distorted by an
incorrect permutation of the DAG.

Remove the code that sorts the merge parents based on node id so
that the correct DAG order is preserved.
2014-03-28 16:17:12 +01:00
frej
7937dfaad5 Merge pull request #23 from ritcheyer/master
checking for - and converting - backslashes

Thank you for your contribution!
2014-03-16 16:05:47 +01:00
Kyle J. McKay
8822aa34e9 hg-fast-export.py: improve authors file compatibility
The authors file format accepted by git-svnimport and git-cvsimport
actually allows blank lines and comment lines that start with '#'.

Ignore blank lines and lines starting with '#' as the first
non-whitespace character to be compatible with the authors file
format accepted by the referenced tools.
2014-03-16 16:00:42 +01: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
b1d1265330 hg-fast-export.py: do not lose file mode changes
If the file mode changes (for example from 10644 to 10755), but the
actual text of the file itself does not, then the change could be
missed since the hashes would remain the same.

If the hashes match, also compare the gitmode values before deciding
the file is unchanged.
2014-03-16 16:00:42 +01:00
Kyle J. McKay
4be2fa46ee hg-fast-export.py: support older hg versions
Do not use the closesbranch function as it was added in later
versions of hg.  Use its definition instead.
2014-03-16 16:00:42 +01:00
Kyle J. McKay
728716375b hg-fast-export.py: restore compatibility with older python
Since hg runs and supports older versions of python, hg-fast-export.py
should too.  Replace dictionary comprehension with equivalent code that
supports versions of python older than 2.7.
2014-03-16 16:00:42 +01:00