← Back to team overview

dulwich-users team mailing list archive

Tree entries

 

In the stuff I'm doing on rename detection, I've been bitten a few times by
the weird ordering of (name, mode, sha) tuples coming out of various tree
iteration methods.

Currently, we have:
Tree.entries() yields (mode, name, sha)
Tree.iteritems() and BaseObjectStore.iter_tree_contents() yield (name, mode,
sha)
index.commit_tree() takes (name, sha, mode)

We should really standardize this, preferably in one of three ways:
1. Use (name, mode, sha) everywhere.
2. Use a namedtuple of (name, mode, sha).
2. Use a new data object.
I would prefer using a namedtuple would make some of the code I'm about to
write cleaner. It would also be backwards-compatible with the appropriate
type. The downside is that it's another feature that's new in 2.6.

In my ideal world we would get rid of Tree.entries() and change
index.commit_tree() to use the standard format, but I don't have a sense of
how widely either of those are used. Thoughts on how to proceed?

Follow ups