Skip to content

Commit

Permalink
more gracefully handle overlapping ignore options
Browse files Browse the repository at this point in the history
Summary:
facebook/buck#170 (comment) refers
to issues watching .svn dirs and requests a way to ignore those.

facebook/buck#170 (comment)
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 #17

Test Plan: `make integration`

Reviewers: fsilva, jimp, sid0

Reviewed By: sid0

Differential Revision: https://phabricator.fb.com/D1484322
  • Loading branch information
wez committed Aug 8, 2014
1 parent 35466dc commit e344240
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/configuration.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ would ignore the `build` directory at the top level of the watched tree, and
everything below it. It will never appear in the watchman query results for
the tree.

Since version 2.9.9, if you list a dir in `ignore_dirs` that is also listed in
`ignore_vcs`, the `ignore_dirs` placement will take precedence. This may not
sound like a big deal, but since `ignore_vcs` is used as a hint to for the
placement of [cookie files](/watchman/docs/cookies.html), having these two
options overlap in earlier versions would break watchman queries.

#### gc_age_seconds

Deleted files (and dirs) older than this are periodically pruned from the
Expand Down
13 changes: 11 additions & 2 deletions root.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ static bool apply_ignore_vcs_configuration(w_root_t *root, char **errmsg)

name = w_string_new(ignore);
fullname = w_string_path_cat(root->root_path, name);

// if we are completely ignoring this dir, we have nothing more to
// do here
if (w_ht_get(root->ignore_dirs, w_ht_ptr_val(fullname))) {
w_string_delref(fullname);
w_string_delref(name);
continue;
}

w_ht_set(root->ignore_vcs, w_ht_ptr_val(fullname),
w_ht_ptr_val(fullname));

Expand Down Expand Up @@ -360,13 +369,13 @@ static w_root_t *w_root_new(const char *path, char **errmsg)
root->gc_interval = cfg_get_int(root, "gc_interval_seconds",
DEFAULT_GC_INTERVAL);

apply_ignore_configuration(root);

if (!apply_ignore_vcs_configuration(root, errmsg)) {
w_root_delref(root);
return NULL;
}

apply_ignore_configuration(root);

if (!w_root_init(root, errmsg)) {
w_root_delref(root);
return NULL;
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/ignore.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ function testInvalidIgnore() {
}
}

function testIgnoreOverlapVCSIgnore() {
$dir = PhutilDirectoryFixture::newEmptyFixture();
$root = realpath($dir->getPath());

$cfg = array(
'ignore_dirs' => array('.hg'),
);
file_put_contents("$root/.watchmanconfig", json_encode($cfg));
mkdir("$root/.hg");

$this->watch($root);
$this->assertFileList($root, array('.watchmanconfig'));
touch("$root/foo");
$this->assertFileList($root, array('.watchmanconfig', 'foo'));
}

function testIgnoreGeneric() {
$dir = PhutilDirectoryFixture::newEmptyFixture();
$root = realpath($dir->getPath());
Expand Down

0 comments on commit e344240

Please sign in to comment.