[PATCH] mail/hgweb: support service names for ports (issue2350)

Martin Geisler mg at lazybytes.net
Sun Aug 29 16:20:12 CDT 2010


Brodie Rao <brodie at bitheap.org> writes:

> # HG changeset patch
> # User Brodie Rao <brodie at bitheap.org>
> # Date 1283013067 14400
> # Node ID f01d5dd19c9bb6ee88c32090afe727038ed3eff5
> # Parent  a8b1cb0b0ddb63d32294d4e0edb464c7006275c7
> mail/hgweb: support service names for ports (issue2350)

Thanks! I pushed to crew (49463314c24f) with some minor changes:

> +def getport(port):
> +    """Return the port for a given network service.
> +
> +    If port is an integer, it's returned as is. If it's a string, it's
> +    looked up using socket.getservbyname(). If there's no matching
> +    service, util.Abort is raised.
> +    """
> +    try:
> +        return int(port)
> +    except ValueError:
> +        pass
> +
> +    try:
> +        return socket.getservbyname(port)
> +    except socket.error:
> +        raise Abort(_("no port number associated with service '%s'" % port))

The format string should be translated by itself, so I changed it to:

> +        raise Abort(_("no port number associated with service '%s'") % port)


> +echo % With -v and -p http (should fail)
> +KILLQUIETLY=Y hgserve -p http

bash gave me a syntax error because of the parenthesis, so I quoted the
whole string.

-- 
Martin Geisler

Mercurial links: http://mercurial.ch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100829/201206b0/attachment.pgp>


More information about the Mercurial-devel mailing list