Pushing from bzr 1.3 => bzr < 1.2 is broken for Branch5 (AssertionError)

Bug #214894 reported by Selene ToyKeeper
4
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Critical
John A Meinel

Bug Description

While trying to push to a remote repo, bzr failed with an error about the revno being different than the length of the repo's history. The sequence leading up to this was, approximately:

  gutsy-box> bzr init foo
  ... work on stuff ...
  gutsy-box> bzr commit

  sid-box> bzr branch bzr+ssh://gusty-box/foo
  ... work on stuff ...
  sid-box> bzr commit
  sid-box> bzr push --remember bzr+ssh://gusty-box/foo

The gutsy box is x86_64, running bzr 0.90-1. The sid box is ia64, running bzr 1.3-1. Perhaps this is a version mismatch, or just an old bug.

The symptoms look similar to bug 91725 and bug 177855, but the versions and commands invoked are different, so it's hard to say whether this is a new issue.

The full output was:

~/src/project/> bzr push --remember bzr+ssh://b/home/scott/src/project
This transport does not update the working tree of: bzr+ssh://b/home/scott/src/project/. See 'bzr help working-trees' for more information.
Server is too old for fast get_parent_map, reconnecting. (Upgrade the server to Bazaar 1.2 to avoid this)
bzr: ERROR: exceptions.AssertionError: 3 != 4

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 834, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 790, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.4/site-packages/bzrlib/builtins.py", line 837, in run
    stop_revision=revision_id)
  File "/usr/lib/python2.4/site-packages/bzrlib/decorators.py", line 127, in read_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1556, in push
    _override_hook_source_branch=_override_hook_source_branch)
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1598, in _push_with_bound_branches
    result = self._basic_push(target, overwrite, stop_revision)
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1617, in _basic_push
    target.update_revisions(self, stop_revision)
  File "/usr/lib/python2.4/site-packages/bzrlib/remote.py", line 1525, in update_revisions
    return self._real_branch.update_revisions(
  File "/usr/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1480, in update_revisions
    other_last_revision)
  File "/usr/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1398, in set_last_revision_info
    assert len(history) == revno, '%d != %d' % (len(history), revno)
AssertionError: 3 != 4

bzr 1.3 on python 2.4.5.candidate.1 (linux2)
arguments: ['/usr/bin/bzr', 'push', '--remember', 'bzr+ssh://b/home/scott/src/project']
encoding: 'ANSI_X3.4-1968', fsenc: 'ANSI_X3.4-1968', lang: 'C'
plugins:
  bzrtools /usr/lib/python2.4/site-packages/bzrlib/plugins/bzrtools [1.3.0]
  gtk /usr/lib/python2.4/site-packages/bzrlib/plugins/gtk [0.93.0]
  launchpad /usr/lib/python2.4/site-packages/bzrlib/plugins/launchpad [unknown]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.
[1] 22676 exit 4 bzr push --remember bzr+ssh://b/home/scott/src/project

Afterward, the original (gutsy) repo is in a strange state...

(~/src/project/> bzr check
checked branch file:///home/scott/src/project/ format Bazaar-NG branch format 5
checked repository <bzrlib.transport.local.LocalTransport url=file:///home/scott/src/project/> format <RepositoryFormatKnit1>
     4 revisions
     5 unique file texts
     4 repeated file texts
     3 weaves
~/src/project/> bzr revno
2
~/src/project/> bzr revision-history | wc -l
2

It looks like the transaction is halfway completed.

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

Looking into this, the problem is with the RemoteRepository.get_parent_map() code.

Specifically, if the server doesn't support get_parent_map() it falls back to just calling get_revision_graph().

However, for nodes with 0 parents, get_parent_map() returns ('null:',) while get_revision_graph() just returns ().
for get_parent_map(), a return of () means that the revision is a ghost.

This shows up for Branch5, because it checks the normalization of history when you call set_last_revision_info(). And the _lefthand_history() code iterates backwards, stopping when it finds a ghost.

So when you "bzr push bzr+ssh://" a Branch5 (dirstate) it checks the length of the remote history, and doesn't include the first revision (because it thinks it is a ghost).

The fix isn't very hard, you just need to filter the get_revision_graph() call and substitute ('null:',) for any () nodes.

I'll work up a patch. This is probably worthy of a 1.3.2 fix if we really want to allow bzr >1.2 to interoperate with bzr <1.2 (and 1.3.2 because that is easier to get into Hardy than asking them to release 1.5)

Changed in bzr:
assignee: nobody → jameinel
importance: Undecided → Critical
status: New → Triaged
Revision history for this message
John A Meinel (jameinel) wrote :

There is a workaround, which is to use the same version of bzr on the client and the server. If both are <1.2 or both are >1.2 this bug won't trigger.
Or if you upgrade to > Branch6 (--dirstate-tags, or --pack-0.92).
Or you can push using sftp:// instead of bzr+ssh://.

Changed in bzr:
milestone: none → 1.5
status: Triaged → Fix Committed
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 214894] Re: AssertionError when pushing to remote bzr+ssh repository (len(history) != revno)
  • unnamed Edit (189 bytes, application/pgp-signature; name=signature.asc)

On Tue, 2008-04-29 at 19:53 +0000, John A Meinel wrote:
> Looking into this, the problem is with the
> RemoteRepository.get_parent_map() code.
>
> Specifically, if the server doesn't support get_parent_map() it falls
> back to just calling get_revision_graph().
>
> However, for nodes with 0 parents, get_parent_map() returns ('null:',) while get_revision_graph() just returns ().
> for get_parent_map(), a return of () means that the revision is a ghost.
>
> This shows up for Branch5, because it checks the normalization of
> history when you call set_last_revision_info(). And the
> _lefthand_history() code iterates backwards, stopping when it finds a
> ghost.
>
> So when you "bzr push bzr+ssh://" a Branch5 (dirstate) it checks the
> length of the remote history, and doesn't include the first revision
> (because it thinks it is a ghost).
>
> The fix isn't very hard, you just need to filter the
> get_revision_graph() call and substitute ('null:',) for any () nodes.
>
> I'll work up a patch. This is probably worthy of a 1.3.2 fix if we
> really want to allow bzr >1.2 to interoperate with bzr <1.2 (and 1.3.2
> because that is easier to get into Hardy than asking them to release
> 1.5)

Good catch. I think we should do a point release.

-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

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

Bug attachments

Remote bug watches

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