[PATCH 0 of 3] add fswatcher class and use it in hgweb

Sune Foldager cryo at cyanite.org
Thu May 26 06:06:41 CDT 2011


The first patch adds a class, fswatcher, to util. It's an updated version of
my previous patch. Thanks to Benoit for sparring. It's conservative in the
sense that it may report changes that didn't happen, but it shouldn't miss
any. I added tests as well.

The second patch adds a getwatcher method to localrepo, so decisions about
what files to watch can be kept in that class, and not in hgweb. Maybe it
should be private; not sure how generally useful it is.


The third patch uses this watcher in hgweb to decide if the repo instance was
changed and needs to be recreated. Previously, mtime and size were used, but
there might have been a race condition.

The new version keeps mtime around, since it's used in the index display in
hgwebdir as well as in caching decisions. Maybe we should add an mtime method
to localrepo as well, to get that logic out of hgweb?

A slightly different thing: it seems the mtime/size approach, as well as the
new watch approach, picks up on hgweb's own changes to the repository as well,
but I am not sure how that can be avoided while still making sure no external
changes are missed. At least not unless something is done while holding a lock
or similar. But this is not directly connected to the patch.


Another future use for the fswatcher is for hgweb to watch for config file
changes, and for hgwebdir to use it to do the same.

-Sune


More information about the Mercurial-devel mailing list