0

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!

1 Answers1

0

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:

jelmer
  • 2,405
  • 14
  • 27
  • However, I cannot seem to get the repository.Repository.get_revision to work. I keep getting the (TypeError: unbound method get_revision() must be called with Repository instance as first argument (got str instance instead)) – newtopython Jun 11 '20 at 20:25
  • If you would like me to show you my script I will edit my initial post to include it as well as the error message. – newtopython Jun 11 '20 at 21:04
  • 1
    You need to call .get_revision() on a repository instance, not on the the Repository object itself. – jelmer Jun 11 '20 at 21:15
  • I used b = Branch.open (d1) c = b.dotted_revno_to_revision_id((r1,), _cache_reverse=False) parent_ids = b.repository.get_revision(c).parent_ids print parent_ids That seemed to work! – newtopython Jun 12 '20 at 13:12