diff tests/test-revset.t @ 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 d2ac8b57a75d
children 0d79d91ba7e3
line wrap: on
line diff
--- a/tests/test-revset.t	Tue Mar 08 23:04:53 2016 +0900
+++ b/tests/test-revset.t	Tue Mar 08 23:04:53 2016 +0900
@@ -2191,28 +2191,21 @@
 
   $ cd ..
 
-Test registrar.delayregistrar via revset.extpredicate
-
-'extpredicate' decorator shouldn't register any functions until
-'setup()' on it.
+Test that revset predicate of extension isn't loaded at failure of
+loading it
 
   $ cd repo
 
   $ cat <<EOF > $TESTTMP/custompredicate.py
-  > from mercurial import revset
+  > from mercurial import error, registrar, revset
   > 
-  > revsetpredicate = revset.extpredicate()
+  > revsetpredicate = registrar.revsetpredicate()
   > 
   > @revsetpredicate('custom1()')
   > def custom1(repo, subset, x):
   >     return revset.baseset([1])
-  > @revsetpredicate('custom2()')
-  > def custom2(repo, subset, x):
-  >     return revset.baseset([2])
   > 
-  > def uisetup(ui):
-  >     if ui.configbool('custompredicate', 'enabled'):
-  >         revsetpredicate.setup()
+  > raise error.Abort('intentional failure of loading extension')
   > EOF
   $ cat <<EOF > .hg/hgrc
   > [extensions]
@@ -2220,13 +2213,8 @@
   > EOF
 
   $ hg debugrevspec "custom1()"
+  *** failed to import extension custompredicate from $TESTTMP/custompredicate.py: intentional failure of loading extension
   hg: parse error: unknown identifier: custom1
   [255]
-  $ hg debugrevspec "custom2()"
-  hg: parse error: unknown identifier: custom2
-  [255]
-  $ hg debugrevspec "custom1() or custom2()" --config custompredicate.enabled=true
-  1
-  2
 
   $ cd ..