harden_directory.php: reduce footprint of directories by hardlinking them
harden_directory.php: reduce footprint of directories by hardlinking them

Summary:
This is a small step toward a world of watirworld / sandcastle / integration
tests / async unit tests / web bisect. Do Sandcastle-style disk-size reduction
via hardlinks.

I've incorporated a couple of tricks and such:

  - Detect the hardlink limit thing and deal with it, I don't remember what
Sandcastle's solution was (presumably something similar?) but this should dodge
that.
  - If possible, use 'git show-tree' instead of hashing files ourselves.
  - If not, use git hashes.
  - Deal with executable bits correctly.
  - Deal correctly with git submodules.
  - Layout the workflow so that the "soft" directory can be used by other
processes and silently (and atomically) becomes the hard directory later.
Ideally this should let us use the "soft" directory immediately, but still
benefit from hardening it.

@slawekbiel, am I missing anything obvious here?

Test Plan:
Created a sandpit with every revision of Phabricator in it. It consumes 37MB of
disk + 3.0MB of hardlinks (for ~650 copies), versus 63MB for a single git
repository.
Made an attempt to verify all the special behaviors (no git, executable,
symlinks, hardlink limit).
I haven't played with the perf on this. It's pretty fast (<<1 second) for
incremental sandpits, although the initial copy of 12,000 files took a little
while.

Reviewed By: slawekbiel
Reviewers: slawekbiel, aran, jungejason, tuomaspelkonen
CC: aran, slawekbiel, epriestley
Differential Revision: 464

PageUpPeopleOrg/libphutil-patches,schlaile/libphutil,aik099/libphutil,eSpark/libphutil,fivestars/libphutil,devurandom/libphutil,christopher-johnson/libphutil,r4nt/libphutil,librewiki/libphutil,devurandom/libphutil,wikimedia/phabricator-libphutil,memsql/libphutil,Automattic/libphutil,eSpark/libphutil,Symplicity/libphutil,wikimedia/phabricator-libphutil,zhihu/libphutil,wikimedia/phabricator-libphutil,librewiki/libphutil,christopher-johnson/libphutil,uhd-urz/libphutil,Automattic/libphutil,yangshiqi/libphutil,eSpark/libphutil,uhd-urz/libphutil,PageUpPeopleOrg/libphutil-patches,julkiewicz/libphutil,uhd-urz/libphutil,julkiewicz/libphutil,uber/libphutil,uber/libphutil,r4nt/libphutil,wxstars/libphutil,librewiki/libphutil,fivestars/libphutil,Khan/libphutil,devurandom/libphutil,wxstars/libphutil,zhihu/libphutil,zhihu/libphutil,newbeess/libphutil,aik099/libphutil,Symplicity/libphutil,julkiewicz/libphutil,Automattic/libphutil,PageUpPeopleOrg/libphutil-patches,yangshiqi/libphutil,Symplicity/libphutil,schlaile/libphutil,r4nt/libphutil,christopher-johnson/libphutil,fivestars/libphutil,Khan/libphutil,uber/libphutil,aik099/libphutil,schlaile/libphutil,memsql/libphutil,codelabs-ch/libphutil,newbeess/libphutil,wxstars/libphutil,yangshiqi/libphutil,memsql/libphutil,newbeess/libphutil,codelabs-ch/libphutil,Khan/libphutil,codelabs-ch/libphutil