Mercurial > hg
comparison hgext/largefiles/uisetup.py @ 27586:42910f9fffeb
revset: use delayregistrar to register predicate in extension easily
Previous patch introduced 'revset.predicate' decorator to register
revset predicate function easily.
But it shouldn't be used in extension directly, because it registers
specified function immediately. Registration itself can't be restored,
even if extension loading fails after that.
Therefore, registration should be delayed until 'uisetup()' or so.
This patch uses 'extpredicate' decorator derived from 'delayregistrar'
to register predicate in extension easily.
This patch also tests whether 'registrar.delayregistrar' avoids
function registration if 'setup()' isn't invoked on it, because
'extpredicate' is the first user of it.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 29 Dec 2015 23:58:30 +0900 |
parents | ef21a2c41629 |
children | 4511e8dac4c7 |
comparison
equal
deleted
inserted
replaced
27585:60bf90eb8bf8 | 27586:42910f9fffeb |
---|---|
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
9 '''setup for largefiles extension: uisetup''' | 9 '''setup for largefiles extension: uisetup''' |
10 | 10 |
11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ | 11 from mercurial import archival, cmdutil, commands, extensions, filemerge, hg, \ |
12 httppeer, merge, scmutil, sshpeer, wireproto, revset, subrepo, copies | 12 httppeer, merge, scmutil, sshpeer, wireproto, subrepo, copies |
13 from mercurial.i18n import _ | 13 from mercurial.i18n import _ |
14 from mercurial.hgweb import hgweb_mod, webcommands | 14 from mercurial.hgweb import hgweb_mod, webcommands |
15 | 15 |
16 import overrides | 16 import overrides |
17 import proto | 17 import proto |
81 pullopt = [('', 'all-largefiles', None, | 81 pullopt = [('', 'all-largefiles', None, |
82 _('download all pulled versions of largefiles (DEPRECATED)')), | 82 _('download all pulled versions of largefiles (DEPRECATED)')), |
83 ('', 'lfrev', [], | 83 ('', 'lfrev', [], |
84 _('download largefiles for these revisions'), _('REV'))] | 84 _('download largefiles for these revisions'), _('REV'))] |
85 entry[1].extend(pullopt) | 85 entry[1].extend(pullopt) |
86 revset.symbols['pulled'] = overrides.pulledrevsetsymbol | |
87 | 86 |
88 entry = extensions.wrapcommand(commands.table, 'clone', | 87 entry = extensions.wrapcommand(commands.table, 'clone', |
89 overrides.overrideclone) | 88 overrides.overrideclone) |
90 cloneopt = [('', 'all-largefiles', None, | 89 cloneopt = [('', 'all-largefiles', None, |
91 _('download all versions of all largefiles'))] | 90 _('download all versions of all largefiles'))] |
168 extensions.wrapfunction(module, 'rebase', | 167 extensions.wrapfunction(module, 'rebase', |
169 overrides.overriderebase) | 168 overrides.overriderebase) |
170 if name == 'transplant': | 169 if name == 'transplant': |
171 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', | 170 extensions.wrapcommand(getattr(module, 'cmdtable'), 'transplant', |
172 overrides.overridetransplant) | 171 overrides.overridetransplant) |
172 | |
173 overrides.revsetpredicate.setup() |