pq: move switch_pq() to common

So that it can be re-used by the upcoming pq-rpm tool.

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

This is a method of getting the filename and status information of a
diff. That is, a list of files that changed and their status, "added",
"modified" etc.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository.create_branch: add 'force' option

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
ComponentTestBase: add a per-class toplevel temp dir

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
ComponentTestBase: add check_files() method

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
ComponentTestBase: add dirs argument to _check_repo_state()

Make difference between regular files and directories, eliminating the
requirement of listing directories in the file list.

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

Simple wrapper to the git-status command.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp-dch: fix handling of the '--meta' option

Make it effective again - previously it was totally ignored. Also,
change it's default value to True to match the current behavior.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
notify: catch RuntimeError when importing pynotify

Work around a problem in some distros (e.g. Fedora) where "import
pynotify" crashes in RuntimeError in some cases, e.g. when DISPLAY env
variable is not set.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
log: fix auto colorizing for custom streams

Check for existence of isatty() method in the stream object. Some custom
streams (e.g. in nose) do not necessarily have this.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage/dump_tree: add 'recursive' option

For selecting whether to dump all the files recursively or just the top
level directory of the tree.

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

Initial version of gbp-pq-rpm - a tool for managing patch queues for rpm
packages. The functionality more or less corresponds to that of the
(Debian) gbp-pq. The only major difference probably being (in addition
to the obvious of working with .spec files instead of debian/) is that
patches are always imported on top of the upstream version, not on top
of the packaging branch (which might not even contain any source code).

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Olev Kartau <olev.kartau@intel.com>
GitRepository: implemet checkout_files() method

Makes it possible to only checkout certain files from a branch, instead
of switching to the branch. Add a new method instead of extending
checkout() in order to keep it consistent. That is, otherwise checkout()
would have totally different outcome depending on whether paths were
defined of not.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq-rpm: implement '--import-files' command line option

The new option can be used to "copy" files from the packaging branch to
the patch-queue branch when doing pq import. The files defined with this
option will appear as new files in one monolithic commit in the
development/patch-queue branch.

By default, the local gbp conf files are imported in order to try to
ensure that gbp sees the same settings on the patch-queue branch as
on the packaging branch.

NOTE: This option does not affect the importing (i.e. apply and commit)
of patches.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: allow repo inititialization from subdir

This allows initialization of a GitRepository object, even if the
current working directory (or path given to GitRepository) is not the
top level directory of the git repository.

Don't guess the git meta data dir, but, take it as reported by git
itself.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
config: read the right config if run from subdir

A step towards being able to run GBP tools from subdirectories.

Now expands '%(top_dir)s' and '%(git_dir)s' in config file path to root
of the working directory and git metadata directory, respectively.

Also, adds a new method _read_config_file() in preparation for
supporting per-tree config files.

Fixes tests.test_Config: currently the only correct way to define the
config file(s) to be parsed is by using the GBP_CONF_FILES environment
variable.

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>
GitRepository.archive: add 'paths' option

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