Show More
@@ -111,6 +111,7 b' import lfcommands' | |||
|
111 | 111 | import proto |
|
112 | 112 | import reposetup |
|
113 | 113 | import uisetup as uisetupmod |
|
114 | import overrides | |
|
114 | 115 | |
|
115 | 116 | # Note for extension authors: ONLY specify testedwith = 'internal' for |
|
116 | 117 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
@@ -130,3 +131,4 b' def uisetup(ui):' | |||
|
130 | 131 | uisetupmod.uisetup(ui) |
|
131 | 132 | |
|
132 | 133 | cmdtable = lfcommands.cmdtable |
|
134 | revsetpredicate = overrides.revsetpredicate |
@@ -12,7 +12,7 b' import os' | |||
|
12 | 12 | import copy |
|
13 | 13 | |
|
14 | 14 | from mercurial import hg, util, cmdutil, scmutil, match as match_, \ |
|
15 | archival, pathutil, revset, error | |
|
15 | archival, pathutil, registrar, revset, error | |
|
16 | 16 | from mercurial.i18n import _ |
|
17 | 17 | |
|
18 | 18 | import lfutil |
@@ -801,7 +801,7 b' def overridepull(orig, ui, repo, source=' | |||
|
801 | 801 | ui.status(_("%d largefiles cached\n") % numcached) |
|
802 | 802 | return result |
|
803 | 803 | |
|
804 |
revsetpredicate = re |
|
|
804 | revsetpredicate = registrar.revsetpredicate() | |
|
805 | 805 | |
|
806 | 806 | @revsetpredicate('pulled()') |
|
807 | 807 | def pulledrevsetsymbol(repo, subset, x): |
@@ -171,5 +171,3 b' def uisetup(ui):' | |||
|
171 | 171 | if name == 'transplant': |
|
172 | 172 | extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', |
|
173 | 173 | overrides.overridetransplant) |
|
174 | ||
|
175 | overrides.revsetpredicate.setup() |
@@ -70,6 +70,7 b' from mercurial import extensions, error,' | |||
|
70 | 70 | from mercurial import patch as patchmod |
|
71 | 71 | from mercurial import lock as lockmod |
|
72 | 72 | from mercurial import localrepo |
|
73 | from mercurial import registrar | |
|
73 | 74 | from mercurial import subrepo |
|
74 | 75 | import os, re, errno, shutil |
|
75 | 76 | |
@@ -3536,7 +3537,7 b' def summaryhook(ui, repo):' | |||
|
3536 | 3537 | # i18n: column positioning for "hg summary" |
|
3537 | 3538 | ui.note(_("mq: (empty queue)\n")) |
|
3538 | 3539 | |
|
3539 |
revsetpredicate = re |
|
|
3540 | revsetpredicate = registrar.revsetpredicate() | |
|
3540 | 3541 | |
|
3541 | 3542 | @revsetpredicate('mq()') |
|
3542 | 3543 | def revsetmq(repo, subset, x): |
@@ -3575,8 +3576,6 b' def extsetup(ui):' | |||
|
3575 | 3576 | if extmodule.__file__ != __file__: |
|
3576 | 3577 | dotable(getattr(extmodule, 'cmdtable', {})) |
|
3577 | 3578 | |
|
3578 | revsetpredicate.setup() | |
|
3579 | ||
|
3580 | 3579 | colortable = {'qguard.negative': 'red', |
|
3581 | 3580 | 'qguard.positive': 'yellow', |
|
3582 | 3581 | 'qguard.unguarded': 'green', |
@@ -16,7 +16,7 b' https://mercurial-scm.org/wiki/RebaseExt' | |||
|
16 | 16 | |
|
17 | 17 | from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks |
|
18 | 18 | from mercurial import extensions, patch, scmutil, phases, obsolete, error |
|
19 | from mercurial import copies, destutil, repoview, revset | |
|
19 | from mercurial import copies, destutil, repoview, registrar, revset | |
|
20 | 20 | from mercurial.commands import templateopts |
|
21 | 21 | from mercurial.node import nullrev, nullid, hex, short |
|
22 | 22 | from mercurial.lock import release |
@@ -76,7 +76,7 b' def _destrebase(repo, sourceset):' | |||
|
76 | 76 | return destutil.destmerge(repo, action='rebase', sourceset=sourceset, |
|
77 | 77 | onheadcheck=False) |
|
78 | 78 | |
|
79 |
revsetpredicate = re |
|
|
79 | revsetpredicate = registrar.revsetpredicate() | |
|
80 | 80 | |
|
81 | 81 | @revsetpredicate('_destrebase') |
|
82 | 82 | def _revsetdestrebase(repo, subset, x): |
@@ -1325,4 +1325,3 b' def uisetup(ui):' | |||
|
1325 | 1325 | ['rebasestate', _('hg rebase --continue')]) |
|
1326 | 1326 | # ensure rebased rev are not hidden |
|
1327 | 1327 | extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) |
|
1328 | revsetpredicate.setup() |
@@ -19,7 +19,7 b' import os, tempfile' | |||
|
19 | 19 | from mercurial.node import short |
|
20 | 20 | from mercurial import bundlerepo, hg, merge, match |
|
21 | 21 | from mercurial import patch, revlog, scmutil, util, error, cmdutil |
|
22 | from mercurial import revset, templatekw, exchange | |
|
22 | from mercurial import registrar, revset, templatekw, exchange | |
|
23 | 23 | |
|
24 | 24 | class TransplantError(error.Abort): |
|
25 | 25 | pass |
@@ -694,7 +694,7 b' def _dotransplant(ui, repo, *revs, **opt' | |||
|
694 | 694 | if cleanupfn: |
|
695 | 695 | cleanupfn() |
|
696 | 696 | |
|
697 |
revsetpredicate = re |
|
|
697 | revsetpredicate = registrar.revsetpredicate() | |
|
698 | 698 | |
|
699 | 699 | @revsetpredicate('transplanted([set])') |
|
700 | 700 | def revsettransplanted(repo, subset, x): |
@@ -714,7 +714,6 b' def kwtransplanted(repo, ctx, **args):' | |||
|
714 | 714 | return n and revlog.hex(n) or '' |
|
715 | 715 | |
|
716 | 716 | def extsetup(ui): |
|
717 | revsetpredicate.setup() | |
|
718 | 717 | templatekw.keywords['transplanted'] = kwtransplanted |
|
719 | 718 | cmdutil.unfinishedstates.append( |
|
720 | 719 | ['transplant/journal', True, False, _('transplant in progress'), |
@@ -33,6 +33,7 b' from . import (' | |||
|
33 | 33 | fancyopts, |
|
34 | 34 | hg, |
|
35 | 35 | hook, |
|
36 | revset, | |
|
36 | 37 | ui as uimod, |
|
37 | 38 | util, |
|
38 | 39 | ) |
@@ -752,6 +753,7 b' def _checkshellalias(lui, ui, args, prec' | |||
|
752 | 753 | # extraobj) arguments |
|
753 | 754 | extraloaders = [ |
|
754 | 755 | ('cmdtable', commands, 'loadcmdtable'), |
|
756 | ('revsetpredicate', revset, 'loadpredicate'), | |
|
755 | 757 | ] |
|
756 | 758 | |
|
757 | 759 | def _dispatch(req): |
@@ -2191,28 +2191,21 b' test error message of bad revset' | |||
|
2191 | 2191 | |
|
2192 | 2192 | $ cd .. |
|
2193 | 2193 | |
|
2194 | Test registrar.delayregistrar via revset.extpredicate | |
|
2195 | ||
|
2196 | 'extpredicate' decorator shouldn't register any functions until | |
|
2197 | 'setup()' on it. | |
|
2194 | Test that revset predicate of extension isn't loaded at failure of | |
|
2195 | loading it | |
|
2198 | 2196 | |
|
2199 | 2197 | $ cd repo |
|
2200 | 2198 | |
|
2201 | 2199 | $ cat <<EOF > $TESTTMP/custompredicate.py |
|
2202 | > from mercurial import revset | |
|
2200 | > from mercurial import error, registrar, revset | |
|
2203 | 2201 | > |
|
2204 |
> revsetpredicate = re |
|
|
2202 | > revsetpredicate = registrar.revsetpredicate() | |
|
2205 | 2203 | > |
|
2206 | 2204 | > @revsetpredicate('custom1()') |
|
2207 | 2205 | > def custom1(repo, subset, x): |
|
2208 | 2206 | > return revset.baseset([1]) |
|
2209 | > @revsetpredicate('custom2()') | |
|
2210 | > def custom2(repo, subset, x): | |
|
2211 | > return revset.baseset([2]) | |
|
2212 | 2207 | > |
|
2213 | > def uisetup(ui): | |
|
2214 | > if ui.configbool('custompredicate', 'enabled'): | |
|
2215 | > revsetpredicate.setup() | |
|
2208 | > raise error.Abort('intentional failure of loading extension') | |
|
2216 | 2209 | > EOF |
|
2217 | 2210 | $ cat <<EOF > .hg/hgrc |
|
2218 | 2211 | > [extensions] |
@@ -2220,13 +2213,8 b' Test registrar.delayregistrar via revset' | |||
|
2220 | 2213 | > EOF |
|
2221 | 2214 | |
|
2222 | 2215 | $ hg debugrevspec "custom1()" |
|
2216 | *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension | |
|
2223 | 2217 | hg: parse error: unknown identifier: custom1 |
|
2224 | 2218 | [255] |
|
2225 | $ hg debugrevspec "custom2()" | |
|
2226 | hg: parse error: unknown identifier: custom2 | |
|
2227 | [255] | |
|
2228 | $ hg debugrevspec "custom1() or custom2()" --config custompredicate.enabled=true | |
|
2229 | 1 | |
|
2230 | 2 | |
|
2231 | 2219 | |
|
2232 | 2220 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now