revert working tree using bzrlib

John Arbash Meinel john at arbash-meinel.com
Mon Nov 29 17:30:38 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 11/29/2010 10:44 AM, Zunbeltz wrote:
> Hi,
> 
> I started to use bzrlib from an script.
> I got thw WorkingTree object and I would like to revert the working tree
> back and ford; like with the command line
> bzr revert -r3
> 
> WorkingTree has the following method
> @needs_tree_write_lock
> def revert(self, filenames=None, old_tree=None, backups=True, pb=None,
> report_changes=False): 
> 
> But it is not documented, and I do not figure out where the revno should go.
> 
> TIA
> 
> Zunbeltz 

You pass it the tree that you want it to be reverted to. (old_tree). To
get that tree you need something like:

revno = 3
rev_id = tree.branch.revno_to_revision_id(revno)
rev_tree = tree.branch.repository.revision_tree(rev_id)
tree.revert(old_tree=rev_tree)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzz4z4ACgkQJdeBCYSNAAPLHgCfd+ghtmSpNA+hMOh1qOgfQp8v
chEAnjFFuBndQsDKKCOWSS8VoQ0GDL5N
=mtAh
-----END PGP SIGNATURE-----



More information about the bazaar mailing list