mnauw / git-remote-hg

Transparent bidirectional bridge between Git and Mercurial for Git
GNU General Public License v2.0
62 stars 5 forks source link

Fails to clone repo with branches "tests" and "tests/test1" #10

Closed taivokasper closed 7 years ago

taivokasper commented 7 years ago

I was successfully using git-remote-hg until someone added those two branches to the repository. Now I cannot pull or clone it.

I included a sample mercurial repository sample-mercurial-repo.zip unzip it with unzip -d /tmp /tmp/sample-mercurial-repo.zip and then try doing a local clone with git clone "hg::file:///tmp/nested-branches-repro" /tmp/git-nested-branches-repro

I get the following error:

Cloning into '/tmp/git-nested-branches-repro'... requesting all changes adding changesets adding manifests adding file changes added 3 changesets with 3 changes to 1 files progress revision walk 'bookmarks/master' (0/0) progress revision 0 'master' (0/1) progress revision 1 'tests' (0/1) progress revision 2 'tests/test1' (0/1) error: cannot lock ref 'hg/origin/refs/branches/tests/test1': 'hg/origin/refs/branches/tests' exists; cannot create 'hg/origin/refs/branches/tests/test1' fatal: Error while running fast-import Traceback (most recent call last): File "/usr/local/bin/git-remote-hg", line 1763, in sys.exit(main(sys.argv)) File "/usr/local/bin/git-remote-hg", line 1755, in main marks.store() File "/usr/local/bin/git-remote-hg", line 180, in store json.dump(self.dict(), open(self.path, 'w')) IOError: [Errno 2] No such file or directory: '/private/tmp/git-nested-branches-repro/.git/hg/marks-hg'

mnauw commented 7 years ago

The root problem here is that git does not allow/support both parent and parent/child as branches. One could address this using --single-branch when cloning and/or using a convenient refspec.

Alternatively, the above commit adds a configuration setting that makes the git-remote-hg filter out any unwanted remote names (branches, bookmarks) such as in particular unsupported cases. For example, the following should now work with the provided example: git clone -c remote-hg.ignore-name=test1 "hg::file:///tmp/nested-branches-repro" /tmp/git-nested-branches-repro

That should suffice to get things going again, or otherwise some other way around this limitation will have to be found.

taivokasper commented 7 years ago

Thank you very much!