Don't fatal on duplicate field in commit message

Summary:
If the actual commit message has a duplicate field and we shouldAutoclose it then the commit message parser fails.
Put the error in `$errors` instead.

Test Plan:
Reparsed commit with duplicate field in message.
Tried to `arc diff` message with duplicate field.

Reviewers: epriestley, nh

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3470
Make AphrontErrorView work on devices

Summary:
This is the last Paste UI element that doesn't work properly on tablets/phones. Make it flexible.

Also add empty states to Paste.

Test Plan: Viewed various errors, and `/uiexample/errors/`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3429
Modernize UIExamples

Summary:
  - Get rid of an AphrontSideNavView callsite.
  - Modernize and simplify the application implementation.
  - Doesn't work perfectly on tablet/phone but that's because not all the UI examples work there yet.

Test Plan: Looked at /applications/ and /uiexample/.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D3431
Detect tasks referenced in commit messages and either link or update the mentioned tasks. Refs T945

Summary: This takes the place of D2721 which I am going to abandon.

Test Plan:
* Make a commit with "Closes T###" in the summary field. See that the mentioned task gets closed.
* Make a commit with "refs T###" in the summary. See that it gets added as a related commit via edges.

Reviewers: 20after4

Reviewed By: epriestley

CC: aran, Korvin, champo

Maniphest Tasks: T945

Differential Revision: https://secure.phabricator.com/D3466
Test commit for T945

Resolves T945 as fixed. (Also tweaks the regexp slightly.)
adding comments to ponder

Summary: This is pretty spartan, but it does the job.

Test Plan:
Patch, update storage, add some comment
to your favorite question or answer.

Reviewers: nh, vrana, epriestley

Reviewed By: epriestley

CC: aran, Korvin, starruler, syrneus, me.here, victorzarate7

Maniphest Tasks: T1645

Differential Revision: https://secure.phabricator.com/D3471
Add paste policy storage

Summary: Add storage to Pastes for view policies.

Test Plan: Set policies on pastes, see next diff.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D3474
Allow projects to be set as policies

Summary:
  - Renames `PhabricatorPolicyQuery` to `PhabricatorPolicyAwareQuery` (a query which respects policy settings).
  - Introduces `PhabricatorPolicyQuery`, which loads available policies (e.g., "member of project X").
  - Introduces `PhabricatorPolicy`, which describes a policy.
  - Allows projects to be set as policies.
  - Allows Paste policies to be edited.
  - Covers crazy cases where you make projects depend on themselves or each other because you are a dastardly villan.

Test Plan: Set paste and project policies, including crazy policies like A -> B -> A, A -> A, etc.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D3476
Hide Ponder add comment behind link

Summary: Does what it says on the tin

Test Plan: Viewed ponder question, expanded link, added comment

Reviewers: pieter, epriestley

Reviewed By: pieter

CC: vrana, aran, Korvin

Maniphest Tasks: T1775

Differential Revision: https://secure.phabricator.com/D3485
Fix error in ponder comment hiding.

Summary: I'm a tard

Test Plan: - view page

Reviewers: pieter

Reviewed By: pieter

CC: aran, epriestley, vrana

Maniphest Tasks: T1775

Differential Revision: https://secure.phabricator.com/D3487
Open editor on highlighted line in Diffusion

Test Plan:
Edited:

  path$33
  path$33-35
  path

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3488
fix ponder escaping issue

Summary: Question titles were not escaped; now they are.

Test Plan: Observe the escaping.

Reviewers: epriestley

Reviewed By: epriestley

CC: nh, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3490
Fix GitHub login failure for user with username "0".
Fix another missing strlen for users with username "0".
Fix one more issue for username "0".
Use 'w' connection in `bin/storage`

Test Plan:
Built a DB provider using readonly connection for 'r' mode. Then:

  $ arc unit

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3484
Enforce blame in Skip Past This Commit

Test Plan:
# Set default view to non-blame.
# Visit URL with '?view=blame'.
# Click //Skip Past This Commit//.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3494
Make it more clear that "Public" really means "Public"

Summary: In the long term I think we can probably just explain this feature better, but for now I want to make sure no one makes a mistake with "Public". This seems like a reasonable way to do it.

Test Plan: Looked at the policy selector dropdown.

Reviewers: vrana, btrahan

Reviewed By: vrana

CC: aran

Differential Revision: https://secure.phabricator.com/D3486
Do sampled profiling of requests

Summary:
People have occasionally complained about phabricator being slow. We have
the access log to look at to see when slowness happens, but it doesn't tell
us much about why it happened. Since it's usually a sporadic issue that's
reported, it's hard to reproduce and then profile. This change will allow us
to collect sampled profiles so we can look at them when slowness occurs.

Test Plan:
checking that sampling works correctly:
- set rate to 0; do several page loads; check no new entries in table
- set rate to 1; check that there's a new row in the table for each page load
- set rate to 10; check that some requests write to table and some don't
check new ui for samples:
- load /xhprof/list/all/, see a list with a lot of samples
- load /xhprof/list/sampled/, see only sampled runs
- load /xhprof/list/manual/, see only non-sampled runs
- load /xhprof/list/my-runs/, se only my manual runs

Reviewers: vrana, epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3458
Fix bad rebase

Auditors: nh