Access to branch and merge information of a bug

Asked by Rohit Karajgi

Hi,

I am trying to use python-launchpadlib to scour bugs in my project and look for all files that the bug fix / merge modified and the number of files. The way we see on the Launchpad's Bug UI, "Diff: x number of lines (+/-) , y files modified" , I would like to see this information from the python API.

From the API, doc, i think the following APIs would do the job, but I am unable to find them in the library!

https://launchpad.net/+apidoc/1.0.html#bug_branch
https://launchpad.net/+apidoc/1.0.html#branch_merge_proposal
https://launchpad.net/+apidoc/1.0.html#preview_diff

The 'bug' object seems to have only the following methods: -->
bug.FIND_ATTRIBUTES bug.__reduce__ bug.bug_target_name bug.lp_entries
bug.FIND_COLLECTIONS bug.__reduce_ex__ bug.bug_watch bug.lp_get_named_operation
bug.FIND_ENTRIES bug.__repr__ bug.date_assigned bug.lp_get_parameter
bug.JSON_MEDIA_TYPE bug.__setattr__ bug.date_closed bug.lp_has_parameter
bug.__class__ bug.__sizeof__ bug.date_confirmed bug.lp_operations
bug.__delattr__ bug.__str__ bug.date_created bug.lp_refresh
bug.__dict__ bug.__subclasshook__ bug.date_fix_committed bug.lp_save
bug.__doc__ bug.__weakref__ bug.date_fix_released bug.lp_values_for
bug.__eq__ bug._create_bound_resource bug.date_in_progress

The code below finds the number of fixed bugs for my project. I want to take it further and find the number and the name of the files that were affected.
---------------
from launchpadlib.launchpad import Launchpad
cachedir = '/home/rohit/lpdocs/.launchpadlib/cache/'

launchpad = Launchpad.login_anonymously('scour bugs','production')

project = launchpad.projects['<my_proj>']
bugs = project.searchTasks(status = 'Fix Committed')

num_of_bugs = 0

for bug in bugs:
    print "%s:" % (bug.title)
    num_of_bugs = num_of_bugs + 1

print "\n", "Total 'Fix Committed' bugs found were: ",num_of_bugs

-------------------------------

Kindly help me out here, am I missing out something?

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu python-launchpadlib Edit question
Assignee:
No assignee Edit question
Solved by:
Rohit Karajgi
Solved:
Last query:
Last reply:
Revision history for this message
Rohit Karajgi (rohitk) said :
#1

I am using Ubuntu Maverick , and launchpadlib version is. 1.6.0

Revision history for this message
Rohit Karajgi (rohitk) said :
#2

I discovered that python launchpadlib gives all that is needed. The code below solves the problem:

def get_branch_merge_proposal_link(branch, launchpad):
       num = len(branch.landing_targets.entries)
       print branch.landing_targets.entries[0]['self_link']
       return launchpad.load(str(branch.landing_targets.entries[num - 1]['self_link']))

branch_link = bug.bug.linked_branches.entries[self.number_of_branches - 1]['branch_link']
branch = launchpad.load(str(branch_link))
bmp = get_branch_merge_proposal_link(branch, launchpad)

print bmp.preview_diff_link
preview = launchpad.load(str(bmp.preview_diff_link))
print preview.diffstat