'Convenience function to make swapping repositories easier.
This is currently used by mock tests.
TODO: Maybe there is a cleaner way.'

def swap(self, other):

    attrs = ['repos', 'by_namespace', 'by_path', '_all_package_names', '_provider_index']
    for attr in attrs:
        tmp = getattr(self, attr)
        setattr(self, attr, getattr(other, attr))
        setattr(other, attr, tmp)
