Switching to the local branch creates recursion

Bug #1018628 reported by Nils Durner
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Bazaar
Triaged
High
Unassigned
Breezy
Fix Released
High
Jelmer Vernooij

Bug Description

$ bzr init .
$ bzr commit -m 1 --unchanged
$ bzr commit -m 2 --unchanged
$ bzr switch -r 1

bzr: ERROR: exceptions.RuntimeError: maximum recursion depth exceeded while calling a Python object

$ bzr log

bzr: ERROR: exceptions.RuntimeError: maximum recursion depth exceeded in cmp

Related branches

Revision history for this message
Nils Durner (ndurner) wrote :
description: updated
Revision history for this message
Nils Durner (ndurner) wrote :

To rescue the corrupted branch:
1. echo "Bazaar Branch Format 7 (needs bzr 1.6)" > .bzr/branch/format

2. echo > .bzr/branch/location

3. open .bzr/checkout/dirstate, search for the most recently changed filename and copy the ID from the end of the line (between @ and ^@, starts with the user's email address)

4. enter the last revision number and the ID in .bzr/branch/last-revision:
echo "2 <email address hidden>" > .bzr/branch/last-revision

5. bzr log to check if the branch work again

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

This isn't because of the '-r' as it can be reproduced with 'bzr switch .'

The issue is that you have a full branch, which you then issue 'bzr switch' which makes us try to change your branch into a checkout. However, since you haven't specified a location, we use the local branch as the target of the switch. Which leaves us with a branch reference pointing at itself (and thus infinite recursion).

We seem to intentionally be changing a regular branch into a branch reference during 'bzr switch', to make it easier for people to switch to 'some other' branch.

1) We could stop doing that entirely. If someone is in a regular branch, require something else in order to turn their tree into a checkout of a 3rd branch.

2) Add a check that the target of the switch is, indeed, a different branch. If it is the same location, refuse.

3) Add a check that if only '-r' is given, then the local tree is already a checkout (has a branch reference) and not a full branch.

summary: - Switching to previous rev corrupts branch
+ Switching to the local branch creates recursion
Revision history for this message
Nils Durner (ndurner) wrote : Re: [Bug 1018628] Re: Switching to the local branch creates recursion

What I had originally intended is this: "svn switch -r" is used to
(temporarily) switch the working copy to that particular revision (to see
if a bug was already present back then, for example). Would it make sense
for bzr to up/downgrade the working tree without touching the branch if
just -r is passed (would that be the same as #3 - is a branch with a
working tree technically a checkout with a branch reference?)?

Revision history for this message
Alexander Belchenko (bialix) wrote :

Nils Durner пишет:
> What I had originally intended is this: "svn switch -r" is used to

You want `bzr update -r` instead.

--
All the dude wanted was his rug back

Revision history for this message
Spundun (spundun) wrote :

https://code.launchpad.net/~spundun/bzr/bzr-1018628

Created a new branch with three blackbox unittests.

I banged my head against the TestCase api for a while and gave up to create a simpler script test case. feel free to port them to the faster api.

Spundun (spundun)
tags: added: colocate
Revision history for this message
Spundun (spundun) wrote :

Simplified the test where a simple colo branch creation locks the directory path.

                $ mkdir mywork
                $ cd mywork
                $ bzr init
                Created a standalone tree (format: 2a)
                $ echo A > a && bzr add a && bzr commit -m A
                $ bzr switch -b br1
                $ cd ..
                $ mv mywork mywork1
                $ cd mywork1
                $ bzr branches

This should not give error.

Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
Jelmer Vernooij (jelmer)
tags: added: colocated switch
removed: check-for-breezy colocate
Changed in brz:
status: New → Triaged
importance: Undecided → High
assignee: nobody → Jelmer Vernooij (jelmer)
Jelmer Vernooij (jelmer)
Changed in brz:
milestone: none → 3.0.0
Jelmer Vernooij (jelmer)
Changed in brz:
status: Triaged → In Progress
Jelmer Vernooij (jelmer)
Changed in brz:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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