Comment 14 for bug 1025886

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 1025886] Re: KeyError when using git+https in hg-git

On Thu, 2012-09-27 at 08:57 +0000, dom wrote:
> OK I looked into the tutorials at
> http://www.samba.org/~jelmer/dulwich/docs/tutorial/index.html and tried
> to understand how all this works. Sadly my simple example lead to the
> same error.
>
> What I tried is I cloned https://github.com/mozilla/django-csp.git
>
> git clone https://github.com/mozilla/django-csp.git
>
> then I started python and did the following
>
> from dulwich.repo import Repo
> from dulwich.client import HttpGitClient
> from dulwich.repo import Repo
>
> repo = Repo('django-csp')
> client = HttpGitClient('https://github.com/fmarier/django-csp.git')
> client.fetch('https://github.com/fmarier/django-csp.git', repo)
>
> which leads to the well known Exception
> ...
> C:\tools\Python27\lib\site-packages\dulwich-0.8.5-py2.7-win32.egg\dulwich\pack.p
> yc in _ensure_no_pending(self)
> 1242 def _ensure_no_pending(self):
> 1243 if self._pending_ref:
> -> 1244 raise KeyError([sha_to_hex(s) for s in self._pending_ref])
> 1245
> 1246 def _walk_ref_chains(self):
>
> KeyError: ['f69f776453ccec1a9f9bdc5bfaa49fd0e375f9b3', '2f01f206a41522c7e57ebce0
> 50b70dbecd93dd7a', 'a8c54dd23c7d444774aec1404bbaa326638aff1d', '8069b7ba8e8b8bfd
> 60ed84e949de3db08e7886c3']
>
> So my question now is what would be the right way to do this?

bin/dulwich just calls out to client.fetch() too, like your code does.
The problem is that fetch doesn't use add_thin_pack but add_pack which
can't handle thin packs and doesn't resolve external references.

Arguably this is a major bug in GitClient.fetch(). bzr-git doesn't use
GitClient.fetch(), which is why we haven't really noticed this before.
I'll bump the priority of this bug.

Cheers,

Jelmer