'Determine the wants for a set of heads.
The given heads are advertised to the client, who then specifies which
refs he wants using \'want\' lines. This portion of the protocol is the
same regardless of ack type, and in fact is used to set the ack type of
the ProtocolGraphWalker.
If the client has the \'shallow\' capability, this method also reads and
responds to the \'shallow\' and \'deepen\' lines from the client. These are
not part of the wants per se, but they set up necessary state for
walking the graph. Additionally, later code depends on this method
consuming everything up to the first \'have\' line.
:param heads: a dict of refname->SHA1 to advertise
:return: a list of SHA1s requested by the client'

def determine_wants(self, heads):

    symrefs = self.get_symrefs()
    values = set(heads.values())
    if (self.advertise_refs or (not self.http_req)):
        for (i, (ref, sha)) in enumerate(sorted(heads.items())):
            line = ((sha + '    ') + ref)
            if (not i):
                line += ('\x00' + self.handler.capability_line((self.handler.capabilities() + symref_capabilities(symrefs.items()))))
            self.proto.write_pkt_line((line + '\n'))
            peeled_sha = self.get_peeled(ref)
            if (peeled_sha != sha):
                self.proto.write_pkt_line(((((peeled_sha + '    ') + ref) + ANNOTATED_TAG_SUFFIX) + '\n'))
        self.proto.write_pkt_line(None)
        if self.advertise_refs:
            return []
    want = self.proto.read_pkt_line()
    if (not want):
        return []
    (line, caps) = extract_want_line_capabilities(want)
    self.handler.set_client_capabilities(caps)
    self.set_ack_type(ack_type(caps))
    allowed = (COMMAND_WANT, COMMAND_SHALLOW, COMMAND_DEEPEN, None)
    (command, sha) = _split_proto_line(line, allowed)
    want_revs = []
    while (command == COMMAND_WANT):
        if (sha not in values):
            raise GitProtocolError(('Client    wants    invalid    object    %s' % sha))
        want_revs.append(sha)
        (command, sha) = self.read_proto_line(allowed)
    self.set_wants(want_revs)
    if (command in (COMMAND_SHALLOW, COMMAND_DEEPEN)):
        self.unread_proto_line(command, sha)
        self._handle_shallow_request(want_revs)
    if (self.http_req and self.proto.eof()):
        return []
    return want_revs
