cleanup: whitespace cleanup
authorPeter Arrenbrecht <peter.arrenbrecht@gmail.com>
Mon, 23 Mar 2009 13:13:27 +0100
changeset 7877 eba7f12b0c51
parent 7876 53c72ba36c2b
child 7878 8c09952cd39a
cleanup: whitespace cleanup
hgext/convert/convcmd.py
hgext/convert/hg.py
hgext/rebase.py
hgext/win32mbcs.py
hgext/zeroconf/Zeroconf.py
--- a/hgext/convert/convcmd.py	Mon Mar 23 13:13:11 2009 +0100
+++ b/hgext/convert/convcmd.py	Mon Mar 23 13:13:27 2009 +0100
@@ -188,11 +188,11 @@
     def writeauthormap(self):
         authorfile = self.authorfile
         if authorfile:
-           self.ui.status(_('Writing author map file %s\n') % authorfile)
-           ofile = open(authorfile, 'w+')
-           for author in self.authors:
-               ofile.write("%s=%s\n" % (author, self.authors[author]))
-           ofile.close()
+            self.ui.status(_('Writing author map file %s\n') % authorfile)
+            ofile = open(authorfile, 'w+')
+            for author in self.authors:
+                ofile.write("%s=%s\n" % (author, self.authors[author]))
+            ofile.close()
 
     def readauthormap(self, authorfile):
         afile = open(authorfile, 'r')
--- a/hgext/convert/hg.py	Mon Mar 23 13:13:11 2009 +0100
+++ b/hgext/convert/hg.py	Mon Mar 23 13:13:27 2009 +0100
@@ -155,35 +155,33 @@
         return p2
 
     def puttags(self, tags):
-         try:
-             parentctx = self.repo[self.tagsbranch]
-             tagparent = parentctx.node()
-         except error.RepoError:
-             parentctx = None
-             tagparent = nullid
+        try:
+            parentctx = self.repo[self.tagsbranch]
+            tagparent = parentctx.node()
+        except error.RepoError:
+            parentctx = None
+            tagparent = nullid
 
-         try:
-             oldlines = util.sort(parentctx['.hgtags'].data().splitlines(1))
-         except:
-             oldlines = []
+        try:
+            oldlines = util.sort(parentctx['.hgtags'].data().splitlines(1))
+        except:
+            oldlines = []
 
-         newlines = util.sort([("%s %s\n" % (tags[tag], tag)) for tag in tags])
-
-         if newlines == oldlines:
-             return None
-         data = "".join(newlines)
-
-         def getfilectx(repo, memctx, f):
+        newlines = util.sort([("%s %s\n" % (tags[tag], tag)) for tag in tags])
+        if newlines == oldlines:
+            return None
+        data = "".join(newlines)
+        def getfilectx(repo, memctx, f):
             return context.memfilectx(f, data, False, False, None)
 
-         self.ui.status(_("updating tags\n"))
-         date = "%s 0" % int(time.mktime(time.gmtime()))
-         extra = {'branch': self.tagsbranch}
-         ctx = context.memctx(self.repo, (tagparent, None), "update tags",
-                              [".hgtags"], getfilectx, "convert-repo", date,
-                              extra)
-         self.repo.commitctx(ctx)
-         return hex(self.repo.changelog.tip())
+        self.ui.status(_("updating tags\n"))
+        date = "%s 0" % int(time.mktime(time.gmtime()))
+        extra = {'branch': self.tagsbranch}
+        ctx = context.memctx(self.repo, (tagparent, None), "update tags",
+                             [".hgtags"], getfilectx, "convert-repo", date,
+                             extra)
+        self.repo.commitctx(ctx)
+        return hex(self.repo.changelog.tip())
 
     def setfilemapmode(self, active):
         self.filemapmode = active
--- a/hgext/rebase.py	Mon Mar 23 13:13:11 2009 +0100
+++ b/hgext/rebase.py	Mon Mar 23 13:13:27 2009 +0100
@@ -340,7 +340,7 @@
     targetancestors = util.set()
 
     if not dest:
-         # Destination defaults to the latest revision in the current branch
+        # Destination defaults to the latest revision in the current branch
         branch = repo[None].branch()
         dest = repo[branch].rev()
     else:
--- a/hgext/win32mbcs.py	Mon Mar 23 13:13:11 2009 +0100
+++ b/hgext/win32mbcs.py	Mon Mar 23 13:13:27 2009 +0100
@@ -46,54 +46,54 @@
 from mercurial import util
 
 def decode(arg):
