I am new to Python and Linux and I have been tasked with a project that will utilize the bzrlib toolbox written in python.
The task is as follows. "Create a Python function which accepts the file system path to a local Bazaar (bzr) project and returns the revision and branch of the project's baseline. Use a driver to demonstrate function objectives"
So basically if I wanted to know the last known merged revision off of the project's baseline I would call the function on the linux command line and then enter the Directory where the repository is located and Revision number from the baseline that I want to check.
Here are some examples of what the input and output may look like:
INPUT: /home/example-directory INPUT: 134
OUTPUT: 133
INPUT: /home/example-directory INPUT: 176
OUTPUT: 170.4.5
I have been reading through the bzrlib API to try and find what I am looking for but so far no luck. If anybody has an idea of how I might do this I would appreciate it!
You can use the Branch.open method to open a branch from a path.
The .repository
attribute of the branch can be used to access its repository.
There are three relevant functions that you'd want to use:
Branch.dotted_revno_to_revision_id to convert the revision number to a revision id.
Repository.get_revision to retrieve the metadata for the revision. The "parent_ids" attribute of the metadata will have the parent ids.
Branch.revision_id_to_dotted_revno to convert the revision ids back to dotted revision numbers