Commit Graph

430 Commits

Author SHA1 Message Date
Fantomas42
3ff69b5392 Fix mapping option, close #10 2013-06-21 18:35:38 +02:00
Frej Drejhammar
9a414ca8e2 Update README with pointer to the github issue tracker 2012-10-13 16:27:06 +02:00
Frej Drejhammar
c178d5c8a0 Rename hg-fast-export.txt to README 2012-10-13 16:18:15 +02:00
frej
ad72c608dc Merge pull request #7 from living180/master
Make Windows support actually work
2012-09-30 12:09:08 -07:00
Daniel Harding
7eaba68bc2 Make hg-fast-export (actually) work on Windows
Because on Windows sys.stdout is initially in text mode, any LF
characters written to it will be transformed to CRLF, which causes git
to blow up.  This change uses Windows platform-specific code to change
sys.stdout to binary mode.
2012-09-30 11:10:48 +01:00
frej
e63f780004 Merge pull request #6 from aried3r/master
Fix for Mercurial 2.3 compatibility
2012-08-10 09:10:44 -07:00
Anton Rieder
0dcbd3d195 Organized imports
After an update to Mercurial 2.3 the module 'repo' was removed and the
program crashed when trying to convert a repository. I checked the
imports with 'pyflakes' and removed all unused ones, repo (among
others) was never used.

http://www.selenic.com/repo/hg/rev/1ac628cd7113#l9.1
2012-08-07 01:35:09 +02:00
frej
11224c6c0b Merge pull request #5 from living180/master
Make hg-fast-export work on Windows
2012-06-01 08:05:31 -07:00
Daniel Harding
4ce8835d11 Make hg-fast-export work on Windows
* use sys.stdout.write instead of print to avoid end-of-line issues
* use os.devnull instead of hard-coding /dev/null
2012-05-28 18:57:30 +01:00
frej
d311f7fbc7 Merge pull request #4 from aried3r/master
Fixed a bug related to sanitizing branch names.
2012-05-20 10:31:40 -07:00
Anton Rieder
8f6adfd07c Applied rule #7 of git-check-ref-format
Rule #7 of git-check-ref-format states "7. They cannot end with a dot
'.'." which was not yet implemented in fast-export. This commit fixes
this.
2012-05-16 23:44:00 +02:00
Frej Drejhammar
b2f6d28722 Update documentation: The tool is no longer called hg-fast-import 2012-01-27 20:06:07 +01:00
Frej Drejhammar
a8b1481a8e Mention the author map file in the readme 2012-01-27 20:02:54 +01:00
David Wragg
32c481a98f Add usage info for the --force option 2012-01-23 16:17:44 +00:00
Barry Wardell
e24fa42b87 Commits with no parent need a reset command.
This fixes a problem where a repository is imported incorrectly when there is a merge
between two branches with no common history.
2011-12-09 19:29:14 +01:00
Barry Wardell
0a9570c676 Support the case where the author field has an empty email address, i.e. it is of the form 'name <>'. 2011-11-26 15:07:43 +01:00
Paul O’Shannessy
3e00d99d39 Use hg methods to extract name and email when doing user fixup 2011-10-18 16:20:54 -07: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
486690e176 Remove \" from the user string before trying to extract name and email
Signed-off-by: Frej Drejhammar <frej.drejhammar@gmail.com>
Reported-by: Cole Robinson <crobinso@redhat.com>

Thank's to Cole Robinson for reporting the bug and providing a fix
which was adapted to this patch.

The original bug report:

I was recently converting a few mercurial repositories to git, and
noticed certain commits had their date reset to Jan 1 1970.

An example repo:

http://hg.fedorahosted.org/hg/virt-manager

An example commit:

http://hg.fedorahosted.org/hg/virt-manager/rev/41182500ddef

After some poking, it seems the culprit was that the "author:" was
surrounded by quotation marks
2011-03-18 19:12:45 +01:00
David Wragg
c8a4584896 The "verifying branch" message is not very interesting
Particularly if the repo has hundreds of branches.
2010-09-29 02:02:32 +01:00
David Wragg
2b197f947f Simplify handling of parents of exported commit
The previous code did an awful lot of work to infer the parents of an
exported commit, incorporating information from many sources.  But
there were multiple bugs in this scheme, sometimes resulting in merge
commits with two parents pointing to the same commit object.

Instead, use a much more straightforward process of mapping the
parents stored in hg.
2010-09-29 02:02:22 +01:00
Rocco Rutte
1464dabbff Maintain backwards compatibility for ui setup
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2009-05-25 15:17:33 +02:00
Rocco Rutte
ff19982cc2 Update to work with mercurial ui refactorings
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2009-05-14 14:53:42 +02:00
Matthias Urlichs
0306977b28 hg-fast-export: Compare HG revisions when merging
hg-fast-export uses hg's branch order (from the log) when merging,
this is a problem. Consider the case:

HG repo A  has revisions 1-10. Repository B is cloned from that.
Subsequently, A adds revision 11, and B adds a different change which
also has revision 11. If B now pulls from A, A's rev11 will have the
number 12; if A then pulls from B, the reverse also holds. So the logs
are different even though they contain the exact same changes.

hg-fast-export will thus create different git repositories for A and B,
even though the contents are identical for all practical purposes.
In particular, the repos would be identical if A and B had used git from
the beginning.

