[PATCH 2 of 7] rename unused destructuring variables to start with underbar (_)

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


# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1236838570 -3600
rename unused destructuring variables to start with underbar (_)

This is so the PyDev Eclipse plugin no longer reports them as unused.
Doing this is beneficial as I also found a number of variables that
could be dropped entirely (see later patch).

I don't expect people to keep this up. I can do it again later. But
it does help to weed out false positives.

It would be helpful, though, if once people start using one of these
varialbles, that they remove the leading underbar.

diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -181,7 +181,7 @@
         '''tell bugzilla to send mail.'''
 
         self.ui.status(_('telling bugzilla to send mail:\n'))
-        (user, userid) = self.get_bugzilla_user(committer)
+        (user, _userid) = self.get_bugzilla_user(committer)
         for id in ids:
             self.ui.status(_('  bug %s\n') % id)
             cmdfmt = self.ui.config('bugzilla', 'notify', self.default_notify)
@@ -251,7 +251,7 @@
     def add_comment(self, bugid, text, committer):
         '''add comment to bug. try adding comment as committer of
         changeset, otherwise as default bugzilla user.'''
-        (user, userid) = self.get_bugzilla_user(committer)
+        (_user, userid) = self.get_bugzilla_user(committer)
         now = time.strftime('%Y-%m-%d %H:%M:%S')
         self.run('''insert into longdescs
                     (bug_id, who, bug_when, thetext)
diff --git a/hgext/churn.py b/hgext/churn.py
--- a/hgext/churn.py
+++ b/hgext/churn.py
@@ -52,8 +52,8 @@
         df = util.matchdate(opts['date'])
 
     get = util.cachefunc(lambda r: repo[r].changeset())
-    changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
-    for st, rev, fns in changeiter:
+    changeiter, _matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
+    for st, rev, _fns in changeiter:
         if not st == 'add':
             continue
         if df and not df(get(rev)[2][0]): # doesn't match date format
@@ -133,7 +133,7 @@
     sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None)
     rate.sort(sortfn)
 
-    maxcount = float(max([v for k, v in rate]))
+    maxcount = float(max([v for _k, v in rate]))
     maxname = max([len(k) for k, v in rate])
 
     ttywidth = util.termwidth()
diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py
--- a/hgext/convert/bzr.py
+++ b/hgext/convert/bzr.py
@@ -136,7 +136,7 @@
         revid = current._revision_id;
         changes = []
         renames = {}
-        for (fileid, paths, changed_content, versioned, parent, name,
+        for (_fileid, paths, _changed_content, _versioned, _parent, name,
             kind, executable) in current.iter_changes(origin):
 
             if paths[0] == u'' or paths[1] == u'':
diff --git a/hgext/convert/darcs.py b/hgext/convert/darcs.py
--- a/hgext/convert/darcs.py
+++ b/hgext/convert/darcs.py
@@ -45,7 +45,7 @@
     def before(self):
         self.tmppath = tempfile.mkdtemp(
             prefix='convert-' + os.path.basename(self.path) + '-')
-        output, status = self.run('init', repodir=self.tmppath)
+        _output, status = self.run('init', repodir=self.tmppath)
         self.checkexit(status)
 
         tree = self.xml('changes', xml_output=True, summary=True,
diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py
--- a/hgext/convert/filemap.py
+++ b/hgext/convert/filemap.py
@@ -84,7 +84,7 @@
             exc = ''
         if not inc or exc:
             return None
-        newpre, pre, suf = self.lookup(name, self.rename)
+        newpre, _pre, suf = self.lookup(name, self.rename)
         if newpre:
             if newpre == '.':
                 return suf
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -134,7 +134,7 @@
             for l in fh:
                 if "\t" not in l:
                     continue
-                m, f = l[:-1].split("\t")
+                _m, f = l[:-1].split("\t")
                 changes.append(f)
             fh.close()
         else:
diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -164,7 +164,7 @@
     def getmode(self, name, rev):
         self.mtnloadmanifest(rev)
         try:
-            node, attr = self.files[name]
+            _node, attr = self.files[name]
             return attr
         except KeyError:
             return ""
diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py
--- a/hgext/convert/subversion.py
+++ b/hgext/convert/subversion.py
@@ -91,7 +91,7 @@
                        discover_changed_paths,
                        strict_node_history,
                        receiver)
-    except SubversionException, (inst, num):
+    except SubversionException, (_inst, num):
         pickle.dump(num, fp, protocol)
     except IOError:
         # Caller may interrupt the iteration
@@ -122,7 +122,7 @@
         while True:
             entry = pickle.load(self._stdout)
             try:
-                orig_paths, revnum, author, date, message = entry
+                _orig_paths, _revnum, _author, _date, _message = entry
             except:
                 if entry is None:
                     break
@@ -235,7 +235,7 @@
     def setrevmap(self, revmap):
         lastrevs = {}
         for revid in revmap.iterkeys():
-            uuid, module, revnum = self.revsplit(revid)
+            _uuid, module, revnum = self.revsplit(revid)
             lastrevnum = lastrevs.setdefault(module, revnum)
             if revnum > lastrevnum:
                 lastrevs[module] = revnum
@@ -336,7 +336,7 @@
             files, copies = self.expandpaths(rev, paths, parents)
         else:
             # Perform a full checkout on roots
-            uuid, module, revnum = self.revsplit(rev)
+            _uuid, module, revnum = self.revsplit(rev)
             entries = svn.client.ls(self.baseurl + urllib.quote(module),
                                     optrev(revnum), True, self.ctx)
             files = [n for n,e in entries.iteritems()
@@ -357,7 +357,7 @@
 
     def getcommit(self, rev):
         if rev not in self.commits:
-            uuid, module, revnum = self.revsplit(rev)
+            _uuid, module, revnum = self.revsplit(rev)
             self.module = module
             self.reparent(module)
             # We assume that:
@@ -396,7 +396,7 @@
         start = svn.ra.get_latest_revnum(self.ra)
         try:
             for entry in self._getlog([self.tags], start, self.startrev):
-                origpaths, revnum, author, date, message = entry
+                origpaths, _revnum, _author, _date, _message = entry
                 copies = [(e.copyfrom_path, e.copyfrom_rev, p) for p, e
                           in origpaths.iteritems() if e.copyfrom_path]
                 copies.sort()
@@ -500,7 +500,7 @@
         stream = self._getlog([path], stop, dirent.created_rev)
         try:
             for entry in stream:
-                paths, revnum, author, date, message = entry
+                paths, revnum, _author, _date, _message = entry
                 if revnum <= dirent.created_rev:
                     break
 
@@ -589,7 +589,7 @@
                 # changeset, get the right fromrev
                 # parents cannot be empty here, you cannot remove things from
                 # a root revision.
-                uuid, old_module, fromrev = self.revsplit(parents[0])
+                _uuid, old_module, fromrev = self.revsplit(parents[0])
 
                 basepath = old_module + "/" + self.getrelpath(path)
                 entrypath = basepath
@@ -837,7 +837,7 @@
                             firstcset.parents.append(latest)
                 except SvnPathNotFound:
                     pass
-        except SubversionException, (inst, num):
+        except SubversionException, (_inst, num):
             if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION:
                 raise util.Abort(_('svn: branch has no revision %s') % to_revnum)
             raise
diff --git a/hgext/convert/transport.py b/hgext/convert/transport.py
--- a/hgext/convert/transport.py
+++ b/hgext/convert/transport.py
@@ -77,7 +77,7 @@
                 self.ra = svn.client.open_ra_session(
                     self.svn_url.encode('utf8'),
                     self.client, self.pool)
-            except SubversionException, (inst, num):
+            except SubversionException, (_inst, num):
                 if num in (svn.core.SVN_ERR_RA_ILLEGAL_URL,
                            svn.core.SVN_ERR_RA_LOCAL_REPOS_OPEN_FAILED,
                            svn.core.SVN_ERR_BAD_URL):
diff --git a/hgext/gpg.py b/hgext/gpg.py
--- a/hgext/gpg.py
+++ b/hgext/gpg.py
@@ -141,7 +141,7 @@
     revs = {}
 
     for data, context in sigwalk(repo):
-        node, version, sig = data
+        node, _version, _sig = data
         fn, ln = context
         try:
             n = repo.lookup(node)
@@ -169,7 +169,7 @@
     keys = []
 
     for data, context in sigwalk(repo):
-        node, version, sig = data
+        node, _version, _sig = data
         if node == hexrev:
             k = getkeys(ui, repo, mygpg, data, context)
             if k:
@@ -186,7 +186,7 @@
 
 def keystr(ui, key):
     """associate a string to a key (username, comment)"""
-    keyid, user, fingerprint = key
+    _keyid, user, fingerprint = key
     comment = ui.config("gpg", fingerprint, None)
     if comment:
         return "%s (%s)" % (user, comment)
diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -318,7 +318,7 @@
     """
 
     check_unsupported_flags(opts)
-    dest, revs, checkout = hg.parseurl(
+    dest, revs, _checkout = hg.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'),
         opts.get('rev'))
     cmdutil.setremoteconfig(ui, opts)
@@ -347,7 +347,7 @@
     """
 
     check_unsupported_flags(opts)
-    source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
+    source, revs, _checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
     cmdutil.setremoteconfig(ui, opts)
 
     other = hg.repository(ui, source)
diff --git a/hgext/inotify/linux/watcher.py b/hgext/inotify/linux/watcher.py
--- a/hgext/inotify/linux/watcher.py
+++ b/hgext/inotify/linux/watcher.py
@@ -243,7 +243,7 @@
         except OSError, err:
             if onerror and err.errno not in self.ignored_errors:
                 onerror(err)
-        for root, dirs, names in os.walk(path, topdown=False, onerror=onerror):
+        for root, dirs, _names in os.walk(path, topdown=False, onerror=onerror):
             for d in dirs:
                 try:
                     yield self.add(root + '/' + d, submask)
diff --git a/hgext/inotify/server.py b/hgext/inotify/server.py
--- a/hgext/inotify/server.py
+++ b/hgext/inotify/server.py
@@ -51,7 +51,7 @@
             if err.errno not in walk_ignored_errors:
                 raise
         yield rootslash + dirname, hginside
-    for dirname, hginside in walkit('', True):
+    for dirname, _hginside in walkit('', True):
         yield dirname
 
 def walk(repo, root):
@@ -309,7 +309,7 @@
         # Files that had been deleted but were present in the dirstate
         # may have vanished from the dirstate; we must clean them up.
         nuke = []
-        for wfn, ignore in self.walk(key, self.statustrees[key]):
+        for wfn, _ignore in self.walk(key, self.statustrees[key]):
             if wfn not in self.repo.dirstate:
                 nuke.append(wfn)
         for wfn in nuke:
@@ -326,7 +326,7 @@
                 self.add_watch(join(root, d), self.mask)
             wroot = root[len(self.wprefix):]
             d = self.dir(self.tree, wroot)
-            for fn, kind in entries:
+            for fn, _kind in entries:
                 wfn = join(wroot, fn)
                 self.updatestatus(wfn, self.getstat(wfn))
                 ds.pop(wfn, None)
@@ -587,7 +587,7 @@
         pass
 
     def handle_event(self, fd, event):
-        sock, addr = self.sock.accept()
+        sock, _addr = self.sock.accept()
 
         cs = common.recvcs(sock)
         version = ord(cs.read(1))
@@ -613,7 +613,7 @@
 
         if not names:
             def genresult(states, tree):
-                for fn, state in self.watcher.walk(states, tree):
+                for fn, _state in self.watcher.walk(states, tree):
                     yield fn
         else:
             def genresult(states, tree):
@@ -623,7 +623,7 @@
                         if l in states:
                             yield fn
                     except TypeError:
-                        for f, s in self.watcher.walk(states, l, fn):
+                        for f, _s in self.watcher.walk(states, l, fn):
                             yield f
 
         results = ['\0'.join(r) for r in [
diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -342,7 +342,7 @@
     ui.quiet = not ui.verbose
     commands.branch(ui, repo, branchname)
     ui.quiet = quiet
-    for name, cmd in ui.configitems('hooks'):
+    for name, _cmd in ui.configitems('hooks'):
         if name.split('.', 1)[0].find('commit') > -1:
             repo.ui.setconfig('hooks', name, '')
     ui.note(_('unhooked all commit hooks\n'))
@@ -373,7 +373,7 @@
     '''
     kwt = kwtools['templater']
     status = _status(ui, repo, kwt, opts.get('untracked'), *pats, **opts)
-    modified, added, removed, deleted, unknown, ignored, clean = status
+    modified, added, _removed, _deleted, unknown, _ignored, clean = status
     files = util.sort(modified + added + clean + unknown)
     wctx = repo[None]
     kwfiles = [f for f in files if kwt.iskwfile(f, wctx.flags)]
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -464,7 +464,7 @@
             if not patch:
                 self.ui.warn(_("patch %s does not exist\n") % patch)
                 return (1, None)
-            pushable, reason = self.pushable(patch)
+            pushable, _reason = self.pushable(patch)
             if not pushable:
                 self.explain_pushable(patch, all_patches=True)
                 continue
@@ -529,7 +529,7 @@
         err = 0
         n = None
         for patchname in series:
-            pushable, reason = self.pushable(patchname)
+            pushable, _reason = self.pushable(patchname)
             if not pushable:
                 self.explain_pushable(patchname, all_patches=True)
                 continue
@@ -572,7 +572,7 @@
                     repo.dirstate.remove(f)
                 for f in merged:
                     repo.dirstate.merge(f)
-                p1, p2 = repo.dirstate.parents()
+                p1, _p2 = repo.dirstate.parents()
                 repo.dirstate.setparents(p1, merge)
 
             files = patch.updatedir(self.ui, repo, files)
@@ -722,9 +722,9 @@
             def badfn(f, msg):
                 raise util.Abort('%s: %s' % (f, msg))
             match.bad = badfn
-            m, a, r, d = repo.status(match=match)[:4]
+            m, a, r, _d = repo.status(match=match)[:4]
         else:
-            m, a, r, d = self.check_localchanges(repo, force)
+            m, a, r, _d = self.check_localchanges(repo, force)
             match = cmdutil.matchfiles(repo, m + a + r)
         commitfiles = m + a + r
         self.check_toppatch(repo)
@@ -1144,7 +1144,7 @@
                 # but we do it backwards to take advantage of manifest/chlog
                 # caching against the next repo.status call
                 #
-                mm, aa, dd, aa2 = repo.status(patchparent, tip)[:4]
+                mm, aa, dd, _aa2 = repo.status(patchparent, tip)[:4]
                 changes = repo.changelog.read(tip)
                 man = repo.manifest.read(changes[0])
                 aaa = aa[:]
@@ -1318,7 +1318,7 @@
             start = self.series.index(patch) + 1
         unapplied = []
         for i in xrange(start, len(self.series)):
-            pushable, reason = self.pushable(i)
+            pushable, _reason = self.pushable(i)
             if pushable:
                 unapplied.append((i, self.series[i]))
             self.explain_pushable(i)
@@ -1355,7 +1355,7 @@
                 self.ui.write('%s%s\n' % (pfx, displayname(patch)))
         else:
             msng_list = []
-            for root, dirs, files in os.walk(self.path):
+            for root, _dirs, files in os.walk(self.path):
                 d = root[len(self.path) + 1:]
                 for f in files:
                     fl = os.path.join(d, f)
@@ -1480,7 +1480,7 @@
                 return start
             i = start
             while i < len(self.series):
-                p, reason = self.pushable(i)
+                p, _reason = self.pushable(i)
                 if p:
                     break
                 self.explain_pushable(i)
@@ -1951,7 +1951,7 @@
             if ph.message:
                 messages.append(ph.message)
         pf = q.join(p)
-        (patchsuccess, files, fuzz) = q.patch(repo, pf)
+        (patchsuccess, files, _fuzz) = q.patch(repo, pf)
         if not patchsuccess:
             raise util.Abort(_('Error folding patch %s') % p)
         patch.updatedir(ui, repo, files)
@@ -2078,7 +2078,7 @@
         if opts['name']:
             newpath = repo.join(opts['name'])
         else:
-            newpath, i = lastsavename(q.path)
+            newpath, _i = lastsavename(q.path)
         if not newpath:
             ui.warn(_("no saved queues found, please use -n\n"))
             return 1
@@ -2316,7 +2316,7 @@
     popped = False
     if opts['pop'] or opts['reapply']:
         for i in xrange(len(q.applied)):
-            pushable, reason = q.pushable(i)
+            pushable, _reason = q.pushable(i)
             if not pushable:
                 ui.status(_('popping guarded patches\n'))
                 popped = True
diff --git a/hgext/parentrevspec.py b/hgext/parentrevspec.py
--- a/hgext/parentrevspec.py
+++ b/hgext/parentrevspec.py
@@ -86,7 +86,7 @@
                     if j == i + 1:
                         raise
                     n = int(suffix[i+1:j])
-                    for k in xrange(n):
+                    for _k in xrange(n):
                         rev = cl.parentrevs(rev)[0]
                     i = j
                 else:
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -113,7 +113,7 @@
         ui.note(_('rebase merging completed\n'))
 
         if collapsef:
-            p1, p2 = defineparents(repo, min(state), target,
+            p1, _p2 = defineparents(repo, min(state), target,
                                                         state, targetancestors)
             concludenode(repo, rev, p1, external, state, collapsef,
                          last=True, skipped=skipped, extrafn=extrafn)
diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -90,7 +90,7 @@
     def apply(self, repo, source, revmap, merges, opts={}):
         '''apply the revisions in revmap one by one in revision order'''
         revs = util.sort(revmap)
-        p1, p2 = repo.dirstate.parents()
+        p1, _p2 = repo.dirstate.parents()
         pulls = []
         diffopts = patch.diffopts(self.ui, opts)
         diffopts.git = True
@@ -120,7 +120,7 @@
                         if source != repo:
                             repo.pull(source, heads=pulls)
                         merge.update(repo, pulls[-1], False, False, None)
-                        p1, p2 = repo.dirstate.parents()
+                        p1, _p2 = repo.dirstate.parents()
                         pulls = []
 
                 domerge = False
@@ -198,7 +198,7 @@
     def applyone(self, repo, node, cl, patchfile, merge=False, log=False,
                  filter=None):
         '''apply the patch in patchfile to the repository as a transplant'''
-        (manifest, user, (time, timezone), files, message) = cl[:5]
+        (_manifest, user, (time, timezone), files, message) = cl[:5]
         date = "%d %d" % (time, timezone)
         extra = {'transplant_source': node}
         if filter:
@@ -277,7 +277,7 @@
         extra = {'transplant_source': node}
         wlock = repo.wlock()
         try:
-            p1, p2 = repo.dirstate.parents()
+            p1, _p2 = repo.dirstate.parents()
             if p1 != parents[0]:
                 raise util.Abort(
                     _('working dir not at transplant parent %s') %
@@ -465,7 +465,7 @@
     def getremotechanges(repo, url):
         sourcerepo = ui.expandpath(url)
         source = hg.repository(ui, sourcerepo)
-        common, incoming, rheads = repo.findcommonincoming(source, force=True)
+        _common, incoming, rheads = repo.findcommonincoming(source, force=True)
         if not incoming:
             return (source, None, None)
 
diff --git a/hgext/zeroconf/Zeroconf.py b/hgext/zeroconf/Zeroconf.py
--- a/hgext/zeroconf/Zeroconf.py
+++ b/hgext/zeroconf/Zeroconf.py
@@ -487,7 +487,7 @@
 		"""Reads questions section of packet"""
 		format = '!HH'
 		length = struct.calcsize(format)
-		for i in range(0, self.numQuestions):
+		for _i in range(0, self.numQuestions):
 			name = self.readName()
 			info = struct.unpack(format, self.data[self.offset:self.offset+length])
 			self.offset += length
@@ -530,7 +530,7 @@
 		format = '!HHiH'
 		length = struct.calcsize(format)
 		n = self.numAnswers + self.numAuthorities + self.numAdditionals
-		for i in range(0, n):
+		for _i in range(0, n):
 			domain = self.readName()
 			info = struct.unpack(format, self.data[self.offset:self.offset+length])
 			self.offset += length
@@ -856,7 +856,7 @@
 				self.condition.release()
 			else:
 				try:
-					rr, wr, er = select.select(rs, [], [], self.timeout)
+					rr, _wr, _er = select.select(rs, [], [], self.timeout)
 					for socket in rr:
 						try:
 							self.readers[socket].handle_read()
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -239,7 +239,7 @@
                 if not chunk:
                     break
                 self.bundlefilespos[chunk] = self.bundlefile.tell()
-                for c in changegroup.chunkiter(self.bundlefile):
+                for _c in changegroup.chunkiter(self.bundlefile):
                     pass
 
         if f[0] == '/':
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -255,7 +255,7 @@
             equal = 0
             alines = mdiff.splitnewlines(aa)
             matches = bdiff.blocks(aa, rr)
-            for x1,x2,y1,y2 in matches:
+            for x1,x2,_y1,_y2 in matches:
                 for line in alines[x1:x2]:
                     equal += len(line)
 
@@ -924,9 +924,9 @@
     """Find the tipmost changeset that matches the given date spec"""
     df = util.matchdate(date)
     get = util.cachefunc(lambda r: repo[r].changeset())
-    changeiter, matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
+    changeiter, _matchfn = walkchangerevs(ui, repo, [], get, {'rev':None})
     results = {}
-    for st, rev, fns in changeiter:
+    for st, rev, _fns in changeiter:
         if st == 'add':
             d = get(rev)[2]
             if df(d[0]):
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -205,7 +205,7 @@
     cmdutil.bail_if_changed(repo)
     node = repo.lookup(rev)
 
-    op1, op2 = repo.dirstate.parents()
+    op1, _op2 = repo.dirstate.parents()
     a = repo.changelog.ancestor(op1, node)
     if a != node:
         raise util.Abort(_('cannot back out change on a different branch'))
@@ -507,7 +507,7 @@
                         visit.append(p)
     else:
         cmdutil.setremoteconfig(ui, opts)
-        dest, revs, checkout = hg.parseurl(
+        dest, revs, _checkout = hg.parseurl(
             ui.expandpath(dest or 'default-push', dest or 'default'), revs)
         other = hg.repository(ui, dest)
         o = repo.findoutgoing(other, force=opts.get('force'))
@@ -693,7 +693,7 @@
         options = []
         otables = [globalopts]
         if cmd:
-            aliases, entry = cmdutil.findcmd(cmd, table, False)
+            _aliases, entry = cmdutil.findcmd(cmd, table, False)
             otables.append(entry[1])
         for t in otables:
             for o in t:
@@ -1206,7 +1206,7 @@
     fstate = {}
     skip = {}
     get = util.cachefunc(lambda r: repo[r].changeset())
-    changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
+    changeiter, _matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts)
     found = False
     follow = opts.get('follow')
     for st, rev, fns in changeiter:
@@ -1500,7 +1500,7 @@
     if not name:
         ui.write(_("\nadditional help topics:\n\n"))
         topics = []
-        for names, header, doc in help.helptable:
+        for names, header, _doc in help.helptable:
             names = [(-len(name), name) for name in names]
             names.sort()
             topics.append((names[0][1], header))
@@ -1540,7 +1540,7 @@
 
     revs = []
     if source:
-        source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
+        source, revs, _checkout = hg.parseurl(ui.expandpath(source), [])
         repo = hg.repository(ui, source)
 
     if not repo.local():
@@ -1726,15 +1726,15 @@
     See pull for valid source format details.
     """
     limit = cmdutil.loglimit(opts)
-    source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
+    source, revs, _checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
     cmdutil.setremoteconfig(ui, opts)
 
     other = hg.repository(ui, source)
     ui.status(_('comparing with %s\n') % url.hidepassword(source))
     if revs:
         revs = [other.lookup(rev) for rev in revs]
-    common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
-                                                       force=opts["force"])
+    _common, incoming, rheads = repo.findcommonincoming(other, heads=revs,
+                                                        force=opts["force"])
     if not incoming:
         try:
             os.unlink(opts["bundle"])
@@ -1912,7 +1912,7 @@
     only_branches = opts.get('only_branch')
 
     displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
-    for st, rev, fns in changeiter:
+    for st, rev, _fns in changeiter:
         if st == 'add':
             parents = [p for p in repo.changelog.parentrevs(rev)
                        if p != nullrev]
@@ -2048,7 +2048,7 @@
     See pull for valid destination format details.
     """
     limit = cmdutil.loglimit(opts)
-    dest, revs, checkout = hg.parseurl(
+    dest, revs, _checkout = hg.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
     cmdutil.setremoteconfig(ui, opts)
     if revs:
@@ -2198,7 +2198,7 @@
     If DESTINATION is omitted, a default path will be used.
     See 'hg help urls' for more information.
     """
-    dest, revs, checkout = hg.parseurl(
+    dest, revs, _checkout = hg.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
     cmdutil.setremoteconfig(ui, opts)
 
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -419,7 +419,7 @@
             visit.extend(fn)
 
         hist = {}
-        for r, f in util.sort(visit):
+        for _r, f in util.sort(visit):
             curr = decorate(f.data(), f)
             for p in parents(f):
                 if p != nullid:
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -88,7 +88,7 @@
                 return 1
 
 def wrapcommand(table, command, wrapper):
-    aliases, entry = cmdutil.findcmd(command, table)
+    _aliases, entry = cmdutil.findcmd(command, table)
     for alias, e in table.iteritems():
         if e is entry:
             key = alias
diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py
--- a/mercurial/fancyopts.py
+++ b/mercurial/fancyopts.py
@@ -52,7 +52,7 @@
     argmap = {}
     defmap = {}
 
-    for short, name, default, comment in options:
+    for short, name, default, _comment in options:
         # convert opts to getopt format
         oname = name
         name = name.replace('-', '_')
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -61,7 +61,7 @@
 
     # then merge tools
     tools = {}
-    for k,v in ui.configitems("merge-tools"):
+    for k,_v in ui.configitems("merge-tools"):
         t = k.split('.')[0]
         if t not in tools:
             tools[t] = int(_toolstr(ui, t, "priority", "0"))
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -60,7 +60,7 @@
     """return a repository object for the specified path"""
     repo = _lookup(path).instance(ui, path, create)
     ui = getattr(repo, "ui", ui)
-    for name, module in extensions.extensions():
+    for _name, module in extensions.extensions():
         hook = getattr(module, 'reposetup', None)
         if hook:
             hook(ui, repo)
diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -256,7 +256,7 @@
                 rows.sort()
                 if descending:
                     rows.reverse()
-                for key, row in rows:
+                for _key, row in rows:
                     row['parity'] = parity.next()
                     yield row
 
diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py
+++ b/mercurial/hgweb/request.py
@@ -61,7 +61,7 @@
     def drain(self):
         '''need to read all data from request, httplib is half-duplex'''
         length = int(self.env.get('CONTENT_LENGTH', 0))
-        for s in util.filechunkiter(self.inp, limit=length):
+        for _s in util.filechunkiter(self.inp, limit=length):
             pass
 
     def respond(self, status, type=None, filename=None, length=0):
@@ -71,7 +71,7 @@
             if not self.headers:
                 raise RuntimeError("request.write called before headers sent")
 
-            for k, v in self.headers:
+            for _k, v in self.headers:
                 if not isinstance(v, str):
                     raise TypeError('header value must be string: %r' % v)
 
diff --git a/mercurial/hgweb/server.py b/mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py
+++ b/mercurial/hgweb/server.py
@@ -148,7 +148,7 @@
         self.sent_headers = True
 
     def _start_response(self, http_status, headers, exc_info=None):
-        code, msg = http_status.split(None, 1)
+        code, _msg = http_status.split(None, 1)
         code = int(code)
         self.saved_status = http_status
         bad_headers = ('connection', 'transfer-encoding')
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -273,7 +273,7 @@
     l = len(path)
     abspath = "/" + path
 
-    for f, n in mf.iteritems():
+    for f, _n in mf.iteritems():
         if f[:l] != path:
             continue
         remain = f[l:]
@@ -385,7 +385,7 @@
 
         b = web.repo.branchtags()
         l = [(-web.repo.changelog.rev(n), n, t) for t, n in b.iteritems()]
-        for r,n,t in util.sort(l):
+        for _r,n,t in util.sort(l):
             yield {'parity': parity.next(),
                    'branch': t,
                    'node': hex(n),
diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -25,7 +25,7 @@
         self.path = path
         self.caps = None
         self.handler = None
-        scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
+        _scheme, _netloc, _urlpath, query, frag = urlparse.urlsplit(path)
         if query or frag:
             raise util.Abort(_('unsupported URL component: "%s"') %
                              (query or frag))
diff --git a/mercurial/ignore.py b/mercurial/ignore.py
--- a/mercurial/ignore.py
+++ b/mercurial/ignore.py
@@ -79,12 +79,12 @@
         return util.never
 
     try:
-        files, ignorefunc, anypats = (
+        files, ignorefunc, _anypats = (
             util.matcher(root, inc=allpats, src='.hgignore'))
     except util.Abort:
         # Re-raise an exception where the src is the right file
         for f, patlist in pats.iteritems():
-            files, ignorefunc, anypats = (
+            files, ignorefunc, _anypats = (
                 util.matcher(root, inc=patlist, src=f))
 
     return ignorefunc
diff --git a/mercurial/keepalive.py b/mercurial/keepalive.py
--- a/mercurial/keepalive.py
+++ b/mercurial/keepalive.py
@@ -197,7 +197,7 @@
 
     def close_all(self):
         """close all open connections"""
-        for host, conns in self._cm.get_all().iteritems():
+        for _host, conns in self._cm.get_all().iteritems():
             for h in conns:
                 self._cm.remove(h)
                 h.close()
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -291,7 +291,7 @@
 
         # read the tags file from each head, ending with the tip
         f = None
-        for rev, node, fnode in self._hgtagsnodes():
+        for _rev, _node, fnode in self._hgtagsnodes():
             f = (f and f.filectx(fnode) or
                  self.filectx('.hgtags', fileid=fnode))
             readtags(f.data().splitlines(), f, "global")
@@ -385,7 +385,7 @@
         else:
             self.branchcache.clear() # keep using the same dict
         if oldtip is None or oldtip not in self.changelog.nodemap:
-            partial, last, lrev = self._readbranchcache()
+            partial, _last, lrev = self._readbranchcache()
         else:
             lrev = self.changelog.rev(oldtip)
             partial = self._ubranchcache
@@ -1208,7 +1208,7 @@
             return ('close' not in extras)
         # sort the output in rev descending order
         heads = [(-self.changelog.rev(h), h) for h in heads if display(h)]
-        return [n for (r, n) in util.sort(heads)]
+        return [n for (_r, n) in util.sort(heads)]
 
     def branchheads(self, branch=None, start=None, closed=True):
         if branch is None:
@@ -1471,7 +1471,7 @@
     def pull(self, remote, heads=None, force=False):
         lock = self.lock()
         try:
-            common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
+            _common, fetch, rheads = self.findcommonincoming(remote, heads=heads,
                                                             force=force)
             if fetch == [nullid]:
                 self.ui.status(_("requesting all changes\n"))
@@ -1511,9 +1511,9 @@
         remote_heads = remote.heads()
         inc = self.findincoming(remote, common, remote_heads, force=force)
 
-        update, updated_heads = self.findoutgoing(remote, common, remote_heads)
+        update, _updated_heads = self.findoutgoing(remote, common, remote_heads)
         if revs is not None:
-            msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
+            _msng_cl, bases, heads = self.changelog.nodesbetween(update, revs)
         else:
             bases, heads = update, self.changelog.heads()
 
@@ -1568,7 +1568,7 @@
         try:
             ret = self.prepush(remote, force, revs)
             if ret[0] is not None:
-                cg, remote_heads = ret
+                cg, _remote_heads = ret
                 return remote.addchangegroup(cg, 'push', self.url())
             return ret[1]
         finally:
@@ -1656,8 +1656,8 @@
             # changesets are known.  The recipient must know about all
             # changesets required to reach the known heads from the null
             # changeset.
-            has_cl_set, junk, junk = cl.nodesbetween(None, knownheads)
-            junk = None
+            has_cl_set, _junk, _junk = cl.nodesbetween(None, knownheads)
+            _junk = None
             # Transform the list into an ersatz set.
             has_cl_set = dict.fromkeys(has_cl_set)
         else:
@@ -1672,8 +1672,8 @@
         # Nor do we know which filenodes are missing.
         msng_filenode_set = {}
 
-        junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex
-        junk = None
+        _junk = mnfst.index[len(mnfst) - 1] # Get around a bug in lazyindex
+        _junk = None
 
         # A changeset always belongs to itself, so the changenode lookup
         # function for a changenode is identity.
@@ -2106,7 +2106,7 @@
         self.ui.status(_('%d files to transfer, %s of data\n') %
                        (total_files, util.bytecount(total_bytes)))
         start = time.time()
-        for i in xrange(total_files):
+        for _i in xrange(total_files):
             # XXX doesn't support '\n' or '\r' in filenames
             l = fp.readline()
             try:
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -248,7 +248,7 @@
     pos = 0
     t = []
     while pos < len(bin):
-        p1, p2, l = struct.unpack(">lll", bin[pos:pos + 12])
+        _p1, _p2, l = struct.unpack(">lll", bin[pos:pos + 12])
         pos += 12
         t.append(bin[pos:pos + l])
         pos += l
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -59,7 +59,7 @@
     def resolve(self, dfile, wctx, octx):
         if self[dfile] == 'r':
             return 0
-        state, hash, lfile, afile, anode, ofile, flags = self._state[dfile]
+        _state, hash, lfile, afile, anode, ofile, flags = self._state[dfile]
         f = self._repo.opener("merge/" + hash)
         self._repo.wwrite(dfile, f.read(), flags)
         fcd = wctx[dfile]
@@ -381,7 +381,7 @@
             else:
                 repo.dirstate.normal(f)
         elif m == "m": # merge
-            f2, fd, flag, move = a[2:]
+            f2, fd, _flag, move = a[2:]
             if branchmerge:
                 # We've done a branch merge, mark this file as merged
                 # so that we properly record the merger later
@@ -403,7 +403,7 @@
                 if move:
                     repo.dirstate.forget(f)
         elif m == "d": # directory rename
-            f2, fd, flag = a[2:]
+            f2, fd, _flag = a[2:]
             if not f2 and f not in repo.dirstate:
                 # untracked file moved
                 continue
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -187,7 +187,7 @@
             if m:
                 if gp:
                     gitpatches.append(gp)
-                src, dst = m.group(1, 2)
+                _src, dst = m.group(1, 2)
                 gp = patchmeta(dst)
                 gp.lineno = lineno
         elif gp:
@@ -450,7 +450,7 @@
         m = unidesc.match(self.desc)
         if not m:
             raise PatchError(_("bad hunk #%d") % self.number)
-        self.starta, foo, self.lena, self.startb, foo2, self.lenb = m.groups()
+        self.starta, _foo, self.lena, self.startb, _foo, self.lenb = m.groups()
         if self.lena == None:
             self.lena = 1
         else:
@@ -476,7 +476,7 @@
         m = contextdesc.match(self.desc)
         if not m:
             raise PatchError(_("bad hunk #%d") % self.number)
-        foo, self.starta, foo2, aend, foo3 = m.groups()
+        _foo, self.starta, _foo, aend, _foo = m.groups()
         self.starta = int(self.starta)
         if aend == None:
             aend = self.starta
@@ -508,7 +508,7 @@
         m = contextdesc.match(l)
         if not m:
             raise PatchError(_("bad hunk #%d") % self.number)
-        foo, self.startb, foo2, bend, foo3 = m.groups()
+        _foo, self.startb, _foo, bend, _foo = m.groups()
         self.startb = int(self.startb)
         if bend == None:
             bend = self.startb
@@ -1234,7 +1234,7 @@
         r = [hexfunc(node) for node in [node1, node2] if node]
 
     if opts.git:
-        copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
+        copy, _diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
         for k, v in copy.items():
             copy[v] = k
 
diff --git a/mercurial/pure/diffhelpers.py b/mercurial/pure/diffhelpers.py
--- a/mercurial/pure/diffhelpers.py
+++ b/mercurial/pure/diffhelpers.py
@@ -12,7 +12,7 @@
         num = max(todoa, todob)
         if num == 0:
             break
-        for i in xrange(num):
+        for _i in xrange(num):
             s = fp.readline()
             c = s[0]
             if s == "\\ No newline at end of file\n":
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -136,7 +136,7 @@
         while cur < end:
             data = self.dataf.read(blocksize)
             off = 0
-            for x in xrange(256):
+            for _x in xrange(256):
                 n = data[off + ngshaoffset:off + ngshaoffset + 20]
                 self.map[n] = count
                 count += 1
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -293,7 +293,7 @@
             if region[0] != "conflict":
                 yield region
                 continue
-            type, iz, zmatch, ia, amatch, ib, bmatch = region
+            type, _iz, _zmatch, ia, amatch, ib, bmatch = region
             a_region = self.a[ia:amatch]
             b_region = self.b[ib:bmatch]
             matches = mdiff.get_matching_blocks(''.join(a_region),
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -92,7 +92,7 @@
         self.respond("")
 
     def do_branches(self):
-        arg, nodes = self.getarg()
+        _arg, nodes = self.getarg()
         nodes = map(bin, nodes.split(" "))
         r = []
         for b in self.repo.branches(nodes):
@@ -100,7 +100,7 @@
         self.respond("".join(r))
 
     def do_between(self):
-        arg, pairs = self.getarg()
+        _arg, pairs = self.getarg()
         pairs = [map(bin, p.split("-")) for p in pairs.split(" ")]
         r = []
         for b in self.repo.between(pairs):
@@ -108,8 +108,7 @@
         self.respond("".join(r))
 
     def do_changegroup(self):
-        nodes = []
-        arg, roots = self.getarg()
+        _arg, roots = self.getarg()
         nodes = map(bin, roots.split(" "))
 
         cg = self.repo.changegroup(nodes, 'serve')
diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -46,7 +46,7 @@
             repo.ui.debug(_('scanning\n'))
             # get consistent snapshot of repo, lock during scan
             l = repo.lock()
-            for name, ename, size in repo.store.walk():
+            for name, _ename, size in repo.store.walk():
                 entries.append((name, size))
                 total_bytes += size
         finally:
diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -82,7 +82,7 @@
 
         self.report(_("transaction abort!\n"))
 
-        for f, o, ignore in self.entries:
+        for f, o, _ignore in self.entries:
             try:
                 self.opener(f, "a").truncate(o)
             except:
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -781,7 +781,7 @@
 
     if os.path.isdir(src):
         os.mkdir(dst)
-        for name, kind in osutil.listdir(src):
+        for name, _kind in osutil.listdir(src):
             srcname = os.path.join(src, name)
             dstname = os.path.join(dst, name)
             copyfiles(srcname, dstname, hardlink)
@@ -845,7 +845,7 @@
                                 (path, prefix))
         parts.pop()
         prefixes = []
-        for n in range(len(parts)):
+        for _n in range(len(parts)):
             prefix = os.sep.join(parts)
             if prefix in self.auditeddir:
                 break
@@ -919,7 +919,7 @@
         if cache is None:
             try:
                 dmap = dict([(ncase(n), s)
-                    for n, k, s in osutil.listdir(dir, True)])
+                    for n, _k, s in osutil.listdir(dir, True)])
             except OSError, err:
                 # handle directory not found in Python version prior to 2.5
                 # Python <= 2.4 returns native Windows code 3 in errno
@@ -1320,7 +1320,7 @@
         rcdir = os.path.join(path, 'hgrc.d')
         try:
             rcs.extend([os.path.join(rcdir, f)
-                        for f, kind in osutil.listdir(rcdir)
+                        for f, _kind in osutil.listdir(rcdir)
                         if f.endswith(".rc")])
         except OSError:
             pass
@@ -1345,7 +1345,7 @@
             if pf[0] == '`':
                 pf = pf[1:-1] # Remove the quotes
         else:
-           if pf.startswith("'") and pf.endswith("'") and " " in pf:
+            if pf.startswith("'") and pf.endswith("'") and " " in pf:
                 pf = pf[1:-1] # Remove the quotes
         return pf
 
@@ -1911,7 +1911,7 @@
     if (seen_dirs is None) and followsym:
         seen_dirs = []
         _add_dir_if_not_there(seen_dirs, path)
-    for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
+    for root, dirs, _files in os.walk(path, topdown=True, onerror=errhandler):
         if '.hg' in dirs:
             yield root # found a repository
             qroot = os.path.join(root, '.hg', 'patches')
@@ -1956,7 +1956,7 @@
             for p in os.environ['HGRCPATH'].split(os.pathsep):
                 if not p: continue
                 if os.path.isdir(p):
-                    for f, kind in osutil.listdir(p):
+                    for f, _kind in osutil.listdir(p):
                         if f.endswith('.rc'):
                             _rcpath.append(os.path.join(p, f))
                 else:
diff --git a/mercurial/util_win32.py b/mercurial/util_win32.py
--- a/mercurial/util_win32.py
+++ b/mercurial/util_win32.py
@@ -237,7 +237,7 @@
             if p.lower().endswith('mercurial.ini'):
                 rcpath.append(p)
             elif os.path.isdir(p):
-                for f, kind in osutil.listdir(p):
+                for f, _kind in osutil.listdir(p):
                     if f.endswith('.rc'):
                         rcpath.append(os.path.join(p, f))
         return rcpath
@@ -304,7 +304,7 @@
                 wincount = int(count)
                 if wincount == -1:
                     wincount = 1048576
-                val, data = win32file.ReadFile(self.handle, wincount)
+                _val, data = win32file.ReadFile(self.handle, wincount)
                 if not data: break
                 cs.write(data)
                 if count != -1:
@@ -324,7 +324,7 @@
                 win32file.SetFilePointer(self.handle, 0, win32file.FILE_END)
             nwrit = 0
             while nwrit < len(data):
-                val, nwrit = win32file.WriteFile(self.handle, data)
+                _val, nwrit = win32file.WriteFile(self.handle, data)
                 data = data[nwrit:]
         except pywintypes.error, err:
             raise WinIOError(err)


More information about the Mercurial-devel mailing list