gitifyhg icon indicating copy to clipboard operation
gitifyhg copied to clipboard

KeyError while cloning mercurial repository

Open viciu opened this issue 11 years ago • 7 comments

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

viciu avatar Aug 23 '13 08:08 viciu

Can you point us to the Mercurial repo so we can reproduce? And what version of git are you using?

PaulPrice avatar Aug 23 '13 10:08 PaulPrice

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.

viciu avatar Aug 23 '13 18:08 viciu

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.

viciu avatar Aug 23 '13 20:08 viciu

Try running DEBUG_GITIFYHG=on git clone gitifyhg:// to get much more useful information.

dusty-phillips avatar Aug 23 '13 21:08 dusty-phillips

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.

viciu avatar Aug 23 '13 22:08 viciu

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 , hg push --bookmark ). Then waited for a while and cloned again. Worked.

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).

viciu avatar Aug 23 '13 22:08 viciu

Probably an empty bookmark. Fixed in git-remote-hg https://github.com/felipec/git/commit/bc82d404d3bdbfa2ba45f30a3caa469ad080ee5b.

felipec avatar May 01 '14 01:05 felipec