[PATCH 3 of 7] drop variables for unused return values

Peter Arrenbrecht peter.arrenbrecht at gmail.com
Thu Mar 12 02:06:13 CDT 2009


# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1236838868 -3600
drop variables for unused return values

They are unnecessary. I did leave them in localrepo.py where there is
something like:

  _junk = foo()
  _junk = None

to free memory early. I don't know if just `foo()` will free the return
value as early.

diff --git a/hgext/convert/cvs.py b/hgext/convert/cvs.py
--- a/hgext/convert/cvs.py
+++ b/hgext/convert/cvs.py
@@ -327,7 +327,7 @@
                 elif line.startswith("E "):
                     self.ui.warn(_("cvs server: %s\n") % line[2:])
                 elif line.startswith("Remove"):
-                    l = self.readp.readline()
+                    self.readp.readline()
                 else:
                     raise util.Abort(_("unknown CVS response: %s") % line)
 
diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -142,7 +142,7 @@
             p2 = parents.pop(0)
             ctx = context.memctx(self.repo, (p1, p2), text, files.keys(), getfilectx,
                                  commit.author, commit.date, extra)
-            a = self.repo.commitctx(ctx)
+            self.repo.commitctx(ctx)
             text = "(octopus merge fixup)\n"
             p2 = hex(self.repo.changelog.tip())
 
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -177,7 +177,7 @@
             if at >= 0:
                 latest = int(url[at+1:])
                 url = url[:at]
-        except ValueError, e:
+        except ValueError:
             pass
         self.url = geturl(url)
         self.encoding = 'UTF-8' # Subversion is always nominal UTF-8
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1742,7 +1742,7 @@
     else:
         patchespath = patchdir(sr)
     try:
-        pr = hg.repository(ui, patchespath)
+        hg.repository(ui, patchespath)
     except error.RepoError:
         raise util.Abort(_('versioned patch repository not found'
                            ' (see qinit -c)'))
@@ -1768,9 +1768,9 @@
                       update=False,
                       stream=opts['uncompressed'])
     ui.note(_('cloning patch repo\n'))
-    spr, dpr = hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr),
-                        pull=opts['pull'], update=not opts['noupdate'],
-                        stream=opts['uncompressed'])
+    hg.clone(ui, opts['patches'] or patchdir(sr), patchdir(dr),
+             pull=opts['pull'], update=not opts['noupdate'],
+             stream=opts['uncompressed'])
     if dr.local():
         if qbase:
             ui.note(_('stripping applied patches from destination repo\n'))
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -230,8 +230,8 @@
     def getpatches(revs):
         for r in cmdutil.revrange(repo, revs):
             output = cStringIO.StringIO()
-            p = patch.export(repo, [r], fp=output,
-                             opts=patch.diffopts(ui, opts))
+            patch.export(repo, [r], fp=output,
+                         opts=patch.diffopts(ui, opts))
             yield output.getvalue().split('\n')
 
     def getbundle(dest):
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -216,8 +216,8 @@
             try:
                 files = {}
                 try:
-                    fuzz = patch.patch(patchfile, self.ui, cwd=repo.root,
-                                       files=files)
+                    patch.patch(patchfile, self.ui, cwd=repo.root,
+                                files=files)
                     if not files:
                         self.ui.warn(_('%s: empty changeset')
                                      % revlog.hex(node))
diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -866,7 +866,6 @@
 					pass
 
 	def getReaders(self):
-		result = []
 		self.condition.acquire()
 		result = self.readers.keys()
 		self.condition.release()
@@ -1486,14 +1485,14 @@
 			out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA, 0)
 			for question in msg.questions:
 				out.addQuestion(question)
-		
+
 		for question in msg.questions:
 			if question.type == _TYPE_PTR:
 				if question.name == "_services._dns-sd._udp.local.":
 					for stype in self.servicetypes.keys():
 						if out is None:
 							out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
-						out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype))						
+						out.addAnswer(msg, DNSPointer("_services._dns-sd._udp.local.", _TYPE_PTR, _CLASS_IN, _DNS_TTL, stype))
 				for service in self.services.values():
 					if question.name == service.type:
 						if out is None:
