[PATCH 1 of 3] util: add fswatcher class

Sune Foldager cryo at cyanite.org
Fri May 27 05:22:40 CDT 2011


On 2011-05-26 15:38, Matt Mackall wrote:
>On Thu, 2011-05-26 at 13:06 +0200, Sune Foldager wrote:
>> # HG changeset patch
>> # User Sune Foldager <cryo at cyanite.org>
>> # Date 1306407274 -7200
>> # Node ID 991245e3b101e911c8fe6c3d75c33676613e5ef5
>> # Parent  0969d91fad5cad68bcf60f85e2e3286acd11ab52
>> util: add fswatcher class
>>
>> Used to watch files and directories for modifications.
>
>Not at all sure about this mtime/ctime comparison business you're doing.
>Not only is its safety suspect, several filesystems don't have the
>concept of a ctime.

Well, the ctime is from time.time() to not really related to the file system.
Benoit told me this was the usual way to sidestep the sub-second problem.

>But we know how to do this already: it's called dirstate. We track and
>compare mtime and size. Since we're doing this in memory, we might as
>well store the whole stat object and compare that so we can catch sneaky
>things like inodes changing.

Dirstate tracks and compares mtime and size and contents, that's a difference.
Size alone is not enough, as an external tool could, in a very contrived
scenario, go in and modify the repo.

Of course if we don't allow such things, we can use mtime and size.

Then, this fswatcher class is supposed to be 'general' and not just for
revlogs so I don't know how that would fit in (I would like hgweb to also
use it to watch the hgrc file, for instance, for which size is pretty useless
to compare for changes).


More information about the Mercurial-devel mailing list