2018-09-12 05:43:00 +03:00
|
|
|
Test namespace registration using registrar
|
|
|
|
|
|
|
|
$ shorttraceback
|
2018-09-12 22:32:02 +03:00
|
|
|
|
2018-09-12 05:43:00 +03:00
|
|
|
$ newrepo
|
|
|
|
$ newext << EOF
|
|
|
|
> from mercurial import registrar, namespaces
|
|
|
|
> namespacepredicate = registrar.namespacepredicate()
|
2018-09-12 22:32:02 +03:00
|
|
|
> @namespacepredicate("a", priority=60)
|
2018-09-12 05:43:00 +03:00
|
|
|
> def a(_repo):
|
2018-09-14 02:44:26 +03:00
|
|
|
> return namespaces.namespace()
|
2018-09-12 22:32:02 +03:00
|
|
|
> @namespacepredicate("b", priority=70)
|
2018-09-12 05:43:00 +03:00
|
|
|
> def b(_repo):
|
|
|
|
> return None
|
2018-09-12 22:32:02 +03:00
|
|
|
> @namespacepredicate("c", priority=50)
|
2018-09-12 05:43:00 +03:00
|
|
|
> def c(_repo):
|
2018-09-14 02:44:26 +03:00
|
|
|
> return namespaces.namespace()
|
2018-09-12 05:43:00 +03:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
$ hg debugshell -c "print(list(repo.names))"
|
|
|
|
['bookmarks', 'tags', 'branches', 'c', 'a']
|
|
|
|
|
|
|
|
$ newext << EOF
|
|
|
|
> from mercurial import registrar, namespaces
|
|
|
|
> namespacepredicate = registrar.namespacepredicate()
|
2018-09-12 22:32:02 +03:00
|
|
|
> @namespacepredicate("z", priority=99)
|
2018-09-12 05:43:00 +03:00
|
|
|
> def z(_repo):
|
2018-09-14 02:44:26 +03:00
|
|
|
> return namespaces.namespace()
|
2018-09-12 22:32:02 +03:00
|
|
|
> @namespacepredicate("d", priority=15)
|
2018-09-12 05:43:00 +03:00
|
|
|
> def d(_repo):
|
2018-09-14 02:44:26 +03:00
|
|
|
> return namespaces.namespace()
|
2018-09-12 05:43:00 +03:00
|
|
|
> EOF
|
|
|
|
$ hg debugshell -c "print(list(repo.names))"
|
2018-09-12 22:32:02 +03:00
|
|
|
['bookmarks', 'd', 'tags', 'branches', 'c', 'a', 'z']
|
2018-09-12 05:43:00 +03:00
|
|
|
|
2018-09-14 02:44:26 +03:00
|
|
|
|
|
|
|
Test that not specifying the priority will result in failure to load the
|
|
|
|
extension.
|
|
|
|
|
|
|
|
$ newext << EOF
|
|
|
|
> from mercurial import registrar, namespaces
|
|
|
|
> namespacepredicate = registrar.namespacepredicate()
|
|
|
|
> @namespacepredicate("x", priority=None)
|
|
|
|
> def z(_repo):
|
|
|
|
> return namespaces.namespace()
|
|
|
|
> EOF
|
|
|
|
|
|
|
|
|
|
|
|
- Run any command to test that the extension loading failed.
|
|
|
|
|
|
|
|
$ hg status
|
|
|
|
* failed to import extension *: namespace priority must be specified (glob)
|