Show repository in Differential emails

Summary: Ref T5137. Listing the repository in Differential emails makes it easy to filter.

Test Plan: Eye-ball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: young_hwi, epriestley, Korvin

Maniphest Tasks: T5137

Differential Revision: https://secure.phabricator.com/D9609
Convert more scripts to use `PhutilConsoleTable`.

Summary: Convert `./bin/mail` and a`./bin/sms` to use `PhutilConsoleTable` for formatting output.

Test Plan: I don't actually have mail and SMS setup on my dev box, but this is a pretty straightforward change.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9621
PHUIImageMask

Summary: Adds a PHUI class for display images on a center point, with or without a mask.

Test Plan:
I am bad a math, so like, check that for me please. I tested using Photoshop. Class may need tweaked depending how we store the inline-comment coords.

{F167829}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9614
Add a masked image to Pholio Inline Comment Dialog

Summary: n/a

Test Plan:
Tested both ajax and regular pages, test various comments, images.

{F168592}

{F168593}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9630
CSS polish, Pholio

Summary:
Minor things

- Fades out comment icon on hover
- Adds hover to inline comment images
- moves mask position to just the image, and not the transparent border

Test Plan: Tested all of these items on various mocks

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9631
Fix invalid submit_uri when creating dashboard panels

Summary: When creating dashboard panels, the `submit_uri` is invalid since the panel has not been saved to the database yet (and therefore doesn't have an ID). This resulted in a 404 when trying to submit the form to `/dashboard/panel/edit//`

Test Plan: Created a dashboard panel and the panel was created successfully

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9629
Tighten up Phragment routes to prevent page crashes

Summary: Fixes T5418.  These routes were a little more permissive than they should have been.

Test Plan: Hit those URLs without a path, got a 404 instead.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin, hach-que

Maniphest Tasks: T5418

Differential Revision: https://secure.phabricator.com/D9635
Move build variables into HarbormasterBuildableInterface

Summary: Ref T1049.  This moves the declaration of build variables onto HarbormasterBuildableInterface, allowing new classes implementing HarbormasterBuildableInterface to declare their own variables.

Test Plan: Implemented it on another class, saw the build variables appear.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T1049

Differential Revision: https://secure.phabricator.com/D9618
Update callsites of `phutil_json_decode`.

Summary: Depends on D9634. `phutil_json_decode` now throws an exception on invalid JSON.

Test Plan: `arc unit`

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9640
Never use "{branches}" in Mercurial

Summary:
Fixes T5304. Mercurial features a "{branches}" template keyword, documented as:

```
    branches      List of strings. The name of the branch on which the
                  changeset was committed. Will be empty if the branch name
                  was default.
```

At some time long in the past, I misinterpreted this to mean "list of branches where the branch head is a descendant of the commit". It is more like "list of zero or one elements, possibly containing the name of the branch the commit was originally made to, if that branch was not 'default'".

In fact, it seems like this is because a //very// long time in the past, Mercurial worked roughly like I expected:

> Ages ago (2005), we had a very different and ultimately unworkable
> approach to named branches that worked vaguely like .hgtags and allowed
> multiple branch names per revision.

http://marc.info/?l=mercurial-devel&m=129883069414855

This appears to be deprecated in modern Mercurial (it's not in the modern web documentation) although I can't find a commit about it so maybe that's just a documentation issue.

In any case, `{branches}` seems to never be useful: `{branch}` provides the same information without the awkward "default-if-empty" case.

Switch from `{branches}` to either `{branch}` (where that's good enough, notably in the hook engine) or `(descendants(%s) and head())`, which is equivalent to `--contains` in Git.

This fixes pushing to branches with spaces in their names, and makes the "Branches" / "Contains" queries moderately more consistent.

Test Plan:
  - Pushed to a Mercurial branch with a space in it.
  - Viewed list of branches in a Mercurial repository.
  - Viewed containing branches of a Mercurial commit in Diffusion.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5304

Differential Revision: https://secure.phabricator.com/D9453
Substantially support character encodings and "Highlight As" in changesets

Summary: Ref T5179. Ref T4045. Ref T832. We can now write non-utf8 hunks into the database, so try to do more reasonable things with them in the UI.

Test Plan: (See screenshots...)

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T832, T4045, T5179

Differential Revision: https://secure.phabricator.com/D9294
When pasting both image data and text into Chrome, use only the text

Summary: Fixes T5437. This actual behavior is debateable but this is the one that seems simplest and most sensible.

Test Plan: Copied some cells from Numbers, pasted them into a remarkup box in Chrome, got just the text.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5437

Differential Revision: https://secure.phabricator.com/D9647
Don't recommend putting Phabricator on the main Directory directive

Summary: Fixes T5428. The rules are different under `<Directory />` and this is very rare, so don't make this harder than it needs to be.

Test Plan: Read text.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5428

Differential Revision: https://secure.phabricator.com/D9646
Add email preferences to Pholio

Summary: Fixes T5386, adds a base set of email preferences to Pholio

Test Plan: Turned on, tested and got email, turned off, tested and saw notifications.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T5386

Differential Revision: https://secure.phabricator.com/D9644
Remove ajaxey comment magic in Pholio, and also some bugs

Summary:
Fixes T5424.

  - One concrete issue: drafts were not being cleared properly because `__draft__` was not set on submission. This (mostly) fixes phantom drafts.
  - This ajax comment magic feels weird and floaty and generally has problems. For example, if you add subscribers or inlines, all the stuff on the page which represents those won't update automatically. Instead, just reload. Maybe we'll ajax this stuff some day, but it feels like a net negative for now.
  - Also remove it from other applications where it's currently used.
  - Fix an issue with inline previews.

Test Plan: Made some comments on a mock, everything worked normally like I expected it to.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5424

Differential Revision: https://secure.phabricator.com/D9649
Add a `--local` flag for the `./bin/phd status` workflow.

Summary: It is sometimes useful to use `./bin/phd status` as a means to determine if daemons //are// actually running on the current host. For example, a common practice in upstart scripts is something similar to `./bin/phd status || ./bin/phd status`.

Test Plan:
```
> ./bin/phd status
ID   Host            PID  Started                 Daemon                               Arguments
1162 ip-10-127-58-93 4046 Jun 20 2014, 3:17:43 AM PhabricatorFactDaemon
1161 ip-10-127-58-93 3984 Jun 20 2014, 3:17:43 AM PhabricatorTaskmasterDaemon
1160 ip-10-127-58-93 3973 Jun 20 2014, 3:17:42 AM PhabricatorTaskmasterDaemon
1159 ip-10-127-58-93 3968 Jun 20 2014, 3:17:42 AM PhabricatorTaskmasterDaemon
1158 ip-10-127-58-93 3943 Jun 20 2014, 3:17:42 AM PhabricatorTaskmasterDaemon
1157 ip-10-127-58-93 3914 Jun 20 2014, 3:17:41 AM PhabricatorGarbageCollectorDaemon
1156 ip-10-127-58-93 3909 Jun 20 2014, 3:17:41 AM PhabricatorRepositoryPullLocalDaemon

> ./bin/phd status --local
There are no running Phabricator daemons.
```

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9645
Convert `./bin/storage status` to use `PhutilConsoleTable`.

Summary: Constructing tables manually just isn't fun.

Test Plan:
```
./bin/storage status
phabricator:db.audit                                      Applied db   audit
phabricator:db.calendar                                   Applied db   calendar
phabricator:db.chatlog                                    Applied db   chatlog
phabricator:db.conduit                                    Applied db   conduit
phabricator:db.countdown                                  Applied db   countdown
phabricator:db.daemon                                     Applied db   daemon
phabricator:db.differential                               Applied db   differential
phabricator:db.draft                                      Applied db   draft
phabricator:db.drydock                                    Applied db   drydock
phabricator:db.feed                                       Applied db   feed
phabricator:db.file                                       Applied db   file
phabricator:db.flag                                       Applied db   flag
phabricator:db.harbormaster                               Applied db   harbormaster
...
```

This probably isn't ready to land yet, we should fix `PhutilConsoleTable` to truncate columns which would otherwise cause overflow.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9604
Make dashboard application launchable

Summary:
Ref T4980. This isn't quite ready to unbeta yet, but it's good enough to be shown in the launch view.

Also, name it "Dashboards" in the UI.

Test Plan: Viewed launcher, saw Dashboards. Clicked it, got to dashboard main page.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T4980

Differential Revision: https://secure.phabricator.com/D9650
Add a "start with a template" option when creating dashboards

Summary: Ref T5317. This primarily makes it easier for new administrators to build a dashboard for the first time, without going too crazy on technical complexity.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5317

Differential Revision: https://secure.phabricator.com/D9651
Drop differential_relationship table

Summary: Ref T2222. I'll hold this, but there are no more reads or writes from/to this table in the application.

Test Plan: Grepped for usage, ran migration, browsed around.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley, aran

Maniphest Tasks: T2222

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