##// END OF EJS Templates
localrepo: make supported features manageable in each repositories individually...
localrepo: make supported features manageable in each repositories individually Before this patch, all localrepositories support same features, because supported features are managed by the class variable "supported" of "localrepository". For example, "largefiles" feature provided by largefiles extension is recognized as supported, by adding the feature name to "supported" of "localrepository". So, commands handling multiple repositories at a time like below misunderstand that such features are supported also in repositories not enabling corresponded extensions: - clone/pull from or push to localhost - recursive execution in subrepo tree "reposetup()" can't be used to fix this problem, because it is invoked after checking whether supported features satisfy ones required in the target repository. So, this patch adds the set object named as "featuresetupfuncs" to "localrepository" to manage hook functions to setup supported features of each repositories. If any functions are added to "featuresetupfuncs", they are invoked, and information about supported features is managed in each repositories individually. This patch also adds checking below: - pull from localhost: whether features supported in the local(= dst) repository satisfies ones required in the remote(= src) - push to localhost: whether features supported in the remote(= dst) repository satisfies ones required in the local(= src) Managing supported features by the class variable means that there is no difference of supported features between each instances of "localrepository" in the same Python process, so such checking is not needed before this patch. Even with this patch, if intermediate bundlefile is used as pulling source, pulling indirectly from the remote repository, which requires features more than ones supported in the local, can't be prevented, because bundlefile has no information about "required features" in it.

File last commit:

r16743:38caf405 default
r19778:55ef7903 default
Show More
__init__.py
93 lines | 3.3 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
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Bryan O'Sullivan
Add inotify extension
r6239
Dirkjan Ochtman
extensions: fix up description lines some more
r8932 '''accelerate status report using Linux's inotify service'''
Bryan O'Sullivan
Add inotify extension
r6239
# todo: socket permissions
Martin Geisler
i18n: import _ instead of gettext
r7225 from mercurial.i18n import _
Augie Fackler
hgext: replace uses of hasattr with util.safehasattr
r14945 from mercurial import util
Martin Geisler
removed unused imports
r8656 import server
Nicolas Dumazet
inotify: Separate query sending logic from Server starting....
r8552 from client import client, QueryFailed
Bryan O'Sullivan
Add inotify extension
r6239
Augie Fackler
hgext: mark all first-party extensions as such
r16743 testedwith = 'internal'
Bryan O'Sullivan
Add inotify extension
r6239 def serve(ui, repo, **opts):
'''start an inotify server for this repository'''
Nicolas Dumazet
inotify: use cmdutil.service instead of local daemonizing code
r9514 server.start(ui, repo.dirstate, repo.root, opts)
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):
Augie Fackler
hgext: replace uses of hasattr with util.safehasattr
r14945 if not util.safehasattr(repo, 'dirstate'):
Bryan O'Sullivan
Add inotify extension
r6239 return
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
Greg Ward
inotify: expose the same dirstate.status() interface as dirstate....
r10605 def status(self, match, subrepos, ignored, clean, unknown):
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 = []
Brodie Rao
cleanup: eradicate long lines
r16683 if (self._inotifyon and not ignored and not subrepos and
not self._dirty):
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(
Benoit Boissinot
regression: missing arg from 24ce8f0c0a39 dirstate.{walk,status} changes
r10493 match, [], False, clean, unknown)
Matt Mackall
many, many trivial check-code fixups
r10282 for c, a, b in zip('LMARDUIC', result, r2):
Matt Mackall
inotify: add debugging mode to inotify...
r7219 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(
Augie Fackler
dirstate: don't check state of subrepo directories
r10176 match, subrepos, 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')),
FUJIWARA Katsunori
help: show value requirement and multiple occurrence of options...
r11321 ('', 'daemon-pipefds', '',
_('used internally by daemon mode'), _('NUM')),
('t', 'idle-timeout', '',
_('minutes to sit idle before exiting'), _('NUM')),
('', 'pid-file', '',
_('name of file to write process ID to'), _('FILE'))],
Martin Geisler
inotify: OPT -> OPTION in cmdline help string
r8947 _('hg inserve [OPTION]...')),
Bryan O'Sullivan
Add inotify extension
r6239 }