comparison hgext/mq.py @ 28394:dcb4209bd30d

revset: replace extpredicate by revsetpredicate of registrar This patch consists of changes below (these can't be applied separately). - replace revset.extpredicate by registrar.revsetpredicate in extensions - remove setup() on an instance named as revsetpredicate in uisetup()/extsetup() of each extensions registrar.revsetpredicate doesn't have setup() API. - put new entry for revsetpredicate into extraloaders in dispatch This causes implicit loading predicate functions at loading extension. This loading mechanism requires that an extension has an instance named as revsetpredicate, and this is reason why largefiles/__init__.py is also changed in this patch. Before this patch, test-revset.t tests that all decorated revset predicates are loaded by explicit setup() at once ("all or nothing"). Now, test-revset.t tests that any revset predicate isn't loaded at failure of loading extension, because loading itself is executed by dispatch and it can't be controlled on extension side.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 08 Mar 2016 23:04:53 +0900
parents aa73d6a5d9ea
children 3072ce740945
comparison
equal deleted inserted replaced
28393:ac11ba7c2e56 28394:dcb4209bd30d
68 from mercurial import commands, cmdutil, hg, scmutil, util, revset 68 from mercurial import commands, cmdutil, hg, scmutil, util, revset
69 from mercurial import extensions, error, phases 69 from mercurial import extensions, error, phases
70 from mercurial import patch as patchmod 70 from mercurial import patch as patchmod
71 from mercurial import lock as lockmod 71 from mercurial import lock as lockmod
72 from mercurial import localrepo 72 from mercurial import localrepo
73 from mercurial import registrar
73 from mercurial import subrepo 74 from mercurial import subrepo
74 import os, re, errno, shutil 75 import os, re, errno, shutil
75 76
76 seriesopts = [('s', 'summary', None, _('print first line of patch header'))] 77 seriesopts = [('s', 'summary', None, _('print first line of patch header'))]
77 78
3534 ui.write(_("mq: %s\n") % ', '.join(m)) 3535 ui.write(_("mq: %s\n") % ', '.join(m))
3535 else: 3536 else:
3536 # i18n: column positioning for "hg summary" 3537 # i18n: column positioning for "hg summary"
3537 ui.note(_("mq: (empty queue)\n")) 3538 ui.note(_("mq: (empty queue)\n"))
3538 3539
3539 revsetpredicate = revset.extpredicate() 3540 revsetpredicate = registrar.revsetpredicate()
3540 3541
3541 @revsetpredicate('mq()') 3542 @revsetpredicate('mq()')
3542 def revsetmq(repo, subset, x): 3543 def revsetmq(repo, subset, x):
3543 """Changesets managed by MQ. 3544 """Changesets managed by MQ.
3544 """ 3545 """
3573 3574
3574 for extname, extmodule in extensions.extensions(): 3575 for extname, extmodule in extensions.extensions():
3575 if extmodule.__file__ != __file__: 3576 if extmodule.__file__ != __file__:
3576 dotable(getattr(extmodule, 'cmdtable', {})) 3577 dotable(getattr(extmodule, 'cmdtable', {}))
3577 3578
3578 revsetpredicate.setup()
3579
3580 colortable = {'qguard.negative': 'red', 3579 colortable = {'qguard.negative': 'red',
3581 'qguard.positive': 'yellow', 3580 'qguard.positive': 'yellow',
3582 'qguard.unguarded': 'green', 3581 'qguard.unguarded': 'green',
3583 'qseries.applied': 'blue bold underline', 3582 'qseries.applied': 'blue bold underline',
3584 'qseries.guarded': 'black bold', 3583 'qseries.guarded': 'black bold',