Question

I want to go back in my bazaar history (change working tree) to find the commit that introduced a certain bug.

I do not want to delete any commits, just change my working tree until I found the bug, and then I want to go back to the latest revision to work on.

What are the two commands for that (going back to an earlier commit and afterwards checking out the latest revision again)?

Thanks in advance.

Was it helpful?

Solution

To revert the working tree back to a specific revision N:

bzr revert -rN

To revert the working tree to the latest revision in the branch:

bzr revert

OTHER TIPS

There are two ways to take your working tree back in time to revision N. The first has been mentioned by other answers here:

bzr revert -rN

That will modify all the files necessary to make your working tree match the contents of revision N. If you run bzr status it will show all those files as changed. If you run bzr commit then all those backward changes would get committed and your HEAD revision would now look like revision N.

To come back to the latest version in your branch:

bzr revert

You could also run bzr update, but that might get some newer revisions if your branch is a checkout.

The other option for going back in time is this:

bzr update -rN

The difference between the two is that bzr update makes it look as though no changes have been made. It's just that your working tree is out of date.

To come back to the latest version in your branch:

bzr update

Other commenters who answered with bzr revert -rN are certainly correct in the sense that that is the direct answer to the question as it was asked, however if you have a large number of commits to check through in order to test for the presence of a bug, it is vastly more efficient to use bisection. One time I was presented with a bug where the last known-good commit was 300 commits ago, and bisection found the guilty commit in only 8 passes (I mean, I only had to check 8 commits out of 300 in order to find the one that introduced the bug).

http://doc.bazaar.canonical.com/plugins/en/bisect-plugin.html

If you're feeling overwhelmed by the number of possible commits you need to check, this should reduce the amount of effort involved significantly!

To change the working tree to the state that it had in a previous revision N

bzr revert -r N

To update your working copy to the state it has in the latest revision:

bzr up

Bazaar Quick Reference Card

you can use bzr log --forward to see your previous versions with DESC sorting

and you can use bzr revert -r for change your version to the

if you want to revert to the last version just do bzr revert

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top