[PATCH] Fix deprecation warning in zeroconf with huge port number

Augie Fackler durin42 at gmail.com
Fri Oct 10 14:42:27 CDT 2008


When a really large port number is specified, hg serve will just do a  
bitwise and with 65535 and use that (as best I've ever been able to  
tell). This causes the Zeroconf plugin to behave the same way. It may  
not be the correct place to make such a change though, this was just  
my best guess.

# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1223667646 18000
# Node ID 6b904ea34356740bfd3a0b72251e5cdee5c6c252
# Parent  4e2f40823c143148052025ee4a6aac471a709dab
Fix a deprecation warning if the user specifies a port over 65535.

diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -664,7 +664,7 @@
  	def writeShort(self, value):
  		"""Writes an unsigned short to the packet"""
  		format = '!H'
-		self.data.append(struct.pack(format, value))
+		self.data.append(struct.pack(format, value & 65535))
  		self.size += 2

  	def writeInt(self, value):

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2417 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20081010/18a12431/attachment.bin 


More information about the Mercurial-devel mailing list