Community
Participate
Working Groups
I find the repo flags used in IRepositoryManager.getKnownRepositories(flags) confusing. They aren't truly bits that can be OR'ed together, although they appear on first glance that way. Some act as filters to the other bits, some do not. REPOSITORIES_DISABLED | REPOSITORIES_LOCAL will give me all disabled local repos REPOSITORIES_ALL | REPOSITORIES_LOCAL gives all enabled local repos To get all (enabled and disabled) local repos I have to combine them myself using the above two calls. I'd rather be able to say REPOSITORIES_LOCAL | REPOSITORIES_ENABLED | REPOSITORIES_DISABLED Likewise I can't say REPOSITORIES_SYSTEM | REPOSITORIES_NON_SYSTEM | REPOSITORIES_DISABLED to get all the disabled repos. I have to do it twice, once for system and once for non-system. I find I always have to refer to the implementation of matchesFlag to figure out how to do what I want, ie, which ones are filters that disregard the other bits and which ones are bits that can truly be combined with others. This causes problems in the UI because I'd like to let clients pass me the repo bits to fully describe which repos they want to see, but they can't do that. So I've had to introduce extra flags like "includeDisabledRepositories" so that I can make the multiple calls needed to get the list of repos correct.
Yes, it is confusing. Part of the confusion is that getKnownRepositories initially had a default behaviour (all enabled repositories), so when we added flags there is essentially always an implicit REPOSITORIES_ENABLED flag. However, I don't know how we can express what you are looking for purely with flags. This: REPOSITORIES_LOCAL | REPOSITORIES_ENABLED | REPOSITORIES_DISABLED Would always return everything, since every repository is either ENABLED or DISABLED. What you are trying to express is something more like: REPOSITORIES_LOCAL & (REPOSITORIES_ENABLED | REPOSITORIES_DISABLED) Which can't be expressed with a pure bit mask. >Likewise I can't say >REPOSITORIES_SYSTEM | REPOSITORIES_NON_SYSTEM | REPOSITORIES_DISABLED >to get all the disabled repos. I have to do it twice, once for system and once >for non-system. I think you can do this one with simply getKnownRepositories(REPOSITORIES_DISABLED). The flags in practice act like exclusion filters (LOCAL means "exclude non-local", SYSTEM means "exclude non-system", etc). So, it might be less confusing if they were renamed as such. I'm still not sure this would allow you to express everything you want in a single mask.
maybe just reexamining the naming and some examples in the javadoc would help. Part of what's odd is that in one case we provide filters for both states of a boolean (SYSTEM, NON_SYSTEM) and in other cases we do not (LOCAL, DISABLED). So it's hard to just glance at the bits and figure out what to do.
Putting that back on the list for API.
Created attachment 161189 [details] Fix Here's my attempt at clarifying this without completely reinventing how this works. I have just added more javadoc on each of the flags and on getKnownRepositories to describe how they behave. I have also added a NON_LOCAL flag for symmetry with LOCAL, although I'm not sure if there is any demand for it. I also played around with inverting the flag names (REPOSITORIES_SYSTEM becomes REPOSITORIES_EXCLUDE_NON_SYSTEM), but with a few samples it didn't look any more intuitive to me with double-negative terms like this.
Released in HEAD.