sapling/eden/scm/tests/test-namespaces.t
Jun Wu cc1b1bd6a9 remotenames: move namespace to core
Summary:
This makes it possible to resolve remotenames without enabling the remotenames
extension.

The config check `if repo.ui.configbool("remotenames", "bookmarks")` is dropped
intentionally as we only use remotenames for bookmarks, not named branches.

Since this only enables resolving more names, without disabling or changing
other features, and the remotename namespace priority is lower than local
bookmarks (ex. if a local `master` exists, then `master` will be using the
local bookmark, not the hoisted remote name), it should not cause breaking
changes.

Reviewed By: markbt

Differential Revision: D20529359

fbshipit-source-id: 4126faee1bb7f43ba547fab05dd6197b2e65c1fc
2020-03-26 08:26:26 -07:00

52 lines
1.6 KiB
Perl

Test namespace registration using registrar
$ shorttraceback
$ newrepo
$ newext << EOF
> from edenscm.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 "ui.write('%s\n' % str(list(repo.names)))"
['bookmarks', 'branches', 'c', 'remotebookmarks', 'a']
$ newext << EOF
> from edenscm.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 "ui.write('%s\n' % str(list(repo.names)))"
['bookmarks', 'd', 'branches', 'c', 'remotebookmarks', 'a', 'z']
Test that not specifying the priority will result in failure to load the
extension.
$ newext << EOF
> from edenscm.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
warning: extension ext3 is disabled because it cannot be imported from $TESTTMP/ext3.py: namespace priority must be specified