Go back to old revision in Bazaar
Asked Answered
P

5

32

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.

Perreira answered 13/3, 2012 at 13:11 Comment(1)
I've never used Bazaar, but in SVN the operations you refer to are "update to version" and "update to head". fyi in case the relevant commands in Bazaar use similar language.Cringle
P
23

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
Punic answered 13/3, 2012 at 20:33 Comment(1)
This makes bzr consider your working tree to have local changes, and bzr blame then does not do what I expected. bzr update -r<rev> from Don's answer did what I wanted better, which was pure archaeology in the form of "find the commit that introduced a certain bug". Using bzr update -r<rev> and tracking back using bzr blame following works better to follow through renames and refactoring.Dwain
D
16

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
Dusk answered 29/6, 2012 at 0:14 Comment(0)
F
5

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!

Floribunda answered 3/8, 2013 at 14:29 Comment(0)
E
4

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

Exasperate answered 13/3, 2012 at 14:33 Comment(0)
I
0

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

Intrusion answered 30/3, 2017 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.