Proposed Namespace Changes

Sean Farley sean.michael.farley at gmail.com
Thu Dec 18 19:10:55 CST 2014


Sure, that's fine but doesn't solve the 'namesof' case. Or are you saying
we shouldn't have the namesof method?

On Thursday, December 18, 2014, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

>
>
> On 12/18/2014 04:58 PM, Sean Farley wrote:
>
>>
>> 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)
>>
>
> What about repo.names being iterable `for namespace in repo.names`
>
> --
> Pierre-Yves David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20141218/13f078a5/attachment.html>


More information about the Mercurial-devel mailing list