OrderedDict data structure in bzrlib?

Kirill Müller mail at kirill-mueller.de
Wed Sep 21 12:39:17 UTC 2011


On 20.09.2011 15:05, Jelmer Vernooij wrote:
> 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
I planned to design the command so that most of the current rewrite code 
remains "as-is". Introducing a new rebase plan format would probably 
break more than I'd be keen on fixing myself :-)

This means that I'll try to plan ahead all of the rebase plan. Could you 
give a specific example where you think this might be impossible?

Thanks again for your advice.


Regards

Kirill



More information about the bazaar mailing list