##// END OF EJS Templates
i18n-pt_BR: synchronized with eac360045ba4
i18n-pt_BR: synchronized with eac360045ba4

File last commit:

r8947:9cda7821 default
r8978:2656a5b4 default
Show More
__init__.py
111 lines | 3.8 KiB | text/x-python | PythonLexer
Bryan O'Sullivan
Add inotify extension
r6239 # __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>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
# GNU General Public License version 2, incorporated herein by reference.
Bryan O'Sullivan
Add inotify extension
r6239
Cédric Duval
extensions: improve the consistency of synopses...
r8894 '''accelerate status report using system level services'''
Bryan O'Sullivan
Add inotify extension
r6239
# todo: socket permissions
Martin Geisler
i18n: import _ instead of gettext
r7225 from mercurial.i18n import _
Bryan O'Sullivan
Add inotify extension
r6239 from mercurial import cmdutil, util
Martin Geisler
removed unused imports
r8656 import server
Bryan O'Sullivan
Add inotify extension
r6239 from weakref import proxy
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 from client import client, QueryFailed
Bryan O'Sullivan
Add inotify extension
r6239
def serve(ui, repo, **opts):
'''start an inotify server for this repository'''
timeout = opts.get('timeout')
if timeout:
timeout = float(timeout) * 1e3
Benoit Boissinot
use new style classes
r8778 class service(object):
Bryan O'Sullivan
Add inotify extension
r6239 def init(self):
Benoit Boissinot
inotify: fix traceback when the server has been already started
r6995 try:
Nicolas Dumazet
inotify: Coding Style: name classes in lowercase.
r8385 self.master = server.master(ui, repo, timeout)
Benoit Boissinot
inotify: fix traceback when the server has been already started
r6995 except server.AlreadyStartedException, inst:
raise util.Abort(str(inst))
Bryan O'Sullivan
Add inotify extension
r6239
def run(self):
try:
self.master.run()
finally:
self.master.shutdown()
service = service()
Nicolas Dumazet
inotify: add log config option redirect inotify server output to a file
r8790 logfile = ui.config('inotify', 'log')
cmdutil.service(opts, initfn=service.init, runfn=service.run,
logfile=logfile)
Bryan O'Sullivan
Add inotify extension
r6239
Nicolas Dumazet
inotify: introduce debuginotify, which lists which paths are under watch
r8555 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)
Bryan O'Sullivan
Add inotify extension
r6239 def reposetup(ui, repo):
Brendan Cully
inotify: do not attempt to monkeypatch bundlerepos
r7522 if not hasattr(repo, 'dirstate'):
Bryan O'Sullivan
Add inotify extension
r6239 return
# XXX: weakref until hg stops relying on __del__
repo = proxy(repo)
class inotifydirstate(repo.dirstate.__class__):
Nicolas Dumazet
inotify: set a flag so a failed inotify query doesn't get repeated....
r8556 # 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
Matt Mackall
repo.status: eliminate list_
r6753 def status(self, match, ignored, clean, unknown=True):
Matt Mackall
match: remove files arg from repo.status and friends
r6603 files = match.files()
Brendan Cully
inotify: fix status . in repo.root
r7393 if '.' in files:
Dirkjan Ochtman
kill some trailing spaces
r7434 files = []
Nicolas Dumazet
inotify: Removing the unnecessary "inotifyserver" class variable.
r8557 if self._inotifyon and not ignored:
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 cli = client(ui, repo)
try:
Nicolas Dumazet
inotify: modular architecture for inotify clients...
r8551 result = cli.statusquery(files, match, False,
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 clean, unknown)
except QueryFailed, instr:
ui.debug(str(instr))
Nicolas Dumazet
inotify: set a flag so a failed inotify query doesn't get repeated....
r8556 # don't retry within the same hg instance
inotifydirstate._inotifyon = False
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 pass
else:
if ui.config('inotify', 'debug'):
Matt Mackall
inotify: add debugging mode to inotify...
r7219 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:
Benoit Boissinot
inotify: fix bug in formatting
r7304 ui.warn('*** inotify: %s -%s\n' % (c, f))
Matt Mackall
inotify: add debugging mode to inotify...
r7219 result = r2
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 return result
Bryan O'Sullivan
Add inotify extension
r6239 return super(inotifydirstate, self).status(
Matt Mackall
repo.status: eliminate list_
r6753 match, ignored, clean, unknown)
Bryan O'Sullivan
Add inotify extension
r6239
repo.dirstate.__class__ = inotifydirstate
cmdtable = {
Nicolas Dumazet
inotify: introduce debuginotify, which lists which paths are under watch
r8555 'debuginotify':
(debuginotify, [], ('hg debuginotify')),
Bryan O'Sullivan
Add inotify extension
r6239 '^inserve':
Nicolas Dumazet
inotify: introduce debuginotify, which lists which paths are under watch
r8555 (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 [OPT]...')),
Bryan O'Sullivan
Add inotify extension
r6239 }