Mercurial > hg
comparison hgext/rebase.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 | f9e755736b0e |
children | 157675d0f600 |
comparison
equal
deleted
inserted
replaced
27585:60bf90eb8bf8 | 27586:42910f9fffeb |
---|---|
62 # Destination defaults to the latest revision in the | 62 # Destination defaults to the latest revision in the |
63 # current branch | 63 # current branch |
64 branch = repo[None].branch() | 64 branch = repo[None].branch() |
65 return repo[branch].rev() | 65 return repo[branch].rev() |
66 | 66 |
67 revsetpredicate = revset.extpredicate() | |
68 | |
69 @revsetpredicate('_destrebase') | |
67 def _revsetdestrebase(repo, subset, x): | 70 def _revsetdestrebase(repo, subset, x): |
68 # ``_rebasedefaultdest()`` | 71 # ``_rebasedefaultdest()`` |
69 | 72 |
70 # default destination for rebase. | 73 # default destination for rebase. |
71 # # XXX: Currently private because I expect the signature to change. | 74 # # XXX: Currently private because I expect the signature to change. |
1236 cmdutil.unfinishedstates.append( | 1239 cmdutil.unfinishedstates.append( |
1237 ['rebasestate', False, False, _('rebase in progress'), | 1240 ['rebasestate', False, False, _('rebase in progress'), |
1238 _("use 'hg rebase --continue' or 'hg rebase --abort'")]) | 1241 _("use 'hg rebase --continue' or 'hg rebase --abort'")]) |
1239 # ensure rebased rev are not hidden | 1242 # ensure rebased rev are not hidden |
1240 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) | 1243 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) |
1241 revset.symbols['_destrebase'] = _revsetdestrebase | 1244 revsetpredicate.setup() |