OrderedDict data structure in bzrlib?

Jelmer Vernooij jelmer at samba.org
Tue Sep 20 13:05:02 UTC 2011


On 20/09/11 08:58, Kirill Müller wrote:
> On 19.09.2011 23:34, Jelmer Vernooij wrote:
>> On Mon 19 Sep 2011 11:28:36 PM CEST, Kirill Müller wrote:
>>> I am planning to add a histedit command to the rewrite plugin [1], 
>>> and a data structure like collections.OrderedDict [2] would help a 
>>> lot. Unfortunately, OrderedDict is new in Python 2.7. Is there a 
>>> similar data structure, compatible with all supported versions of 
>>> Python, already available in bzrlib?
>>>
>>> I'd appreciate any feedback.
>> I'm pretty sure we don't have anything like that in bzrlib at the 
>> moment. What in particular do you need the OrderedDict for? Perhaps 
>> there are alternatives.
> In bzr-rewrite, the rebase-plan is unmarshalled into a dictionary, 
> destroying the order. Later, it is reordered by topologically sorting 
> the revisions. For rearranging commits in the "histedit" use case, the 
> ordering from the rebase-plan must be maintained during unmarshalling; 
> using OrderedDict instead of dict worked for me right away.
Is there any particular reason it would have to be a dictionary, 
couldn't it just be a list ?

The point of it being a dictionary at the moment is because the future 
revision ids are already determined, and this gives an easy way to look 
them up. This can't really be the case for something similar to "git 
rebase -i" as revisions can "fall out" if their changes have already 
been applied. This means future revisions (in particular, their parents) 
can't be planned ahead.

Cheers,

Jelmer



More information about the bazaar mailing list