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

Brodie Rao brodie at bitheap.org
Sun Aug 29 20:46:54 CDT 2010


On Aug 29, 2010, at 5:20 PM, Martin Geisler wrote:

> 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.

There's another problem with the test that I just noticed: After doing  
KILLQUIETLY=Y hgserve ..., KILLQUIETLY is still set to Y, since it's  
just a function invocation and not a command invocation.

Should it set it to N after running that? Or is there a better way to  
do what I'm trying to do there?

> -- 
> Martin Geisler
>
> Mercurial links: http://mercurial.ch/



More information about the Mercurial-devel mailing list