Make "cmd flow --help" work like "cmd help flow"

Summary: Currently, the "--help" flag forces us to generic help, but in the "

Test Plan: Ran `cmd`, `cmd help`, `cmd --help`, `cmd flow --help`, `cmd help flow`, `cmd help --help`.

Reviewers: davidreuss

Reviewed By: davidreuss

CC: aran

Differential Revision: https://secure.phabricator.com/D4106
Implement PhutilArrayWithDefaultValue to simplify building a map with a count or mask

Summary: This can greatly simplify some of the code in my `getWorkingCopyStatus()` changes for D4049. See comments for details.

Test Plan: Ran unit tests.

Reviewers: vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4092
Allow SpriteSheet to generate gradient sprites

Summary:
For gradient sprites, force a single column and verify that they're all the same width.

Also retain sprite order in generated CSS.

Test Plan: Generated gradient sprites.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T1960

Differential Revision: https://secure.phabricator.com/D4099
Fix a Remarkup issue where empty list items render with markup in items

Summary:
When you type this:

```
- A
-
```

..it currently displays as:

```
* A
* -
```

That is, the second bullet has a "-" next to it. Instead it should display like this:

```
* A
*
```

Make it do that.

Test Plan: {F26810}

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D4134
Display database name in connection profiler

Test Plan:
  $ ./reparse.php --trace

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4156
Shorten strings in PhutilReadableSerializer::printShort()

Summary: We currently don't shorten strings, which can cause functions like "insert_into_database($giant_block_of_data)" to produce enormous and almost-certainly-useless logs. Shorten overly-long strings.

Test Plan: Threw an exception from `f(str_repeat('y', 1024 * 1024))`, verified the resulting trace wasn't a gigantic mess.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2193

Differential Revision: https://secure.phabricator.com/D4209
Print stack traces on daemon exceptions

Summary: Currently, we force daemon exceptions to STDERR but not associated traces. Force traces to STDERR too.

Test Plan: Triggered a daemon exception with `--log`, verified trace hit the web logs.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2193

Differential Revision: https://secure.phabricator.com/D4206
Allow message types to be disabled in PhutilConsole

Summary: I need this in order to implement a `--json` flag to `arc unit` without creating a big mess in the process.

Test Plan: Implemented a `--json` flag for `arc unit`, using `disableOut()` to disable normal output.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T2065

Differential Revision: https://secure.phabricator.com/D4213
Add PhutilProxyException to permit nested exceptions prior to PHP 5.3

Summary:
  - Prior to PHP 5.3, exceptions aren't nestable.
  - Fake it.

Test Plan: Ran unit tests. Threw a proxy exception, verified sensible console output.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2193

Differential Revision: https://secure.phabricator.com/D4208
Minor, avoid HPHP compatibility issue. See D2408/T1261.

Auditors: vrana
Add words to the

Auditors: vrana
Don't require non-boundary on trailing backtick when matching monospaced remarkup rule

Summary: Fixes T2200; see that task for discussion.

Test Plan: See unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2200

Differential Revision: https://secure.phabricator.com/D4218
Add http basic auth to the Conduit client
Add a shell lexer to libphutil

Summary: I need this to properly parse SSH_ORIGINAL_COMMAND in the sshd receivers. We get a string which may have shell escaping.

Test Plan: Wrote a ton of unit tests.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Maniphest Tasks: T550, T603

Differential Revision: https://secure.phabricator.com/D4230
Use PhutilURI in ConduitClient

Summary: ConduitClient predates PhutilURI and manually parses things. Use PhutilURI instead.

Test Plan: Created this diff.

Reviewers: btrahan, vrana

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D4231
Make PhutilSocketChannel work better for channels with separate I/O

Summary:
Currently, all uses of PhutilSocketChannel are protocol-based or terminate the read and write socket at the same time (e.g., when the other side terminates).

However, when receiving an SSH request, we sometimes to read all of stdin until the socket hits EOF and closes, but then may still want to write a response out. Allow PhutilSocketChannel to close just half of the channel (read or write) without also closing the other half. Also, provide specific tests for a channel being open for reading and writing.

Also, implement PhutilMetricsChannel, which just counts bytes that go through it. Eventually, this will count I/O over SSH and feed into some system which keeps track of how much stuff we're using.

Test Plan: See next diff; implemented SSH glue on top of this.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603, T550

Differential Revision: https://secure.phabricator.com/D4228
Remove backward-compatibility code for __init__.php

Summary: Resolves T1103.

Test Plan: Ran "arc liberate", "arc unit", Phabricator.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T1103

Differential Revision: https://secure.phabricator.com/D4234
Respect error_reporting() in error handler

Summary:
This changes couple of things:

# Errors are not converted to exceptions with `@`.
# It respects `error_reporting()`.
# It doesn't pass ignored errors to listener.

Test Plan: Didn't see tons of "unable to select [4]: Interrupted system call at [Future.php:147]" in DarkConsole.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4254
Improve handling of gigantic CommandExceptions

Summary:
See T2193. For some commands (`svn log --xml ...`), output may be very large:

  - Truncate the maximum length of exception messages.
  - Summarize outputs in CommandExceptions.

Test Plan: Added `execx('cat /usr/share/dict/words && exit 1')` to a controller, loaded page. Saw a reasonbly-sized exception onscreen and in the logs.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2193

Differential Revision: https://secure.phabricator.com/D4280
Fix a bug where an ExecFuture might hang on __destruct() if its process holds pipes

Summary:
I don't have a complete understanding of exactly what's going on here, but here's what I have been able to determine:

  - ExecFuture has a long-standing bug where it may hang indefinitely in __destruct() if the other process holds pipes open, even though ExecFuture has closed the pipes.
    - The new unit test reproduces this behavior.
    - Mystery: I don't know why closing the pipes from our side isn't good enough.
  - D4228 changed PhutilSocketChannel, which would previously tear down **both** pipes when either closed. Now it tears down only one pipe.
    - Mystery: I'm not sure which pipe dies and which stays alive.
  - This exposed T2248, where the remaining pipe kept the parent open and hanging in ExecFuture::__destruct().

Test Plan:
Added unit test, which failed. Made patch. Ran unit tests; tests passed.

Reproduced T2248 and ran "arc unit"; worked properly after this patch.

Reviewers: btrahan, vrana, ender, nh

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2248

Differential Revision: https://secure.phabricator.com/D4292