refactor svn logic into SvnRepo

Summary: This is going to be shared with the reup test.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D85
svn reup test

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D86
move clean tmp dir test logic to shared

Summary:
We like to confirm that no temp files are left over after our
integration tests. This refactor lets us share do this in the reup tests
too.

Test Plan:
Make sure we can fail both the reup and sync tests by deleting the
cleanup logic.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D87
make sure plugin env vars are always masked

Summary:
We had code for this before, but it wasn't tested. It turns out we were
setting the literal field names ('url') instead of the formatted field
names ('PERU_MODULE_URL'). We didn't notice this before, because we
were still using `os.environ.get` for our optional fields, which doesn't
fail on a missing variable. Get rid of those calls.

Test Plan:
Now that we're using `os.environ[]` everywhere, we should notice if this
breaks.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D88
don't catch PrintableError when verbose

Summary: Closes issue #35.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D84
delete compat.indent()

Summary: That was a python3.2 compatibility function. Now we're only >=3.3.

Test Plan: Ran `test.sh` inside a 3.3 virtualenv.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D83
remove peru/plugin_shared.py from .coveragerc's omit list

Summary: That file no longer exists. (Yay!)

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D82
automatically sync after a reup

Summary:
In my experience I almost always follow `peru reup` with `peru sync`, so
let's make that the default. Add a `--nosync` flag to restore the old
reup-only behavior. Also add the `--force` flag to reup, to match the
options to sync.

Test Plan:
New integration test. Also clean up the existing reup tests a bit. I
also made sync respect the `--quiet` flag. That particular logic won't
last long (because fancy output is coming), but it keeps our test output
clean.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D81
less profanity
allow `peru clean` to take the --verbose flag

Summary:
Now that we use verbose to show stacktraces, you might actually want it
for clean. We still don't allow `--quiet`, because clean should have no
output unless there's an error.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D90
move reup output to PERU_REUP_OUTPUT

Summary:
Previously we've allowed plugin fetches to print progress directly to stdout,
but used the stdout of reup to get the actual reup data. This is kind of
inconsistent, and with the upcoming fancy console display, we're going
to want reup to print progress to stdout the same way fetch does. We'll
need a different channel for reup's actual data output.

Create the `PERU_REUP_OUTPUT` variable, which is defined during reup to
point to a temporary file where the plugin should write its
YAML-formatted result. Conceptually this is similar to the
`PERU_FETCH_DEST` variable already used for output during a fetch.

For now, discard the stdout from reup but allow the stderr to print to
the terminal. Pretty soon, we'll do the same thing with stdout here
that we do in a fetch.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D89
fancy display

Summary:
Create a multi-line terminal display that shows output from plugin jobs
in real time. This requires reworking the way plugin jobs deal with
subprocess output. They now take an "output handle", which is a
buffer/context-manager that implements `__enter__`, `__exit__`, and
`write`. Jobs receive these handles from a "display" object that lives
on the `Runtime`, and they write to the handles inside a `with` block,
which lets the display know exactly when jobs start and stop.  The
plugin tests also include a dummy handle implementation, which is a thin
wrapper around a `StringIO` buffer.

In addition to the default `FancyDisplay`, there is a `QuietDisplay` and
a `VerboseDisplay`. The quiet one prints nothing, and the verbose one
waits until each job is finished to print all its output to the terminal
in one go (so it's not real time, but it's formatted in a way that's
suitable for log files). Errors from plugin jobs are handled by throwing
`PluginRuntimeError`, a subclass of `PrintableError`, so the displays
don't need to do anything special.

The fancy display would like to draw to the terminal as soon as it gets
output from a job, but with a few git clones running in parallel that
starts to cause unacceptable flicker. My solution right now is to draw
on a 0.1 second delay, so that a ton of updates coming in at once get
coalesced into a single draw. The main downside of this approach is that
it makes `FancyDisplay` depend on the asyncio event loop to implement
that delay. I hack around that in the tests by directly calling `_draw`.

We still need to make hg, svn, and curl print progress to the terminal
(right now only the git plugin has been brought up to speed).

Test Plan:
The plugin tests use `TestDisplayHandle` to work with the new interface.
New display unit tests include the `FakeTerminal`, which interprets ANSI
control codes so that we can test what `FancyDisplay` is actually
drawing.  The `print` plugin type is provided to make it easy to play with
the `FancyDisplay` by hand without a network connection.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D91
remove remote module imports

Summary:
Since early on, we allowed remote modules to have imports just like the
toplevel module does. We envisioned peru running serious builds for you
and giving you the build products, and we wanted to support builds that
had dependencies on other modules. More recently we've come to the
conclusion that having peru wrap real builds is a bad idea. See
d374aa4d5415b658565e474143681f1bc0fae411, where we removed the `build`
command. This diff removes remote module imports for the same reasons.
We were never using them in practice, and they also made overrides more
complicated.

Closes https://github.com/buildinspace/peru/issues/48.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D92
add context to module field error messages

Summary:
We have several important checks (like invalid module field names) that
are still `assert`s from back before we had any kind of UI. Replace
these with proper `PrintableErrors`, and include maybe-kinda-sorta
important information like the name of the invalid field.

I'm removing the check for whitespace in plugin field names. If the
plugin author wants to define a field with space in it, that's now
possible, though we should consider supporting it a little better. See
https://github.com/buildinspace/peru/issues/51.

Test Plan:
I exercised all these errors by hand to make sure the printouts looked
good. I've added actual tests for some of them, to confirm that field
information is actually present in the message.

Reviewers: sean

Differential Revision: https://phabricator.buildinspace.com/D93