mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 01:39:21 +03:00
e6f4ea31d3
Summary: This would lead to less surprises than using the default priority. Reviewed By: quark-zju Differential Revision: D9818647 fbshipit-source-id: 59214eff84ea0b485ab8ff42b86df1c605a319f5
53 lines
1.4 KiB
Raku
53 lines
1.4 KiB
Raku
Test namespace registration using registrar
|
|
|
|
$ shorttraceback
|
|
|
|
$ newrepo
|
|
$ newext << EOF
|
|
> from mercurial import registrar, namespaces
|
|
> namespacepredicate = registrar.namespacepredicate()
|
|
> @namespacepredicate("a", priority=60)
|
|
> def a(_repo):
|
|
> return namespaces.namespace()
|
|
> @namespacepredicate("b", priority=70)
|
|
> def b(_repo):
|
|
> return None
|
|
> @namespacepredicate("c", priority=50)
|
|
> def c(_repo):
|
|
> return namespaces.namespace()
|
|
> EOF
|
|
|
|
$ hg debugshell -c "print(list(repo.names))"
|
|
['bookmarks', 'tags', 'branches', 'c', 'a']
|
|
|
|
$ newext << EOF
|
|
> from mercurial import registrar, namespaces
|
|
> namespacepredicate = registrar.namespacepredicate()
|
|
> @namespacepredicate("z", priority=99)
|
|
> def z(_repo):
|
|
> return namespaces.namespace()
|
|
> @namespacepredicate("d", priority=15)
|
|
> def d(_repo):
|
|
> return namespaces.namespace()
|
|
> EOF
|
|
$ hg debugshell -c "print(list(repo.names))"
|
|
['bookmarks', 'd', 'tags', 'branches', 'c', 'a', 'z']
|
|
|
|
|
|
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)
|