@@ -1503,16 +1502,16 @@
 				try:
 					if out is None:
 						out = DNSOutgoing(_FLAGS_QR_RESPONSE | _FLAGS_AA)
-					
+
 					# Answer A record queries for any service addresses we know
 					if question.type == _TYPE_A or question.type == _TYPE_ANY:
 						for service in self.services.values():
 							if service.server == question.name.lower():
 								out.addAnswer(msg, DNSAddress(question.name, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
-					
+
 					service = self.services.get(question.name.lower(), None)
 					if not service: continue
-					
+
 					if question.type == _TYPE_SRV or question.type == _TYPE_ANY:
 						out.addAnswer(msg, DNSService(question.name, _TYPE_SRV, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.priority, service.weight, service.port, service.server))
 					if question.type == _TYPE_TXT or question.type == _TYPE_ANY:
@@ -1521,7 +1520,7 @@
 						out.addAdditionalAnswer(DNSAddress(service.server, _TYPE_A, _CLASS_IN | _CLASS_UNIQUE, _DNS_TTL, service.address))
 				except:
 					traceback.print_exc()
-				
+
 		if out is not None and out.answers:
 			out.id = msg.id
 			self.send(out, addr, port)
@@ -1531,7 +1530,7 @@
 		# This is a quick test to see if we can parse the packets we generate
 		#temp = DNSIncoming(out.packet())
 		try:
-			bytes_sent = self.socket.sendto(out.packet(), 0, (addr, port))
+			self.socket.sendto(out.packet(), 0, (addr, port))
 		except:
 			# Ignore this, it may be a temporary loss of network connection
 			pass
diff --git a/hgext/zeroconf/__init__.py b/hgext/zeroconf/__init__.py
--- a/hgext/zeroconf/__init__.py
+++ b/hgext/zeroconf/__init__.py
@@ -130,7 +130,7 @@
 def getzcpaths():
     server = Zeroconf.Zeroconf()
     l = listener()
-    browser = Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
+    Zeroconf.ServiceBrowser(server, "_hg._tcp.local.", l)
     time.sleep(1)
     server.close()
     for v in l.found.values():
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -897,7 +897,7 @@
     ui.status(_("Checking templates...\n"))
     try:
         import templater
-        t = templater.templater(templater.templatepath("map-cmdline.default"))
+        templater.templater(templater.templatepath("map-cmdline.default"))
     except Exception, inst:
         ui.write(" %s\n" % inst)
         ui.write(_(" (templates seem to have been installed incorrectly)\n"))
@@ -1693,8 +1693,8 @@
 
                 files = {}
                 try:
-                    fuzz = patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
-                                       files=files)
+                    patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
+                                files=files)
                 finally:
                     files = patch.updatedir(ui, repo, files, similarity=sim/100.)
                 if not opts.get('no_commit'):
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -233,7 +233,7 @@
 
     def __nonzero__(self):
         try:
-            n = self._filenode
+            self._filenode
             return True
         except error.LookupError:
             # file is missing
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -494,7 +494,7 @@
         HANDLE_ERRORS = i
         try:
             fo = urllib2.urlopen(url)
-            foo = fo.read()
+            fo.read()
             fo.close()
             try: status, reason = fo.status, fo.reason
             except AttributeError: status, reason = None, None
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -835,7 +835,7 @@
             # odds of a binary node being all hex in ASCII are 1 in 10**25
             try:
                 node = id
-                r = self.rev(node) # quick search the index
+                self.rev(node) # quick search the index
                 return node
             except LookupError:
                 pass # may be partial hex id
@@ -855,7 +855,7 @@
             try:
                 # a full hex nodeid?
                 node = bin(id)
-                r = self.rev(node)
+                self.rev(node)
                 return node
             except (TypeError, LookupError):
                 pass
diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -219,7 +219,7 @@
                         warn(_("warning: %s@%s: copy source revision is nullid %s:%s")
                             % (f, lr, rp[0], short(rp[1])))
                     else:
-                        rev = fl2.rev(rp[1])
+                        fl2.rev(rp[1])
             except Exception, inst:
                 exc(lr, _("checking rename of %s") % short(n), inst, f)
 


More information about the Mercurial-devel mailing list