crashes when cloning local git repository with tags pointing at Tree objects

Bug #861973 reported by Andrew Cowie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar Git Plugin
Fix Released
High
Jelmer Vernooij

Bug Description

Attempting to run the command

    $ bzr branch ~/path/to/git/checkout target

Bazaar crashed with

    AttributeError: 'Tree' object has no attribute 'encoding'

So, as requested, the traceback:

    $ cat ~/.bzr.log
...

Thu 2011-09-29 01:45:00 +0000
0.044 bazaar version: 2.4.1
0.044 bzr arguments: [u'init-repo', u'.']
0.066 looking for plugins in /home/andrew/.bazaar/plugins
0.066 looking for plugins in /usr/lib/pymodules/python2.6/bzrlib/plugins
0.083 looking for plugins in /usr/lib/python2.6/dist-packages/bzrlib/plugins
0.092 encoding stdout as sys.stdout encoding 'UTF-8'
0.121 creating repository in file:///home/andrew/tmp/.bzr/.
0.145 Transferred: 0kB (0.0kB/s r:0kB w:0kB)
0.145 return code 0

Thu 2011-09-29 01:45:18 +0000
0.041 bazaar version: 2.4.1
0.042 bzr arguments: [u'branch', u'/home/andrew/torvalds/linux', u'upstream']
0.064 looking for plugins in /home/andrew/.bazaar/plugins
0.064 looking for plugins in /usr/lib/pymodules/python2.6/bzrlib/plugins
0.081 looking for plugins in /usr/lib/python2.6/dist-packages/bzrlib/plugins
0.094 encoding stdout as sys.stdout encoding 'UTF-8'
1.232 Transferred: 0kB (0.0kB/s r:0kB w:0kB)
1.235 Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 946, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 1150, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 699, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/pymodules/python2.6/bzrlib/commands.py", line 721, in run
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/cleanup.py", line 135, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/cleanup.py", line 165, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/bzrlib/builtins.py", line 1307, in run
    source_branch=br_from)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/dir.py", line 169, in sprout
    mapping=source_branch.mapping)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/fetch.py", line 668, in fetch_objects
    wants = determine_wants(remote_refs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/fetch.py", line 507, in determine_wants
    return list(potential - self._target_has_shas(potential))
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/fetch.py", line 529, in _target_has_shas
    revids = [self.source.lookup_foreign_revision_id(sha) for sha in shas]
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/repository.py", line 313, in lookup_foreign_revision_id
    mapping.revision_id_foreign_to_bzr)
  File "/usr/lib/python2.6/dist-packages/bzrlib/plugins/git/mapping.py", line 328, in import_commit
    if commit.encoding is not None:
AttributeError: 'Tree' object has no attribute 'encoding'

1.236 couldn't find apport bug-reporting library: No module named apport
1.268 return code 4
    $

AfC

Related branches

Revision history for this message
Andrew Cowie (afcowie) wrote :

Sorry, further context: this is on a Lucid server running the Bazaar PPA. As branching from a [local] Git repo appears to work fine on my Natty laptop, I can only assume there is a missing dependency. This system pristine, other than

    # apt-get install --no-install-recommends git-core
    # apt-get install --no-install-recommends bzr
    # apt-get install bzr-git

AfC

Revision history for this message
Martin Pool (mbp) wrote :

I don't think this is actually a version mismatch (although that's often the cause of attributeerrors) - it looks like there is a git hash pointing to a tree when it's expected to point to a commit.

affects: bzr → bzr-git
Revision history for this message
Martin Pool (mbp) wrote :

afc can reproduce this in ppa:bzr/daily, I'm just going to see if i can too.

Changed in bzr-git:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Martin Pool (mbp) wrote :

<AfC> poolie: :
 {'rev': <Revision id git-v1:c39ae07f393806ccf406ef966e9a15afc43cc36a>, 'self': <bzrlib.plugins.git.mapping.BzrGitMappingv1 object at 0x1699450>, 'commit': <Tree c39ae07f393806ccf406ef966e9a15afc43cc36a>, 'decode_using_encoding': <function decode_using_encoding at 0x33167d0>, 'lookup_parent_revid': <bound method type.revision_id_foreign_to_bzr of <class 'bzrlib.plugins.git.mapping.BzrGitMappingv1'>>}
<poolie> ok that's useful
<AfC> gesundheit
<poolie> and try 'up' 'p locals()' again
<AfC> ok
 > /usr/lib/python2.6/dist-packages/bzrlib/plugins/git/repository.py(332)lookup_foreign_revision_id()
<AfC> -> mapping.revision_id_foreign_to_bzr)
<AfC> {'foreign_revid': '5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c', 'commit': <Tree c39ae07f393806ccf406ef966e9a15afc43cc36a>, 'self': LocalGitRepository('file:///home/andrew/torvalds/linux/'), 'mapping': <bzrlib.plugins.git.mapping.BzrGitMappingv1 object at 0x1699450>}

Revision history for this message
Martin Pool (mbp) wrote :

(I'll investigate, but jelmer or someone else, feel free to steal it.)

I suspect this is because there's a tag pointing directly to a tree, not to a revision, and bzr-git can't import it. I think this is unusual but permitted in git.

And indeed there is

(Pdb) [(k,v) for (k,v) in refs.items() if v.startswith('5dc')]
[('refs/tags/v2.6.11-tree', '5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c'), ('refs/tags/v2.6.11', '5dc01c595e6c6ec9ccda4f6f69c131c0dd945f8c')]

One approach for this would be to let lookup_foreign_revision_id to be able to return None in the case that the object passed in is not actually a revision, and then just not to map them across.

Changed in bzr-git:
status: Confirmed → In Progress
Revision history for this message
Martin Pool (mbp) wrote :

as a workaround,

  git tag -d v2.6.11
  git tag -d v2.6.11-tree

will let bzr branch this repository it (or at least it gets a lot further along)

Jelmer Vernooij (jelmer)
summary: - bzr crashes when trying to branch a Git repo, with "AttributeError:
- 'Tree' object has no attribute 'encoding'"
+ crashes when cloning local git repository with tags pointing at Tree
+ objects
Changed in bzr-git:
assignee: nobody → Jelmer Vernooij (jelmer)
status: In Progress → Fix Committed
milestone: none → 0.6.3
Revision history for this message
Andrew Cowie (afcowie) wrote :

Lovely. Will this fix be available in ppa:bzr/daily automatically?

AfC

Revision history for this message
Andrew Cowie (afcowie) wrote : Re: [Bug 861973] Re: bzr crashes when trying to branch a Git repo, with "AttributeError: 'Tree' object has no attribute 'encoding'"

On Thu, 2011-09-29 at 05:03 +0000, Martin Pool wrote:
> as a workaround,
>
> git tag -d v2.6.11
> git tag -d v2.6.11-tree
>
> will let bzr branch this repository it (or at least it gets a lot
> further along)

Did your branch ever finish, Martin? Mine is getting ... stuck ... at
about 100k revisions.

AfC

Revision history for this message
Martin Pool (mbp) wrote :

> Did your branch ever finish, Martin? Mine is getting ... stuck ... at
> about 100k revisions.

I think I rebooted my laptop, thereby killing it. If it gets stuck,
please file a separate bug with a traceback.

Jelmer Vernooij (jelmer)
Changed in bzr-git:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.