Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slashes in hg branch names #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Slashes in hg branch names #75

wants to merge 2 commits into from

Conversation

PaulPrice
Copy link
Contributor

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

Based on felipec/git@a160978, with thanks to Felipe Contreras.
git's fast-export doesn't seem to like slashes in branch names
("error: there are still refs under 'refs/hg/origin/branches/<name>").
Work around this by replacing slashes with _SLASH_.
Generalise the *_to_*_spaces() functions top name_*_to_*() functions,
using the mapping NAMES_HG_TO_GIT.
Add a test for this failure mode.
@PaulPrice
Copy link
Contributor Author

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

@dusty-phillips
Copy link
Owner

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

dusty-phillips pushed a commit that referenced this pull request Apr 30, 2013
Fixes #80.

This is a controversial fix in some ways; an earlier commit explicitly turned on cloning of closed branches. However, I feel that the default should be to not clone closed branches. There are a few reasons for this.

The main one is that a closed branch in mercurial is generally considered the equivalent of a deleted branch in git. Therefore, we do not want the deleted branch in git.

A second one is that cloning closed branches can take a great deal of time that is, for the above reason, completely wasted.

A third one is that we have a few problems with branch naming (eg #78, #75, #62) that are caused by conflicting branched names. This fix does not solve those issues, but when the conflicting branches are closed branches, it does prevent them from causing a clone to fail outright.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants