def mergeusers(ui, base, divergent, other):
    """ merges the users from two divergent changesets using three-way merge
    and return the user that will be used as the author of resolved cset"""
    baseuser = base.user()
    divuser = divergent.user()
    othuser = other.user()
    if divuser == othuser:
        return divuser
    elif baseuser == divuser:
        return othuser
    elif baseuser == othuser:
        return divuser
    else:
        users = set(divuser.split(b', '))
        users.update(othuser.split(b', '))
        user = b', '.join(sorted(users))
        return user
