assertionerror trips on pull --overwrite in dirstate branch with non-canonical history

Bug #177855 reported by Michael Hudson-Doyle
38
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
John A Meinel

Bug Description

There are apparently branches out there in the wild with sufficiently strange revision-history files as to seriously trip up bzr.dev when you try to pull --overwrite:

mwh@grond:tmp$ bzr.dev branch http://code.bitlbee.org/jelmer/win32
Branched 37 revision(s).
mwh@grond:tmp$ cd win32/
mwh@grond:win32$ bzr.dev pull --overwrite .
bzr: ERROR: exceptions.AssertionError: 36 != 37

Traceback (most recent call last):
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/commands.py", line 802, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/commands.py", line 758, in run_bzr
    ret = run(*run_argv)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/commands.py", line 492, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/builtins.py", line 646, in run
    possible_transports=possible_transports)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/workingtree.py", line 1537, in pull
    possible_transports=possible_transports)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/branch.py", line 1726, in pull
    run_hooks=run_hooks)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/branch.py", line 1525, in pull
    self.update_revisions(source, stop_revision, overwrite=overwrite)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/branch.py", line 1492, in update_revisions
    other_last_revision)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/home/mwh/src/bzr/bzr.dev/bzrlib/branch.py", line 1412, in set_last_revision_info
    assert len(history) == revno, '%d != %d' % (len(history), revno)
AssertionError: 36 != 37

bzr 1.1.0.dev.0 on python 2.5.1.final.0 (linux2)
arguments: ['/home/mwh/src/bzr/bzr.dev/bzr', 'pull', '--overwrite', '.']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_GB.UTF-8'
plugins:
  gtk /home/mwh/.bazaar/plugins/gtk [0.93.0dev0]
  launchpad /home/mwh/src/bzr/bzr.dev/bzrlib/plugins/launchpad [unknown]
  lpreview /home/mwh/.bazaar/plugins/lpreview [unknown]
  multiparent /home/mwh/src/bzr/bzr.dev/bzrlib/plugins/multiparent.pyc [unknown]
  svn /home/mwh/.bazaar/plugins/svn [0.4.5dev0]
*** 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.

If you upgrade to dirstate-tags, this goes away, but you're left with this strange situation:

mwh@grond:win32$ bzr.dev revno
37
mwh@grond:win32$ bzr.dev revision-history | wc -l
36

(bzr 0.92.0 reports the revno as 36, though).

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

Older versions of Bazaar allowed "bzr pull" to add nodes to the tip of your revision history, without renormalizing it. So if you had:

A
|\
B C
| |
D |
|/
E

A branch at E could have rh=A,B,D,E rn=4, or rh=A,C,E,rn=3

After about 0.8, we changed it so that 'pull' would always generate A,B,D,E

In 1.0 we changed 'pull' so that instead of doing:
  target.set_revision_history(source.get_revision_history())
To doing:
  target.set_last_revision_info(source.get_last_revision_info())

For <= dirstate branches (Branch5), set_last_revision_info regenerates the revision history from the repository. It then checks that the revno is correct. And as you notice, there is a mismatch.

Branch6 doesn't do the rebuild and check, (because it scales with O(history)).

So what we need is just an update to check/reconcile to fix this, and turn the error into a warning that you should run 'reconcile' on the source branch.

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

Just to clarify (on IRC it was confusing)
check/reconcile don't do this yet.

I'm proposing that we update check/reconcile to actually look for and fix this, respectively.

I'm putting something together for this now.

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

I've implemented support for detecting this in 'bzr check' and fixing it for 'bzr reconcile'

See the attached branch.

Changed in bzr:
milestone: none → 1.5
status: Triaged → Fix Committed
Revision history for this message
John A Meinel (jameinel) wrote :

this will be in 1.5rc1

Changed in bzr:
assignee: nobody → jameinel
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.