Mercurial > hg
view hgext/inotify/__init__.py @ 9855:f47c0881b16e
inotify: Do not access inotify when dirstate is dirty (issue1811)
Original patch was provided by Simon Heimberg
It delegates dirstate computation to dirstate.status when dirstate is dirty:
better be slow from time to time instead of using wrong data.
This solves issue1719. As the last component, issue1810, is still not solved,
test-inotify-dirty-dirstate will fail for now. It emphasizes a regression due
to 7c01599dd340:
changeset: 9515:7c01599dd340
user: Nicolas Dumazet <nicdumz.commits@gmail.com>
date: Sun Aug 16 11:11:37 2009 +0900
summary: inotify: use cmdutil.service instead of local daemonizing code
Ancestors of 7c01599dd30 are passing the test, when applied this patch.
Regression has to be investigated, but this patch is important since it affects
often mq operations.
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Wed, 11 Nov 2009 14:38:59 +0900 |
parents | 7c01599dd340 |
children | 24ce8f0c0a39 25e572394f5c |
line wrap: on
line source
# __init__.py - inotify-based status acceleration for Linux # # Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com> # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2, incorporated herein by reference. '''accelerate status report using Linux's inotify service''' # todo: socket permissions from mercurial.i18n import _ from mercurial import cmdutil, util import server from client import client, QueryFailed def serve(ui, repo, **opts): '''start an inotify server for this repository''' server.start(ui, repo.dirstate, repo.root, opts) def debuginotify(ui, repo, **opts): '''debugging information for inotify extension Prints the list of directories being watched by the inotify server. ''' cli = client(ui, repo) response = cli.debugquery() ui.write(_('directories being watched:\n')) for path in response: ui.write((' %s/\n') % path) def reposetup(ui, repo): if not hasattr(repo, 'dirstate'): return class inotifydirstate(repo.dirstate.__class__): # We'll set this to false after an unsuccessful attempt so that # next calls of status() within the same instance don't try again # to start an inotify server if it won't start. _inotifyon = True def status(self, match, ignored, clean, unknown=True): files = match.files() if '.' in files: files = [] if self._inotifyon and not ignored and not self._dirty: cli = client(ui, repo) try: result = cli.statusquery(files, match, False, clean, unknown) except QueryFailed, instr: ui.debug(str(instr)) # don't retry within the same hg instance inotifydirstate._inotifyon = False pass else: if ui.config('inotify', 'debug'): r2 = super(inotifydirstate, self).status( match, False, clean, unknown) for c,a,b in zip('LMARDUIC', result, r2): for f in a: if f not in b: ui.warn('*** inotify: %s +%s\n' % (c, f)) for f in b: if f not in a: ui.warn('*** inotify: %s -%s\n' % (c, f)) result = r2 return result return super(inotifydirstate, self).status( match, ignored, clean, unknown) repo.dirstate.__class__ = inotifydirstate cmdtable = { 'debuginotify': (debuginotify, [], ('hg debuginotify')), '^inserve': (serve, [('d', 'daemon', None, _('run server in background')), ('', 'daemon-pipefds', '', _('used internally by daemon mode')), ('t', 'idle-timeout', '', _('minutes to sit idle before exiting')), ('', 'pid-file', '', _('name of file to write process ID to'))], _('hg inserve [OPTION]...')), }