pushing a non-stacking format into a non-repo bzrdir with a default stacking policy creates broken branch

Bug #259275 reported by Michael Hudson-Doyle
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Critical
Aaron Bentley

Bug Description

This transcript hopefully illustrates the problem:

mwh@grond:repos$ rm -rf ~/tmp/argh
mwh@grond:repos$ mkdir -p ~/tmp/argh
mwh@grond:repos$ bzr init b1
mwh@grond:repos$ cd b1
mwh@grond:b1$ touch file
mwh@grond:b1$ bzr add
added file
mwh@grond:b1$ bzr ci -m .
Committing to: /home/mwh/canonical/repos/b1/
added file

You need a passphrase to unlock the secret key for
user: "Michael Hudson <email address hidden>"
1024-bit DSA key, ID 6EC0EE48, created 2007-09-28

Committed revision 1.
mwh@grond:b1$ cd ../
mwh@grond:repos$ bzr branch b1 b2
Branched 1 revision(s).
mwh@grond:repos$ cd b2
mwh@grond:b2$ touch file2
mwh@grond:b2$ bzr add
added file2
mwh@grond:b2$ bzr ci -m ..
Committing to: /home/mwh/canonical/repos/b2/
added file2

You need a passphrase to unlock the secret key for
user: "Michael Hudson <email address hidden>"
1024-bit DSA key, ID 6EC0EE48, created 2007-09-28

Committed revision 2.
mwh@grond:b2$ mkdir t
mwh@grond:b2$ bzr push -d b1 t/b1
Created new branch.
mwh@grond:b2$ python2.4
Python 2.4.5 (#2, Jul 31 2008, 19:04:55)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bzrlib import bzrdir
>>> f = bzrdir.BzrDirFormat.get_default_format()
>>> d = f.initialize('t')
>>> d.get_config().set_default_stack_on('b1')
>>> import sys
>>> sys.exit()
mwh@grond:b2$ bzr push bzr+ssh://localhost/$(pwd)/t/b2
Using default stacking branch b1 at bzr+ssh://localhost//home/mwh/canonical/repos/b2/t/
using <bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5 object at 0x1782550> for stacking
Created new branch.
mwh@grond:b2$ bzr revision-history t/b2
bzr: ERROR: exceptions.KeyError: '<email address hidden>'

Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 857, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 797, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 499, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.5/site-packages/bzrlib/commands.py", line 818, in ignore_pipe
    result = func(*args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/builtins.py", line 1195, in run
    for revid in branch.revision_history():
  File "/usr/lib/python2.5/site-packages/bzrlib/decorators.py", line 138, in read_locked
    result = unbound(self, *args, **kwargs)
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 421, in revision_history
    history = self._gen_revision_history()
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 2109, in _gen_revision_history
    self._extend_partial_history(stop_index=last_revno-1)
  File "/usr/lib/python2.5/site-packages/bzrlib/branch.py", line 2133, in _extend_partial_history
    for revision_id in iterator:
  File "/usr/lib/python2.5/site-packages/bzrlib/repository.py", line 1607, in iter_reverse_revision_history
    parents = graph.get_parent_map([next_id])[next_id]
KeyError: '<email address hidden>'

bzr 1.6rc3 on python 2.5.2 (linux2)
arguments: ['/usr/bin/bzr', 'revision-history', 't/b2']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_NZ.UTF-8'
plugins:
  avahi /home/mwh/.bazaar/plugins/avahi [0.3.0dev0]
  bpm /home/mwh/.bazaar/plugins/bpm [unknown]
  bzrtools /usr/lib/python2.5/site-packages/bzrlib/plugins/bzrtools [1.6.0]
  dbus /home/mwh/.bazaar/plugins/dbus [unknown]
  fastimport /home/mwh/.bazaar/plugins/fastimport [unknown]
  gtk /home/mwh/.bazaar/plugins/gtk [0.95.0dev1]
  launchpad /usr/lib/python2.5/site-packages/bzrlib/plugins/launchpad [unknown]
  loom /home/mwh/.bazaar/plugins/loom [1.4.0dev0]
  lpreview /home/mwh/.bazaar/plugins/lpreview [unknown]
  merged /home/mwh/.bazaar/plugins/merged [unknown]
  pqm /home/mwh/.bazaar/plugins/pqm [1.4.0dev0]
  pybloom /home/mwh/.bazaar/plugins/pybloom [unknown]
  search /home/mwh/.bazaar/plugins/search [1.6.0dev0]
  service /home/mwh/.bazaar/plugins/service [unknown]
  svn /home/mwh/.bazaar/plugins/svn [0.4.11rc1]
*** 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.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

FWIW, if I push to to a local path instead of over bzr+ssh, the push fails during building the working tree, but it's already created an identically broken branch.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Here's a test case (which explodes in tree building, as mentioned):

    def test_push_doesnt_create_broken_branch(self):
        tree = self.make_branch_and_tree('a')
        self.build_tree(['a/file'])
        tree.add('file')
        tree.commit('commit')
        self.make_bzrdir('.').get_config().set_default_stack_on('a')
        self.run_bzr('push -d a b')

(I put it in TestPush in bzrlib.tests.blackbox.test_push.TestPush)

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

For 1.6 I just disabled the autodetection of 'stack-on' from a containing bzrdir.

The specific issue is that "sprout()" was updated to automatically upgrade the Branch when it automatically upgraded the repository. But clone() was not given the same treatment. (so bzr push breaks, but bzr branch works.)

I think *a* correct fix is to only pay attention to the containing policy when the source format supports it.

Another possible fix is to automatically upgrade during "push" as well as during "branch". (The current code in bzr.dev will upgrade the repository without upgrading the branch.)
However, that seems a bit iffy. It is arguably true if the user explicitly set the 'default_stack_on' value.

It interacts badly with LP if LP sets that value by default. (Since then pushing to LP would automatically upgrade your branches in a non-backwards-compatible manner.)

We could blame LP for that, but really I think we want bzr + LP to work together nicely. (It could be an LP whitelist, etc.)

Either way, a fix is still needed for bzr.dev, 1.6 is taking the easy way out and just disabling the feature. So at least LP won't have to deal with having some clients respond incorrectly to the setting.

In the end, we need to decide as a project what should happen, so I'll bring it up on the mailing list.

Changed in bzr:
importance: High → Critical
Aaron Bentley (abentley)
Changed in bzr:
assignee: nobody → abentley
Revision history for this message
Aaron Bentley (abentley) wrote :

bzr.dev passes the test_push_doesnt_create_broken_branch test case.

Changed in bzr:
status: Triaged → 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.