Commit Graph

452 Commits

Author SHA1 Message Date
Frej Drejhammar
b51c58d3e0 Merge branch 'thetradedesk-master'
Closes #144
2018-12-06 21:51:32 +01:00
Johan Henkens
cadcfcbe90 Move filter_contents to plugin system 2018-12-05 13:25:48 -08:00
Johan Henkens
5e7895ca6b Add branch_name_in_commit plugin 2018-12-05 13:25:48 -08:00
Johan Henkens
679103795b Add dos2unix plugin 2018-12-05 13:25:48 -08:00
Johan Henkens
e895ce087f Add plugin system 2018-12-05 13:25:47 -08:00
Johan Henkens
850094c498 Add gitattributes, additional ignores 2018-12-05 13:25:47 -08:00
Daniel Small
2bb173ef68 hg 4.7: Replace call to util.email with templatefilters.email
This change is required for Mercurial 4.7 support and fixes #137.
2018-08-11 15:49:08 +02: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
Frej Drejhammar
eca99b61eb Merge branch 'atykhyy-as-binary'
This closes #95
2018-06-22 16:46:10 +02:00
Anton Tykhyy
89db1d93cf Add --filter-contents 2018-06-17 21:09:59 +03:00
Frej Drejhammar
e200cec39f Adapt to changes in Mercurial 4.6
Starting with Mercurial 4.6 repo.lookup() no longer accepts raw hashes
for lookups.
v180610
2018-06-10 15:51:09 +02:00
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