schacon / hg-git

mercurial to git bridge, pushed to directly from the hg-git plugin in Hg
GNU General Public License v2.0
620 stars 71 forks source link

Skip exporting hg tags whose names are not valid as git tag name #261

Closed nsuke closed 10 years ago

nsuke commented 10 years ago

When converting a mercurial repo to a git repo as in the README:

$ mkdir git-repo; cd git-repo; git init; cd ..
$ cd hg-repo
$ hg bookmarks hg
$ hg push ../git-repo

if the original repository contains tags which names are not valid as git tag name (e.g. names containing '*'), the push fails with dulwich error caused by an invalid git tag name.

This patch will allow hg-git to skip those tags and complete rest of the process.

durin42 commented 10 years ago

Can you please add a test?

nsuke commented 10 years ago

As you can see in the test code:

git should have only the valid tag alph#a but have full commit log including the missing invalid bet*a tag commit

the test is kind of awkward since hg commit log have creation of the skipped tag.

I would've changed the code so that hg-git aborts exporting, printing error message instead of warning, which is still minor improvement over aborting with an exception since we can clearly inform the user of what he should do to solve the problem. Let me know if you prefer the way, it's trivial.

In my opinion, having to remove or rename funky tags to do the export itself in the first place is less convenient to get started than having slightly unclean commit log and informed of what is skipped, being able to freely fix it (or not) later.

durin42 commented 10 years ago

This is effectively merged, but I did some history editing to clean things up. Thanks!