Patchy: write PID in config file, not in build dir

test-master-lock is specific to the main Git repository used, whereas
PID file was specific to the build directory associated to the branch
being built, so locking handling was half-broken.  As the Git
repository is defined in the config file, it is sensible to write the
PID in this same place.
Patchy: build outside source tree

This allows hard cleaning of the source tree, removing files and whole
directories that are unknown or ignored by Git, and resetting
uncomitted changes; with this commit, this hard cleaning is done
before applying a patch.
Patchy: add option for email signature
Patchy: separate logs of current instance and on disk

The log file now shows the PID for each entry, and the log of
the current instance can be retrieved in log_record attribute.
Patchy: integrate patches test in locking system

For the record, the existing locking system is "repository/config
file"-wide.
Patchy: support running build commands with another user

For this to work non-interactively, sudo should be installed, and a
line like

gituser  ALL = (builduser) NOPASSWD: ALL

should be added to /etc/sudoers, where gituser is the user that runs
Patchy and builduser is the user that runs build commands (autogen.sh,
configure, make...). This avoids exposing Git push access and other
files and services to the build process.

Some additional features, like the installation of documentation,
build logs and regression tests comparison for serving them on the
WWW, may require in addition that gituser be a member of
lilybuild.
Patchy: install documentation if revision already pushed

Rename WastedBuildException to DuplicateBuildException, which is
actually raised when the revision that has just been built is exactly
the one of remote master; in this case, try to install documentation,
because the Patchy that has merged master may not have uploaded
documentation to some WWW location already.

Also add an option for advertising documentation URL in log.
Patchy: support limiting resources of build processes

Caveat: the units and types of resource limits are not the same as the
ones of ulimit bash builtin, they are the ones of setrlimit() system
call, see "man setrlimit" and Python documention of resource module.
Patchy: log tracebacks to ease debugging
Patchy: improve patches test and rework build functions

* pplit compile_lilypond_test/__init__py:main() in pieces that go to
new AutoCompile methods for build routines and
projecthosting_patches.py:PatchBot.do_check() for iteration on patches
and exception management,

* refactor compile_lilypond_test/__init__py:autoCompile,

* optionally enable doc build in patches test,

* get rid of BUILD_ALL_DOCS (when it comes about testing staging for
fast-forwarding master from it, or testing translation branch,
building docs is required so it's made optional only for patch test),

* rebuild baseline only if master committish has changed, or if master
committish is unchanged but out-test-baseline directories contents
checksum has changed since last build,

* split configuration and cache data -- it has always been a pain for
me to edit Patchy configuration file for next run while it is running,
and realize then that my changes are overwritten; solve this by using
a cache file in addition of a configuration file,

* install regression tests comparison and build log, or the whole
build tree in case of failure, to a directory where they can be viewed
on the WWW, or to a directory created at the parent of the build
directory,

* replace most print statements with info()/warn()/error(),

* set AutoCompile.branch to a value different from staging, in order to
have a different build directory,

* log tracebacks as added recently in branch build,

* reformat code (add space before parenthesis).
Patchy: enable setting ressource limits for itself

In particular, the default setting R_LIMITFSIZE of 64MB avoids
output overflooding to the logs.
Patchy: divert stderr output through the logger
Patchy: make patches directory configurable

In addition, delete by default existing issue*.diff patches
in that directory.
Patchy: reformat toplevel code (space before parenthesis)
Patchy: don't log tracebacks twice
Patchy: make the lock work with >2 running instances
Patchy: git clone silently
Patchy: allow per-branch lock check count
Patchy: use local mass-link for robustness
Patchy on a server: locally record tested patches

This allows Patchy on a server toto.net to record which patches have.
been tested on toto.net, independently from any label settings of
issues on Google tracker.

In addition, import config and cache as module-local names in
projecthosting_patches.py.