pq: rewrite patch export functionality

Use our own function for constructing the patch files instead of using
the format-patch command of git. This way, we get the desired output
format directly, without the need for the error-prone "format-patch,
parse patch files, mangle and re-write patch files" cycle.

Also, fix patch naming in patch generation when '--no-patch-numbers' is
used.  Previously, multiple commits with the same subject resulted in
multiple patches having the same filename. This lead into broken series
with missing patches as patch files were overwritten by the topmost
commit.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq.format_patch: support file path filtering

Implements a filter option that allows filtering out changes to certain
files/paths in the patch-generation. A commit is totally ignored if all
files would be filtered out. The path filter is given as a Python
regexp.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: properly generate non-ascii patch files

Encode non-ascii email headers properly. Also, set MIME headers
correctly for the message body if the commit message body contains
non-ascii characters.

The reason for constructing the message in a little bit "clumsy" way is
the intention is to match the output of git-format-patch as closely as
possible.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: support patch-export commands

Support giving commands to pq as a meta tag in commit message. The
format is "Gbp: <command> [args]".

Currently, only one command is supported. namely 'ignore'. That is, one
can use 'Gbp: Ignore' in the commit message for ignoring the commit in
patch-generation.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: add format_diff() function

For generating a patch file from a diff between two arbitrary commits.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: listen to 'Gbp-Pq:' commands, too

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: support 'Topic' patch-export command

Topic can be defined with either 'Gbp: Topic <topic>' or 'Gbp-Pq: Topic
<topic>' in the commit message.

This is to replace the "gbp-pq-topic: <topic>" command.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: deprecate the usage of 'gbp-pq-topic:'

Replaced by the "Gbp[-Pq]: Topic <topic>" command.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
docs: update pq manpages regarding pq command meta tags

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp-clone: support repo URLs like "host:repo.git"

Previously, gbp didn't correctly parse this kind of URL and clone
failed.

Signed-off-by: Guan Junchun <junchunx.guan@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp-clone: support cloning to a specific directory

Signed-off-by: Guan Junchun <junchunx.guan@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: new method for getting git output as generator

Add a new _git_inout2() helper method that returns the git output
(stdout) as a generator - instead of all stdout data in one string.
Useful for handling git commands that are expected to have a lot of
stdout data, like git-archive.

Also, changes the private __git_inout() method to return a generator.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository.__git_inout: prevent blocking of stdin

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository.archive: support getting tar data as return value

Return tar data as a generator object, if the 'output' option is not
defined.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
common/buildpackage: support for different archive formats

Adds support for defining the archive format of the output of
git_archive_single(), e.g. 'zip'. Defaults to 'tar', as before.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Change compressor cmdline opts in compressor_opts to a list

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage/git_archive_single: use GitRepository.archive()

Use GitRepository.archive() method like git_archive_submodules() does.
This makes it possible to call git_archive_single() independent of the
callers current working directory.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage/dump_tree: use GitRepository.archive()

Make dump_tree() utilize the GitRepository.archive() method - similarly
to git_archive_submodules() - instead of ad-hoc Python pipes. This makes
dump_tree() work independent of the callers current working directory.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
common/buildpackage: use GitRepository for submodules

Initialize a GitRepository object for each submodule in
git_archive_submodules().

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository.archive: drop the '**kwargs' argument

Unused and misleading.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>