[PATCH] util: add fswatcher class

Sune Foldager cryo at cyanite.org
Thu May 26 05:30:56 CDT 2011


On 2011-05-25 12:30, Matt Mackall wrote:
>On Wed, 2011-05-25 at 14:30 +0200, Sune Foldager wrote:
>> # HG changeset patch
>> # User Sune Foldager <cryo at cyanite.org>
>> # Date 1306326237 -7200
>> # Node ID 0dedf75d80c4bf4f38ae240e7bba747f5a2d6f6f
>> # Parent  a6b543e053058c39b52e2b7c1e9a4b7c14c66a56
>> util: add fswatcher class
>>
>> Used to watch files and directories for modifications.
>>
>> diff -r a6b543e05305 -r 0dedf75d80c4 mercurial/util.py
>> --- a/mercurial/util.py	Wed May 25 10:06:17 2011 +0200
>> +++ b/mercurial/util.py	Wed May 25 14:23:57 2011 +0200
>> @@ -861,6 +861,36 @@
>>              limit -= len(s)
>>          yield s
>>
>> +class fswatcher(object):
>> +    """Watches files and directories for changes."""
>> +
>> +    def __init__(self, *paths):
>> +        """create an fswatcher for the given paths."""
>> +        self.paths = paths
>> +        self.mtimes = {}
>
>You should probably go ahead and cache entire stat objects, they're
>small.

Yeah but... I really only need the mtime now, and it simplifies the code
slightly further down, so... we can always change the implementation if we
need to.

-Sune


More information about the Mercurial-devel mailing list