bzr log -r <merged-revision> on a remote branch fails with AttributeError

Bug #162486 reported by Francis J. Lacoste
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Low
John A Meinel

Bug Description

It seems that trying to access a revision that was part of a merged fails on a remote branch (bzr+ssh:).

For example, when I run:
$ bzr log -r 5088.2.4 bzr+ssh://devpad.canonical.com/code/leonardr/launchpad/xml-rpc-get-44871bzr: ERROR: exceptions.AttributeError: 'RemoteBranch' object has no attribute '_revision_id_to_revno_cache'

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 802, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 768, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1702, in run
    rev1 = rev2 = revision[0].in_history(b)
  File "/usr/lib/python2.5/site-packages/bzrlib/revisionspec.py", line 225, in in_history
    return self._match_on_and_check(branch, revs)
  File "/usr/lib/python2.5/site-packages/bzrlib/revisionspec.py", line 207, in _match_on_and_check
    info = self._match_on(branch, revs)
  File "/usr/lib/python2.5/site-packages/bzrlib/revisionspec.py", line 325, in _match_on
    revision_id_to_revno = branch.get_revision_id_to_revno_map()
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 192, in get_revision_id_to_revno_map
    if self._revision_id_to_revno_cache is not None:
AttributeError: 'RemoteBranch' object has no attribute '_revision_id_to_revno_cache'

bzr 0.92.0.candidate.1 on python 2.5.1.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'log', '-r', '5088.2.4', 'bzr+ssh://devpad.canonical.com/code/leonardr/launchpad/xml-rpc-get-44871']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'fr_CA.UTF-8'
plugins:
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [0.92.0]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  multiparent /usr/lib/python2.5/site-packages/bzrlib/plugins/multiparent.pyc [unknown]
  pqm /usr/lib/python2.5/site-packages/bzrlib/plugins/pqm [unknown]

** Please send this report to <email address hidden>
   with a description of what you were doing when the
   error occurred.

Tags: hpss
Revision history for this message
John A Meinel (jameinel) wrote :

The fix is pretty trivial:
=== modified file 'bzrlib/remote.py'
--- bzrlib/remote.py 2007-11-04 20:35:32 +0000
+++ bzrlib/remote.py 2007-11-13 20:09:45 +0000
@@ -934,6 +934,7 @@
         # will try to assign to self.tags, which is a property in this subclass.
         # And the parent's __init__ doesn't do much anyway.
         self._revision_history_cache = None
+ self._revision_id_to_revno_cache = None
         self.bzrdir = remote_bzrdir
         if _client is not None:
             self._client = _client

The reason is that RemoteBranch isn't calling the base Branch.__init__() [there is a comment as to why], but it is using the base classes' implementation of get_revision_id_to_revno_map(), which checks for it.

The only other piece necessary is to add a branch_implementations test that get_revision_id_to_revno_map() works correctly. I'll try and put that together.

Changed in bzr:
assignee: nobody → jameinel
importance: Undecided → Low
milestone: none → 1.0rc1
status: New → Fix Committed
Revision history for this message
John A Meinel (jameinel) wrote :

It turns out that there is a test for this function. The bug is masked, though. Because when we unlock a branch, we set self._revision_id_to_revno_cache = None.

So:

  remote = bzrlib.branch.Branch.open('bzr+ssh://remote/branch')
  remote.lock_read()
  remote.get_revision_id_to_revno_map() # Fail
  remote.unlock()
  remote.lock_read()
  remote.get_revision_id_to_revno_map() # Success

I'll try to update the test to be more sensitive about this condition.

John A Meinel (jameinel)
Changed in bzr:
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.