Mercurial > hg
comparison hgext/transplant.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 | dc237afacbd4 |
children | db171c6a1697 |
comparison
equal
deleted
inserted
replaced
28393:ac11ba7c2e56 | 28394:dcb4209bd30d |
---|---|
17 from mercurial.i18n import _ | 17 from mercurial.i18n import _ |
18 import os, tempfile | 18 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 |
26 | 26 |
27 cmdtable = {} | 27 cmdtable = {} |
692 tp.apply(repo, source, revmap, merges, opts) | 692 tp.apply(repo, source, revmap, merges, opts) |
693 finally: | 693 finally: |
694 if cleanupfn: | 694 if cleanupfn: |
695 cleanupfn() | 695 cleanupfn() |
696 | 696 |
697 revsetpredicate = revset.extpredicate() | 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): |
701 """Transplanted changesets in set, or all transplanted changesets. | 701 """Transplanted changesets in set, or all transplanted changesets. |
702 """ | 702 """ |
712 changeset if any.""" | 712 changeset if any.""" |
713 n = ctx.extra().get('transplant_source') | 713 n = ctx.extra().get('transplant_source') |
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'), |
721 _("use 'hg transplant --continue' or 'hg update' to abort")]) | 720 _("use 'hg transplant --continue' or 'hg update' to abort")]) |
722 | 721 |