jelmer/dulwich — pull request #75 by D-Key (2012-11-12 22:25:04+00:00)
Title: alternates: is it possible to use the same logic in __contains__ and __getitem__?

Hi,

We've introduced repositories with alternate object stores in our project, and bumped into some inconsistent results when either retrieving an object with `repository[sha]` or checking for it's presence first with `if sha in repository`.

Apparently, `__getitem__` in `DiskObjectStore` works with alternate stores just fine, while `__contains__` ignores them. I might be missing it, but it seems that there is no Dulwich-native call to check if a given object exists in the main or alternate stores.

I was wondering if it makes sense to adjust `__contains__` logic to return True for all SHAs that can be resolved by `__getitem__`, like in the attached commits, or perhaps expose some other way to efficiently check for object presence in Dulwich?