Package gbp :: Package scripts :: Package common :: Module pq
[hide private]
[frames] | no frames]

Module pq

Common functionality for Debian and RPM patchqueue management

Functions [hide private]
 
is_pq_branch(branch, options)
is branch a patch-queue branch?
 
pq_branch_name(branch, options)
get the patch queue branch corresponding to branch
 
pq_branch_base(pq_branch, options)
Get the branch corresponding to the given patch queue branch.
 
patch_read_header(src)
Read a patches header and split it into single lines.
 
patch_header_parse_topic(header)
Parse the topic from the patch header removing the corresponding line.
 
patch_header_mangle_newline(header)
Look for the diff stat separator and remove trailing new lines before it.
 
patch_write_header(srcname, dstname)
Write out the patch header doing any necessary processing such as detecting and removing a given topic, dropping trailing new lines and skipping the first line containing the sha1.
 
patch_write_content(srcname, dstname, header_len)
Write out the patch body skipping the header
 
write_patch(patch, patch_dir, options)
Write the patch exported by 'git-format-patch' to it's final location (as specified in the commit)
 
get_maintainer_from_control(repo)
Get the maintainer from the control file
 
switch_to_pq_branch(repo, branch, options)
Switch to patch-queue branch if not already there, create it if it doesn't exist yet
 
apply_single_patch(repo, branch, patch, fallback_author, options)
 
apply_and_commit_patch(repo, patch, fallback_author, topic=None)
apply a single patch 'patch', add topic 'topic' and commit it
 
drop_pq(repo, branch, options)
Variables [hide private]
  DEFAULT_PQ_BRANCH_NAME = 'patch-queue/%(branch)s'
  __package__ = 'gbp.scripts.common'
Function Details [hide private]

is_pq_branch(branch, options)

 

is branch a patch-queue branch?

>>> from optparse import OptionParser
>>> (opts, args) = OptionParser().parse_args([])
>>> is_pq_branch("foo", opts)
False
>>> is_pq_branch("patch-queue/foo", opts)
True
>>> opts.pq_branch = "%(branch)s/development"
>>> is_pq_branch("foo/development/bar", opts)
False
>>> is_pq_branch("bar/foo/development", opts)
True
>>> opts.pq_branch = "development"
>>> is_pq_branch("development", opts)
True
>>> opts.pq_branch = "my/%(branch)s/pq"
>>> is_pq_branch("my/foo/pqb", opts)
False
>>> is_pq_branch("my/foo/pq", opts)
True

pq_branch_name(branch, options)

 

get the patch queue branch corresponding to branch

>>> from optparse import OptionParser
>>> (opts, args) = OptionParser().parse_args([])
>>> pq_branch_name("patch-queue/master", opts)
>>> pq_branch_name("foo", opts)
'patch-queue/foo'
>>> opts.pq_branch = "%(branch)s/development"
>>> pq_branch_name("foo", opts)
'foo/development'
>>> opts.pq_branch = "development"
>>> pq_branch_name("foo", opts)
'development'

pq_branch_base(pq_branch, options)

 

Get the branch corresponding to the given patch queue branch. Returns the packaging/debian branch if pq format string doesn't contain '%(branch)s' key.

>>> from optparse import OptionParser
>>> (opts, args) = OptionParser().parse_args([])
>>> opts.packaging_branch = "packaging"
>>> pq_branch_base("patch-queue/master", opts)
'master'
>>> pq_branch_base("foo", opts)
>>> opts.pq_branch = "my/%(branch)s/development"
>>> pq_branch_base("foo/development", opts)
>>> pq_branch_base("my/foo/development/bar", opts)
>>> pq_branch_base("my/foo/development", opts)
'foo'
>>> opts.pq_branch = "development"
>>> pq_branch_base("foo/development", opts)
>>> pq_branch_base("development", opts)
'packaging'

patch_read_header(src)

 

Read a patches header and split it into single lines. We assume the header ends at the first line starting with "diff ..."

patch_header_parse_topic(header)

 

Parse the topic from the patch header removing the corresponding line. This mangles the header in place.

Parameters:
  • header (list of str
    >>> h = ['foo', 'gbp-pq-topic: bar']
    >>> patch_header_parse_topic(h)
    'bar'
    >>> h
    ['foo']
    ) - patch header

patch_header_mangle_newline(header)

 

Look for the diff stat separator and remove trailing new lines before it. This mangles the header in place.

Parameters:
  • header (list of str
    >>> h = ['foo bar\n', '\n', 'bar', '\n', '\n', '\n', '---\n', '\n']
    >>> patch_header_mangle_newline(h)
    >>> h
    ['foo bar\n', '\n', 'bar', '\n', '---\n', '\n']
    ) - patch header