To fix that, compare HG revisions instead of log positions.
2009-02-23 18:38:26 +01:00
Rocco Rutte
688623f17e hg-fast-export: Support branches without parents
Previously we fed the full revision only for the first one and deltas
for all following including branches being forked off. This doesn't work
with branches that are forked from revision 0. In case such a branch is
found, we now also feed the full revision.

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2009-01-27 15:34:46 +01:00
Frej Drejhammar
d6cd058bb3 hg-fast-export: Point out that only local repos are supported
Signed-off-by: Frej Drejhammar <frej.drejhammar@gmail.com>
2009-01-16 20:09:52 +01:00
Rocco Rutte
9f278a9792 hg-fast-export: Update todo now that tag movement is supported
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-12-30 21:52:32 +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
Rocco Rutte
02bc08886f hg-fast-export: Catch up with mercurial crew API changes
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-09-19 08:01:53 +02:00
Peter Colberg
e8ba36aa3f hg-fast-export.py: Use appropriate file mode for symlinks. 2008-09-19 07:55:45 +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
205c76749a Revert "hg2git: Replaces space with "_" in branches name"
The get_branch() function's purpose is to detect whether a mercurial
branch name actually should be considered the default branch.

Sanitizing branch and tag names for git is done in sanitize_name().

Noted by Jonathan Nieder.

This reverts commit cdfdae36c8.
2008-06-03 13:53:08 +02:00
Jonathan Nieder
6e3872b6a0 hg-fast-export.py: sanitize tildes (~) in branch names
In git-check-ref-format (1), there is the following rule for refnames:

	3. It cannot have ASCII control character (i.e. bytes
	   whose values are lower than \040, or \177 DEL), space,
	   tilde ~, caret ^, colon :, question-mark ?, asterisk *,
	   or open bracket [ anywhere;

and indeed, this rule is enforced by "git fast-import". hg-fast-export
already checked for all of the visible characters listed except for ~
and converted them to underscores. For some reason the tilde was
forgotten. This patch makes good on the omission.

Note that control characters are still left alone.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-06-03 08:49:57 +02:00
Rocco Rutte
d89b42a631 Clarify where 'HEAD' branch name comes from
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-05-30 13:44:07 +02:00
Felipe Zimmerle
cdfdae36c8 hg2git: Replaces space with "_" in branches name
Since space doesn't conform to GIT branches name standards,
it should be replaced or with another character.

Signed-off-by: Felipe Zimmerle <felipe.zimmerle@indt.org.br>
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2008-05-30 13:41:56 +02:00
Rocco Rutte
bc98d2c088 hg-fast-export.py: Cache possibly sanitized branch names
...instead of doing it for every single commit.

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-26 17:11:57 +02:00
Rocco Rutte
b200f9f8b3 Merge branch 'fixes'
* fixes:
  hg-fast-import.py: Sanitize ref names
  hg-fast-export.py: Don't attempt to dump revs beyond tip with -m
  hg-fast-export.py: Minor tweaks/cleanup
2007-10-26 14:29:18 +00:00
Rocco Rutte
4cc930807d hg-fast-import.py: Sanitize ref names
At least the opensolaris hg repo has tag names containing '*',
so sanitize all branch and tag names roughly according to the
specs for git-check-ref-format(1).

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-26 16:06:40 +02:00
Rocco Rutte
431c32de6b hg-fast-export.py: Don't attempt to dump revs beyond tip with -m
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-25 15:23:17 +02:00
Rocco Rutte
ec1be3d05f hg-fast-export.py: Minor tweaks/cleanup
Remove some unused variables, generalize dictionary-splitting and make
sure we don't sort filename lists twice (repo.status returns files
sorted already).

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-25 15:21:46 +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
82dccb0ea0 hg-reset.py: Use mangle_key() for load_cache() as hg-fast-export.py does
Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 08:28:18 +00:00
Rocco Rutte
ee510bb022 hg-fast-export.py: Rewrite merge logic
Merges were completely broken as they ended up with twice the same
parent in git. Still everything besides gitk seemed to work.

This because of 1) the incorrect assumption that a commit's parent is
the commit exported right before it and 2) some confusion with markes
being saved/loaded/used since git-fast-import doesn't allow for a ":0"
mark to map hg revision 1:1 to marks.

The merge "algorithm" now works like this:

1) If the commit's higher parent (highest hg rev), is not the last
commit exported for a particular branch, we issue a "from" command to
place it on top of it.

2) If the commit's lower parent exists, we issue a "merge" for it.

This is much simpler and seems to produce correct merges in git. And
while I'm at it, make output less confusing by prepending the target
branch name to each line.

The "twice the same parent" bug was discovered by Michele Ballabio on
the git list.

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 10:06:58 +02:00
Rocco Rutte
8551771d2b hg2git.py: Allow consumers to modify keys of dicts returned by load_cache()
By default, the key is not changed. This will allow us for fixing up the
off-by-one issue with marks restored using load_cache().

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 09:50:52 +02:00
Rocco Rutte
3d1f111d30 hg2git.py: Use git-rev-parse to get SHA1s instead of reading files below refs/ directly
This should now also properly support packed refs.

Signed-off-by: Rocco Rutte <pdmef@gmx.net>
2007-10-22 09:48:48 +02:00