Proposed Namespace Changes

Sean Farley sean.michael.farley at gmail.com
Thu Dec 18 18:58:06 CST 2014


Sean Farley writes:

> Following discussion on IRC with marmoute, it seems that having an
> individual namespace as an object would look better. Here is a
> hypothetical example:
>
> repo.names = {}
>
> repo.names["bookmarks"] = namespace.create(repo, "bookmarks", "bookmark", ...)
>
> repo.names["bookmarks"].listnames() (should we rename 'allnames'?)
>
> repo.names["bookmarks"].templatename
>
> repo.names["bookmarks"].namesof(nodeid)
>
> Let's look at all the method names we have so far,
>
> - singlenode(name) -> returns first node found, errors out otherwise
>
> - names(namespace, node) -> returns list of names
>
> - namesof(node) -> return dictionary of {namespace: name}
>
> - allnames(namespace) -> returns list of names in a namespace
>
> - namespaces() -> return list of namespaces
>
> Here's how it would look as an object:
>
> - singlenode(name) -> returns first node found, errors out otherwise
>
> - names(node) -> returns list of names
>
> - repo.names.namesof(node) -> return dictionary of {namespace: name}
>
> - allnames() -> returns list of names in a namespace
>
> - repo.names.keys() -> return list of namespaces
>
> So, the only kink here is the 'namesof' method since we'd be operating
> on each namespace independently. Thoughts?

To answer my own question, I think the solution here would be two
objects:

- namespaces (inherits or wraps a sortdict)
- namespace (the proposed changes)

This would mean we could call methods on all namespaces via its object:

repo.names.listnames() -> return all namespaces (same as the keys of its
dictionary)

Thoughts against or for this?


More information about the Mercurial-devel mailing list