cmp_sort_key: reference functools.cmp_to_key()
append_repo: preserve existing repo atom

This will fix bug #461948.