'Upload a pack to a remote repository.
:param path: Repository path (as bytestring)
:param update_refs: Function to determine changes to remote refs.
Receive dict with existing remote refs, returns dict with
changed refs (name -> sha, where sha=ZERO_SHA for deletions)
:param generate_pack_contents: Function that can return a sequence of
the shas of the objects to upload.
:param progress: Optional progress function
:param write_pack: Function called with (file, iterable of objects) to
write the objects returned by generate_pack_contents to the server.
:raises SendPackError: if server rejects the pack data
:raises UpdateRefsError: if the server supports report-status
and rejects ref updates
:return: new_refs dictionary containing the changes that were made
{refname: new_ref}, including deleted refs.'

def send_pack(self, path, update_refs, generate_pack_contents, progress=None, write_pack=write_pack_objects):

    if (not progress):
        def progress(x):
            pass
    with self._open_repo(path) as target:
        old_refs = target.get_refs()
        new_refs = update_refs(dict(old_refs))
        have = [sha1 for sha1 in old_refs.values() if (sha1 != ZERO_SHA)]
        want = []
        for (refname, new_sha1) in new_refs.items():
            if ((new_sha1 not in have) and (new_sha1 not in want) and (new_sha1 != ZERO_SHA)):
                want.append(new_sha1)
        if ((not want) and set(new_refs.items()).issubset(set(old_refs.items()))):
            return new_refs
        target.object_store.add_objects(generate_pack_contents(have, want))
        for (refname, new_sha1) in new_refs.items():
            old_sha1 = old_refs.get(refname, ZERO_SHA)
            if (new_sha1 != ZERO_SHA):
                if (not target.refs.set_if_equals(refname, old_sha1, new_sha1)):
                    progress(('unable    to    set    %s    to    %s' % (refname, new_sha1)))
            elif (not target.refs.remove_if_equals(refname, old_sha1)):
                progress(('unable    to    remove    %s' % refname))
    return new_refs
