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
|
2019-01-30 03:25:33 +03:00
|
|
|
> from edenscm.mercurial import registrar, namespaces
|
2018-09-12 05:43:00 +03:00
|
|
|
> 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
|
|
|
|
|
2019-12-13 21:27:16 +03:00
|
|
|
$ hg debugshell -c "ui.write('%s\n' % str(list(repo.names)))"
|
2020-03-26 18:23:49 +03:00
|
|
|
['bookmarks', 'branches', 'c', 'remotebookmarks', 'a']
|
2018-09-12 05:43:00 +03:00
|
|
|
|
|
|
|
$ newext << EOF
|
2019-01-30 03:25:33 +03:00
|
|
|
> from edenscm.mercurial import registrar, namespaces
|
2018-09-12 05:43:00 +03:00
|
|
|
> 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
|
2019-12-13 21:27:16 +03:00
|
|
|
$ hg debugshell -c "ui.write('%s\n' % str(list(repo.names)))"
|
2020-03-26 18:23:49 +03:00
|
|
|
['bookmarks', 'd', 'branches', 'c', 'remotebookmarks', 'a', 'z']
|
2018-09-14 02:44:26 +03:00
|
|
|
|
|
|
|
Test that not specifying the priority will result in failure to load the
|
|
|
|
extension.
|
|
|
|
|
|
|
|
$ newext << EOF
|
2019-01-30 03:25:33 +03:00
|
|
|
> from edenscm.mercurial import registrar, namespaces
|
2018-09-14 02:44:26 +03:00
|
|
|
> 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
|
2019-12-21 03:09:56 +03:00
|
|
|
warning: extension ext3 is disabled because it cannot be imported from $TESTTMP/ext3.py: namespace priority must be specified
|