~doctormo/python-snippets/lp-merge-request-example

« back to all changes in this revision

Viewing changes to launchpadlib/merge-request.py

  • Committer: Martin Owens
  • Date: 2010-01-29 19:09:02 UTC
  • Revision ID: doctormo@gmail.com-20100129190902-zlr1r3sweidzkf7v
Add in new merge request example.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Code by Martin Owens, (c) 2010 GPLv3
 
2
 
 
3
import os
 
4
import time
 
5
from launchpadlib.launchpad import Launchpad, STAGING_SERVICE_ROOT
 
6
from launchpadlib.credentials import Credentials
 
7
 
 
8
CACHE_DIR = os.path.expanduser('~/.cache/launchpadlib/')
 
9
 
 
10
if not os.path.exists(CACHE_DIR):
 
11
    os.makedir(CACHE_DIR)
 
12
 
 
13
# connect ot the staging service of launchpad
 
14
lp = Launchpad.login_with("python-snippets", STAGING_SERVICE_ROOT)
 
15
 
 
16
branch = lp.branches.getByUniqueName(unique_name='lp:~foo/bar/child')
 
17
parent = lp.branches.getByUniqueName(unique_name='lp:~foo/bar/parent')
 
18
 
 
19
reviewer  = parent.reviewer
 
20
if not reviewer:
 
21
    reviewer = parent.owner
 
22
 
 
23
result = self.source_branch.createMergeProposal(
 
24
    initial_comment=comment,
 
25
    needs_review=True,
 
26
    target_branch=parent,
 
27
    reviewers=(reviewer),
 
28
    review_types=('')
 
29
)
 
30