dusty-phillips / gitifyhg

Tools for using git as a client to mercurial repositories
GNU General Public License v3.0
62 stars 17 forks source link

Slashes in hg branch names #75

Open PaulPrice opened 11 years ago

PaulPrice commented 11 years ago

The second part of issue #62. Filing separate pull request so Travis can process and bless the patch.

PaulPrice commented 11 years ago

Though Travis doesn't seem to be running it....

dusty-phillips commented 11 years ago

I think the travis issue might be because I cherry-picked the relative filenames commit.

I'm pretty confident git should not be choking just because slashes exist in the ref name. It's legal to have slashes in branch names in normal git usage. If this really is breaking fast-import, then the bug is almost certainly in git, and working around it with substitution is not the correct fix.

Does the test fail if you use completely different branch names with slashes (ie feature/one and task/two)? My intuition is that this will succeed, and the bug we are seeing with pypy is not because the slashes exist, but because they share a common prefix. I am hopeful that this can be fixed without replacing the slashes in branch names.

My guess is that this happens because gitifyhg makes the false assumption that branches contain only one slash somewhere, and a split('/') or something similar is inadvertently discarding the remainder of the branch name, so it gets confused with an existing ref.

I may be completely off base here; did your research discover otherwise?

PaulPrice commented 11 years ago

Jed (in #62) points out that this is due to a limitation in git: there cannot be both feature and feature/foo branches. In light of that (and the fact that, as you say, slashes are perfectly legitimate), my solution is not the right one, but we need to catch the particular case that's causing problems and munge the names only then.

PaulPrice commented 11 years ago

In order to fix this (and other related problems such as #78), I think we need to introduce a system for mapping branch names between hg and git. Some problems (e.g., clash between foo and foo/bar) could be automatically detected and mapped while others (case insensitivity on Mac?) might require some user intervention (user specifies mapping in git config?). I have a very very rough implementation, but I want to clean it up and do it properly before submitting for merge.