Handle ENOENT when getting canonical case of a path

If we try to get the canonical name for a file that has been deleted
since the last observation, just return the input path.

This was found by running the hgwatchman test suite.
Also handle ENOTDIR when canonicalizing paths
age-out cursors when aging out file nodes

Summary:
Cursors that have a tick value lower than the last gc age
effectively have a 0 value, so we can safely remove them from
the cursor hash.

This supports a use case where tooling generates a unique cursor name on
startup and re-uses it for a while.

This works "best" when the rate at which the tool starts up is
relatively low (a handful of times a day at most).

Test Plan: `make integration`

Reviewers: sid0

Reviewed By: sid0

Subscribers: jimp

Differential Revision: https://phabricator.fb.com/D1413547
Re-enable Ruby tests, pegging to RSpec 3.0

These started failing when RSpec 3.0 came out, so adapt the specs to
make the tests pass under RSpec 3.0, and peg the dependency to that
revision so that we don't have to fix this again in the future.

Note that we have to run `bundle install` manually because Travis will
only do it for us automatically if it detects a Gemfile in the root
level of the repo:

http://docs.travis-ci.com/user/languages/ruby/

Sample failure:

https://travis-ci.org/facebook/watchman/jobs/29939087

Additionally, ensure we never try a `bundle exec` without first
confirming that the `bundle` is present:

https://travis-ci.org/facebook/watchman/jobs/29939419

Fixes: https://github.com/facebook/watchman/issues/41
revise travis build so that we can run osx and linux

This also pulls in hgwatchman so that we can run its test suite.
I've disabled this for the moment because it takes a while on osx
and errors out :-/

We need to resolve that, but in the meantime, there's no reason not to
proceed with the build fixed up.

Also note: this turns off valgrind on travis builds too; we can revisit
and enable in a follow-on diff
clarify the behavior of --no-save-state

Summary: The language was confusing, hopefully this makes more sense

Test Plan: eyes

Reviewers: royw, sid0

Reviewed By: sid0

Subscribers: fsilva

Differential Revision: https://phabricator.fb.com/D1436644
Re-enable the ruby build+test on travis

I accidentally pushed https://github.com/facebook/watchman/pull/45 ahead
of the travis build fixup, so this should get us actually building
again.
more gracefully handle overlapping ignore options

Summary:
https://github.com/facebook/buck/issues/170#issuecomment-51489110 refers
to issues watching .svn dirs and requests a way to ignore those.

https://github.com/facebook/buck/issues/170#issuecomment-51469085
demonstrates that someone got bitten by queries stopping working when
they were experimenting with ignores.

While I don't think ignoring .git or .hg makes a big difference in the
grand scheme (the default ignore_vcs works very well on our large repos,
and noticing VCS activity is an important part of filesystem settle
detection for triggers), it sounds like doing so for .svn is more of an
issue.

What this diff does:

if a dir is listed in both `ignore_dirs` and `ignore_vcs`, we'll take
the `ignore_dirs` placement as definitive, and elide that dir from the
effective value of `ignore_vcs`.

This means that it will no longer be candidate location for the cookie
dir and that queries will continue to work just fine.

Addresses https://github.com/facebook/watchman/issues/17

Test Plan: `make integration`

Reviewers: fsilva, jimp, sid0

Reviewed By: sid0

Differential Revision: https://phabricator.fb.com/D1484322
Fix bashisms in configure.ac

Addresses https://github.com/facebook/watchman/issues/48
don't recrawl if a stale watch descriptor is found

Summary: I believe this is the correct fix.

Test Plan:
`make integration`, and hgwatchman's test suite -- made sure we never recrawled. Also ran `hg update .~10000` in a large repo -- we'd just about always recrawl without this change. With this change we never recrawled.

Finally, as a sanity check, compared the output of `find -type f` and a watchman query for all files right after the update. Saw that except files in `.hg` there were no discrepancies.

Reviewers: wez

Reviewed By: wez

Subscribers: dreiss

Differential Revision: https://phabricator.fb.com/D1488238
clarify stale watch descriptor comment a bit
Attempt to fix ruby build problems on Travis OSX

Looks like the default ruby build segfaults for us, so try installing
one from brew.

Fix up void* vs. char* pointer arithmetic issue
Use statvfs on NetBSD.

One field name in struct statvfs is different than one Solaris; adapt.
Fixes build on NetBSD, since statfs support was removed.
Add cast.

Fixes
root.c:1987:36: error: initialization makes pointer from integer without a cast [-Werror]
with gcc-4.8.3 on NetBSD.
Add casts.

Fixes
error: array subscript has type ‘char’
with gcc-4.8.3 on NetBSD.

See the CAVEATS section in
http://netbsd.gw.com/cgi-bin/man-cgi?ctype+3+NetBSD-current
for an explanation what the problem with "type 'char'" is.
Cast udata to void *.

Another method to get rid of the warning, suggested by Wez Furlong.
Use uint8_t instead of "unsigned char" to keep line length down.

Suggested by Wez Furlong.
Do not use statvfs on OS X.

The statvfs interface there does not provide the wanted information.
Consistently use uint8_t in casts.

Requested by Wez Furlong.
Add get-config command

Summary:
the Buck folks would like to be able to detect whether the
buck-out dir is correctly listed in the ignore_dirs list in the
.watchmanconfig file.

This diff adds a mechanism for querying watchman to get the
configuration that is in use for a watch.

Test Plan:
`make integration`.  Also tested manually; the output from those
tests is reproduced in the documentation.

Reviewers: fsilva, sid0

Reviewed By: sid0

Subscribers: jimp, dreiss

Differential Revision: https://phabricator.fb.com/D1488644