gitifyhg
gitifyhg copied to clipboard
KeyError while cloning mercurial repository
While cloning mercurial repository with gitifyhg following error occurs:
progress revision 4699 'master' (4700/4728)
Traceback (most recent call last):
File "/usr/local/bin/git-remote-gitifyhg", line 9, in <module>
load_entry_point('gitifyhg==0.8.2', 'console_scripts', 'git-remote-gitifyhg')()
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/gitifyhg.py", line 342, in main
HGRemote(*[x.decode('utf-8') for x in args]).process()
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/gitifyhg.py", line 202, in process
getattr(self, 'do_%s' % command)(parser)
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/gitifyhg.py", line 305, in do_import
HGImporter(self, parser).process()
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/hgimporter.py", line 99, in process
self.process_ref(name, reftype, head)
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/hgimporter.py", line 196, in process_ref
output("from :%u" % self.marks.revision_to_mark(head.node()))
File "/usr/local/lib/python2.7/dist-packages/gitifyhg/util.py", line 231, in revision_to_mark
return self.revisions_to_marks[hghex(revision)]
KeyError: '0000000000000000000000000000000000000000'
fatal: stream ends early
fast-import: dumping crash report to /home/application/.git/fast_import_crash_20228
fatal: Error while running fast-import
Can you point us to the Mercurial repo so we can reproduce? And what version of git are you using?
I'm using git version 1.7.10.4 With mercurial repo - this is private repo, so not really. But I'm happy to do some debugging if you guide me.
I put try/except here: File "/usr/local/lib/python2.7/dist-packages/gitifyhg/hgimporter.py", line 196, in process_ref output("from :%u" % self.marks.revision_to_mark(head.node())):
# make sure the ref is updated
output("reset %s" % gitify_ref)
try:
output("from :%u" % self.marks.revision_to_mark(head.node()))
except KeyError:
print("Key Error at %s" % head.node())
The message was this:
error: refs/remotes/origin/experimental_branch does not point to a valid object!
but repo was cloned.
When I tried to open this experimental_branch in the web interface (bitbucket), this message was shown:
The branch 'experimental_branch' does not exist.
Try running DEBUG_GITIFYHG=on git clone gitifyhg://
Thanks.
When turned debug, It shows versions: DEBUG: 'gitifyhg version 0.8.2' DEBUG: 'Mercurial version 2.2.2' DEBUG: 'Python version 2.7.3 (default, Jan 2 2013, 13:56:14) [GCC 4.7.2]'
then starts logging source code from the repository to sys.stderr, so further is not much readable.
I have a workaround for this issue - I removed broken bookmark from mercurial repo using hg commands on another copy of the repo, cloned with hg (hg bookmark --delete
Maybe in case of this situation it would be good to display message like 'please remove broken bookmark using hg' ? As far as I know you can't do that via gitifyhg (at least something like git push origin --delete <branchName> didn't work).
So to reproduce, broken bookmark in mercurial is needed (one can do that creating bookmark, then deleting history via hg I guess).
Probably an empty bookmark. Fixed in git-remote-hg https://github.com/felipec/git/commit/bc82d404d3bdbfa2ba45f30a3caa469ad080ee5b.