-   if isinstance(arg, str):
-       uarg = arg.decode(util._encoding)
-       if arg == uarg.encode(util._encoding):
-           return uarg
-       raise UnicodeError("Not local encoding")
-   elif isinstance(arg, tuple):
-       return tuple(map(decode, arg))
-   elif isinstance(arg, list):
-       return map(decode, arg)
-   return arg
+    if isinstance(arg, str):
+        uarg = arg.decode(util._encoding)
+        if arg == uarg.encode(util._encoding):
+            return uarg
+        raise UnicodeError("Not local encoding")
+    elif isinstance(arg, tuple):
+        return tuple(map(decode, arg))
+    elif isinstance(arg, list):
+        return map(decode, arg)
+    return arg
 
 def encode(arg):
-   if isinstance(arg, unicode):
-       return arg.encode(util._encoding)
-   elif isinstance(arg, tuple):
-       return tuple(map(encode, arg))
-   elif isinstance(arg, list):
-       return map(encode, arg)
-   return arg
+    if isinstance(arg, unicode):
+        return arg.encode(util._encoding)
+    elif isinstance(arg, tuple):
+        return tuple(map(encode, arg))
+    elif isinstance(arg, list):
+        return map(encode, arg)
+    return arg
 
 def wrapper(func, args):
-   # check argument is unicode, then call original
-   for arg in args:
-       if isinstance(arg, unicode):
-           return func(*args)
+    # check argument is unicode, then call original
+    for arg in args:
+        if isinstance(arg, unicode):
+            return func(*args)
 
