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