-   try:
-       # convert arguments to unicode, call func, then convert back
-       return encode(func(*decode(args)))
-   except UnicodeError:
-       # If not encoded with util._encoding, report it then
-       # continue with calling original function.
-      raise util.Abort(_("[win32mbcs] filename conversion fail with"
+    try:
+        # convert arguments to unicode, call func, then convert back
+        return encode(func(*decode(args)))
+    except UnicodeError:
+        # If not encoded with util._encoding, report it then
+        # continue with calling original function.
+        raise util.Abort(_("[win32mbcs] filename conversion fail with"
                          " %s encoding\n") % (util._encoding))
 
 def wrapname(name):
-   idx = name.rfind('.')
-   module = name[:idx]
-   name = name[idx+1:]
-   module = eval(module)
-   func = getattr(module, name)
-   def f(*args):
-       return wrapper(func, args)
-   try:
-      f.__name__ = func.__name__                # fail with python23
-   except Exception:
-      pass
-   setattr(module, name, f)
+    idx = name.rfind('.')
+    module = name[:idx]
+    name = name[idx+1:]
+    module = eval(module)
+    func = getattr(module, name)
+    def f(*args):
+        return wrapper(func, args)
+    try:
+        f.__name__ = func.__name__                # fail with python23
+    except Exception:
+        pass
+    setattr(module, name, f)
 
 # List of functions to be wrapped.
 # NOTE: os.path.dirname() and os.path.basename() are safe because
@@ -109,14 +109,14 @@
  shift_jisx0213 shiftjisx0213 sjisx0213 s_jisx0213'''
 
 def reposetup(ui, repo):
-   # TODO: decide use of config section for this extension
-   if not os.path.supports_unicode_filenames:
-       ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
-       return
+    # TODO: decide use of config section for this extension
+    if not os.path.supports_unicode_filenames:
+        ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
+        return
 
-   # fake is only for relevant environment.
-   if util._encoding.lower() in problematic_encodings.split():
-       for f in funcs.split():
-           wrapname(f)
-       ui.debug(_("[win32mbcs] activated with encoding: %s\n") % util._encoding)
+    # fake is only for relevant environment.
+    if util._encoding.lower() in problematic_encodings.split():
+        for f in funcs.split():
+            wrapname(f)
+        ui.debug(_("[win32mbcs] activated with encoding: %s\n") % util._encoding)
 
--- a/hgext/zeroconf/Zeroconf.py	Mon Mar 23 13:13:11 2009 +0100
+++ b/hgext/zeroconf/Zeroconf.py	Mon Mar 23 13:13:27 2009 +0100
@@ -19,7 +19,7 @@
     You should have received a copy of the GNU Lesser General Public
     License along with this library; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-	
+
 """
 
 """0.12 update - allow selection of binding interface
@@ -101,7 +101,7 @@
 _BROWSER_TIME = 500
 
 # Some DNS constants
-	
+
 _MDNS_ADDR = '224.0.0.251'
 _MDNS_PORT = 5353;
 _DNS_PORT = 53;
@@ -208,7 +208,7 @@
 
 class DNSEntry(object):
 	"""A DNS entry"""
-	
+
 	def __init__(self, name, type, clazz):
 		self.key = string.lower(name)
 		self.name = name
@@ -256,7 +256,7 @@
 
 class DNSQuestion(DNSEntry):
 	"""A DNS question entry"""
-	
+
 	def __init__(self, name, type, clazz):
 		if not name.endswith(".local."):
 			raise NonLocalNameException
@@ -273,7 +273,7 @@
 
 class DNSRecord(DNSEntry):
 	"""A DNS record - like a DNS entry, but has a TTL"""
-	
+
 	def __init__(self, name, type, clazz, ttl):
 		DNSEntry.__init__(self, name, type, clazz)
 		self.ttl = ttl
@@ -334,7 +334,7 @@
 
 class DNSAddress(DNSRecord):
 	"""A DNS address record"""
-	
+
 	def __init__(self, name, type, clazz, ttl, address):
 		DNSRecord.__init__(self, name, type, clazz, ttl)
 		self.address = address
@@ -378,10 +378,10 @@
 	def __repr__(self):
 		"""String representation"""
 		return self.cpu + " " + self.os
-	
+
 class DNSPointer(DNSRecord):
 	"""A DNS pointer record"""
-	
+
 	def __init__(self, name, type, clazz, ttl, alias):
 		DNSRecord.__init__(self, name, type, clazz, ttl)
 		self.alias = alias
@@ -402,7 +402,7 @@
 
 class DNSText(DNSRecord):
 	"""A DNS text record"""
-	
+
 	def __init__(self, name, type, clazz, ttl, text):
 		DNSRecord.__init__(self, name, type, clazz, ttl)
 		self.text = text
@@ -426,7 +426,7 @@
 
 class DNSService(DNSRecord):
 	"""A DNS service record"""
-	
+
 	def __init__(self, name, type, clazz, ttl, priority, weight, port, server):
 		DNSRecord.__init__(self, name, type, clazz, ttl)
 		self.priority = priority
@@ -453,7 +453,7 @@
 
 class DNSIncoming(object):
 	"""Object representation of an incoming DNS packet"""
-	
+
 	def __init__(self, data):
 		"""Constructor from string holding bytes of packet"""
 		self.offset = 0
@@ -464,7 +464,7 @@
 		self.numAnswers = 0
 		self.numAuthorities = 0
 		self.numAdditionals = 0
-		
+
 		self.readHeader()
 		self.readQuestions()
 		self.readOthers()
@@ -491,7 +491,7 @@
 			name = self.readName()
 			info = struct.unpack(format, self.data[self.offset:self.offset+length])
 			self.offset += length
-			
+
 			question = DNSQuestion(name, info[0], info[1])
 			self.questions.append(question)
 
@@ -561,7 +561,7 @@
 
 			if rec is not None:
 				self.answers.append(rec)
-				
+
 	def isQuery(self):
 		"""Returns true if this is a query"""
 		return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_QUERY
@@ -574,7 +574,7 @@
 		"""Reads a UTF-8 string of a given length from the packet"""
 		result = self.data[offset:offset+len].decode('utf-8')
 		return result
-		
+
 	def readName(self):
 		"""Reads a domain name from the packet"""
 		result = ''
@@ -607,11 +607,11 @@
 			self.offset = off
 
 		return result
-	
-		
+
+
 class DNSOutgoing(object):
 	"""Object representation of an outgoing packet"""
-	
+
 	def __init__(self, flags, multicast = 1):
 		self.finished = 0
 		self.id = 0
@@ -620,7 +620,7 @@
 		self.names = {}
 		self.data = []
 		self.size = 12
-		
+
 		self.questions = []
 		self.answers = []
 		self.authorities = []
@@ -660,7 +660,7 @@
 		format = '!H'
 		self.data.insert(index, struct.pack(format, value))
 		self.size += 2
-		
+
 	def writeShort(self, value):
 		"""Writes an unsigned short to the packet"""
 		format = '!H'
@@ -739,7 +739,7 @@
 		self.size += 2
 		record.write(self)
 		self.size -= 2
-		
+
 		length = len(''.join(self.data[index:]))
 		self.insertShort(index, length) # Here is the short we adjusted for
 
@@ -758,7 +758,7 @@
 				self.writeRecord(authority, 0)
 			for additional in self.additionals:
 				self.writeRecord(additional, 0)
-		
+
 			self.insertShort(0, len(self.additionals))
 			self.insertShort(0, len(self.authorities))
 			self.insertShort(0, len(self.answers))
@@ -773,7 +773,7 @@
 
 class DNSCache(object):
 	"""A cache of DNS entries"""
-	
+
 	def __init__(self):
 		self.cache = {}
 
@@ -870,7 +870,7 @@
 		result = self.readers.keys()
 		self.condition.release()
 		return result
-	
+
 	def addReader(self, reader, socket):
 		self.condition.acquire()
 		self.readers[socket] = reader
@@ -895,7 +895,7 @@
 
 	It requires registration with an Engine object in order to have
 	the read() method called when a socket is availble for reading."""
-	
+
 	def __init__(self, zeroconf):
 		self.zeroconf = zeroconf
 		self.zeroconf.engine.addReader(self, self.zeroconf.socket)
@@ -922,7 +922,7 @@
 class Reaper(threading.Thread):
 	"""A Reaper is used by this module to remove cache entries that
 	have expired."""
-	
+
 	def __init__(self, zeroconf):
 		threading.Thread.__init__(self)
 		self.zeroconf = zeroconf
@@ -946,7 +946,7 @@
 	The listener object will have its addService() and
 	removeService() methods called when this browser
 	discovers changes in the services availability."""
-	
+
 	def __init__(self, zeroconf, type, listener):
 		"""Creates a browser for a specific type"""
 		threading.Thread.__init__(self)
@@ -957,7 +957,7 @@
 		self.nextTime = currentTimeMillis()
 		self.delay = _BROWSER_TIME
 		self.list = []
-		
+
 		self.done = 0
 
 		self.zeroconf.addListener(self, DNSQuestion(self.type, _TYPE_PTR, _CLASS_IN))
@@ -1017,11 +1017,11 @@
 
 			if event is not None:
 				event(self.zeroconf)
-				
+
 
 class ServiceInfo(object):
 	"""Service information"""
-	
+
 	def __init__(self, type, name, address=None, port=None, weight=0, priority=0, properties=None, server=None):
 		"""Create a service description.
 
@@ -1087,7 +1087,7 @@
 				index += 1
 				strs.append(text[index:index+length])
 				index += length
-			
+
 			for s in strs:
 				eindex = s.find('=')
 				if eindex == -1:
@@ -1110,7 +1110,7 @@
 		except:
 			traceback.print_exc()
 			self.properties = None
-			
+
 	def getType(self):
 		"""Type accessor"""
 		return self.type
@@ -1200,7 +1200,7 @@
 			result = 1
 		finally:
 			zeroconf.removeListener(self)
-			
+
 		return result
 
 	def __eq__(self, other):
@@ -1225,7 +1225,7 @@
 				result += self.text[:17] + "..."
 		result += "]"
 		return result
-				
+
 
 class Zeroconf(object):
 	"""Implementation of Zeroconf Multicast DNS Service Discovery
@@ -1265,7 +1265,7 @@
 			# the SO_REUSE* options have been set, so ignore it
 			#
 			pass
-		#self.socket.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.intf) + socket.inet_aton('0.0.0.0')) 
+		#self.socket.setsockopt(socket.SOL_IP, socket.IP_MULTICAST_IF, socket.inet_aton(self.intf) + socket.inet_aton('0.0.0.0'))
 		self.socket.setsockopt(socket.SOL_IP, socket.IP_ADD_MEMBERSHIP, socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
 
 		self.listeners = []
@@ -1276,7 +1276,7 @@
 		self.cache = DNSCache()
 
 		self.condition = threading.Condition()
-		
+
 		self.engine = Engine(self)
 		self.listener = Listener(self)
 		self.reaper = Reaper(self)
@@ -1471,7 +1471,7 @@
 						record = entry
 			else:
 				self.cache.add(record)
-				
+
 			self.updateRecord(now, record)
 
 	def handleQuery(self, msg, addr, port):
@@ -1545,11 +1545,11 @@
 			self.unregisterAllServices()
 			self.socket.setsockopt(socket.SOL_IP, socket.IP_DROP_MEMBERSHIP, socket.inet_aton(_MDNS_ADDR) + socket.inet_aton('0.0.0.0'))
 			self.socket.close()
-			
+
 # Test a few module features, including service registration, service
 # query (for Zoe), and service unregistration.
 
-if __name__ == '__main__':	
+if __name__ == '__main__':
 	print "Multicast DNS Service Discovery for Python, version", __version__
 	r = Zeroconf()
 	print "1. Testing registration of a service..."