changeset 41365:876494fd967d

cleanup: delete lots of unused local variables These were found by IntelliJ. There are many more, but these seemed pretty safe. Differential Revision: https://phab.mercurial-scm.org/D5629
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 17 Jan 2019 09:17:12 -0800
parents 0132221c25cd
children fabb0224a599
files contrib/bdiff-torture.py contrib/check-code.py contrib/perf.py contrib/synthrepo.py hgext/absorb.py hgext/blackbox.py hgext/convert/cvs.py hgext/convert/hg.py hgext/convert/monotone.py hgext/convert/subversion.py hgext/fastannotate/protocol.py hgext/fastannotate/support.py hgext/fsmonitor/__init__.py hgext/fsmonitor/pywatchman/capabilities.py hgext/fsmonitor/pywatchman/pybser.py hgext/githelp.py hgext/journal.py hgext/largefiles/overrides.py hgext/largefiles/storefactory.py hgext/phabricator.py hgext/rebase.py hgext/remotefilelog/basepack.py hgext/remotefilelog/datapack.py hgext/remotefilelog/debugcommands.py hgext/remotefilelog/historypack.py hgext/remotefilelog/remotefilelog.py hgext/remotefilelog/repack.py hgext/zeroconf/Zeroconf.py mercurial/bookmarks.py mercurial/changegroup.py mercurial/cmdutil.py mercurial/color.py mercurial/commands.py mercurial/debugcommands.py mercurial/exchange.py mercurial/filemerge.py mercurial/hg.py mercurial/hgweb/hgwebdir_mod.py mercurial/localrepo.py mercurial/logexchange.py mercurial/manifest.py mercurial/merge.py mercurial/minirst.py mercurial/patch.py mercurial/statprof.py mercurial/subrepoutil.py mercurial/transaction.py mercurial/ui.py mercurial/wireprotov1server.py tests/run-tests.py tests/test-ancestor.py tests/test-linelog.py tests/test-remotefilelog-histpack.py tests/test-revlog-raw.py
diffstat 54 files changed, 12 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/bdiff-torture.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/contrib/bdiff-torture.py	Thu Jan 17 09:17:12 2019 -0800
@@ -25,7 +25,7 @@
 
         try:
             test1(a, b)
-        except Exception as inst:
+        except Exception:
             reductions += 1
             tries = 0
             a = a2
--- a/contrib/check-code.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/contrib/check-code.py	Thu Jan 17 09:17:12 2019 -0800
@@ -610,7 +610,7 @@
     try:
         with opentext(f) as fp:
             try:
-                pre = post = fp.read()
+                pre = fp.read()
             except UnicodeDecodeError as e:
                 print("%s while reading %s" % (e, f))
                 return result
--- a/contrib/perf.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/contrib/perf.py	Thu Jan 17 09:17:12 2019 -0800
@@ -911,9 +911,7 @@
         raise error.Abort((b'default repository not configured!'),
                           hint=(b"see 'hg help config.paths'"))
     dest = path.pushloc or path.loc
-    branches = (path.branch, opts.get(b'branch') or [])
     ui.status((b'analysing phase of %s\n') % util.hidepassword(dest))
-    revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get(b'rev'))
     other = hg.peer(repo, opts, dest)
 
     # easier to perform discovery through the operation
--- a/contrib/synthrepo.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/contrib/synthrepo.py	Thu Jan 17 09:17:12 2019 -0800
@@ -450,7 +450,6 @@
                 path = fctx.path()
                 changes[path] = '\n'.join(lines) + '\n'
             for __ in xrange(pick(filesremoved)):
-                path = random.choice(mfk)
                 for __ in xrange(10):
                     path = random.choice(mfk)
                     if path not in changes:
--- a/hgext/absorb.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/absorb.py	Thu Jan 17 09:17:12 2019 -0800
@@ -726,7 +726,6 @@
                 # nothing changed, nothing commited
                 nextp1 = ctx
                 continue
-            msg = ''
             if self._willbecomenoop(memworkingcopy, ctx, nextp1):
                 # changeset is no longer necessary
                 self.replacemap[ctx.node()] = None
--- a/hgext/blackbox.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/blackbox.py	Thu Jan 17 09:17:12 2019 -0800
@@ -118,7 +118,6 @@
         date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
         user = procutil.getuser()
         pid = '%d' % procutil.getpid()
-        rev = '(unknown)'
         changed = ''
         ctx = self._repo[None]
         parents = ctx.parents()
--- a/hgext/convert/cvs.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/convert/cvs.py	Thu Jan 17 09:17:12 2019 -0800
@@ -76,7 +76,6 @@
         d = encoding.getcwd()
         try:
             os.chdir(self.path)
-            id = None
 
             cache = 'update'
             if not self.ui.configbool('convert', 'cvsps.cache'):
@@ -219,7 +218,7 @@
         if "UseUnchanged" in r:
             self.writep.write("UseUnchanged\n")
             self.writep.flush()
-            r = self.readp.readline()
+            self.readp.readline()
 
     def getheads(self):
         self._parse()
--- a/hgext/convert/hg.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/convert/hg.py	Thu Jan 17 09:17:12 2019 -0800
@@ -105,10 +105,6 @@
         if not branch:
             branch = 'default'
         pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches]
-        if pbranches:
-            pbranch = pbranches[0][1]
-        else:
-            pbranch = 'default'
 
         branchpath = os.path.join(self.path, branch)
         if setbranch:
--- a/hgext/convert/monotone.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/convert/monotone.py	Thu Jan 17 09:17:12 2019 -0800
@@ -335,7 +335,6 @@
 
     def before(self):
         # Check if we have a new enough version to use automate stdio
-        version = 0.0
         try:
             versionstr = self.mtnrunsingle("interface_version")
             version = float(versionstr)
--- a/hgext/convert/subversion.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/convert/subversion.py	Thu Jan 17 09:17:12 2019 -0800
@@ -984,7 +984,6 @@
         # TODO: ra.get_file transmits the whole file instead of diffs.
         if file in self.removed:
             return None, None
-        mode = ''
         try:
             new_module, revnum = revsplit(rev)[1:]
             if self.module != new_module:
--- a/hgext/fastannotate/protocol.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/fastannotate/protocol.py	Thu Jan 17 09:17:12 2019 -0800
@@ -71,7 +71,6 @@
             for p in [actx.revmappath, actx.linelogpath]:
                 if not os.path.exists(p):
                     continue
-                content = ''
                 with open(p, 'rb') as f:
                     content = f.read()
                 vfsbaselen = len(repo.vfs.base + '/')
--- a/hgext/fastannotate/support.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/fastannotate/support.py	Thu Jan 17 09:17:12 2019 -0800
@@ -109,7 +109,6 @@
 
 def _remotefctxannotate(orig, self, follow=False, skiprevs=None, diffopts=None):
     # skipset: a set-like used to test if a fctx needs to be downloaded
-    skipset = None
     with context.fctxannotatecontext(self, follow, diffopts) as ac:
         skipset = revmap.revmap(ac.revmappath)
     return orig(self, follow, skiprevs=skiprevs, diffopts=diffopts,
--- a/hgext/fsmonitor/__init__.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/fsmonitor/__init__.py	Thu Jan 17 09:17:12 2019 -0800
@@ -240,24 +240,6 @@
         clock = 'c:0:0'
         notefiles = []
 
-    def fwarn(f, msg):
-        self._ui.warn('%s: %s\n' % (self.pathto(f), msg))
-        return False
-
-    def badtype(mode):
-        kind = _('unknown')
-        if stat.S_ISCHR(mode):
-            kind = _('character device')
-        elif stat.S_ISBLK(mode):
-            kind = _('block device')
-        elif stat.S_ISFIFO(mode):
-            kind = _('fifo')
-        elif stat.S_ISSOCK(mode):
-            kind = _('socket')
-        elif stat.S_ISDIR(mode):
-            kind = _('directory')
-        return _('unsupported file type (type is %s)') % kind
-
     ignore = self._ignore
     dirignore = self._dirignore
     if unknown:
--- a/hgext/fsmonitor/pywatchman/capabilities.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/fsmonitor/pywatchman/capabilities.py	Thu Jan 17 09:17:12 2019 -0800
@@ -62,7 +62,6 @@
     vers['capabilities'] = {}
     for name in opts['optional']:
         vers['capabilities'][name] = check(parsed_version, name)
-    failed = False
     for name in opts['required']:
         have = check(parsed_version, name)
         vers['capabilities'][name] = have
--- a/hgext/fsmonitor/pywatchman/pybser.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/fsmonitor/pywatchman/pybser.py	Thu Jan 17 09:17:12 2019 -0800
@@ -267,7 +267,7 @@
             key = key[3:]
         try:
             return self._values[self._keys.index(key)]
-        except ValueError as ex:
+        except ValueError:
             raise KeyError('_BunserDict has no key %s' % key)
 
     def __len__(self):
@@ -420,7 +420,6 @@
 
 
 def _pdu_info_helper(buf):
-    bser_version = -1
     if buf[0:2] == EMPTY_HEADER[0:2]:
         bser_version = 1
         bser_capabilities = 0
--- a/hgext/githelp.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/githelp.py	Thu Jan 17 09:17:12 2019 -0800
@@ -83,7 +83,6 @@
             args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
             break
         except getopt.GetoptError as ex:
-            flag = None
             if "requires argument" in ex.msg:
                 raise
             if ('--' + ex.opt) in ex.msg:
--- a/hgext/journal.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/journal.py	Thu Jan 17 09:17:12 2019 -0800
@@ -348,7 +348,6 @@
 
     def _write(self, vfs, entry):
         with self.jlock(vfs):
-            version = None
             # open file in amend mode to ensure it is created if missing
             with vfs('namejournal', mode='a+b') as f:
                 f.seek(0, os.SEEK_SET)
--- a/hgext/largefiles/overrides.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/largefiles/overrides.py	Thu Jan 17 09:17:12 2019 -0800
@@ -210,8 +210,6 @@
             ui.warn(msg % m.rel(f))
         return int(len(files) > 0)
 
-    result = 0
-
     if after:
         remove = deleted
         result = warn(modified + added + clean,
--- a/hgext/largefiles/storefactory.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/largefiles/storefactory.py	Thu Jan 17 09:17:12 2019 -0800
@@ -43,7 +43,6 @@
             path, _branches = hg.parseurl(path)
             remote = hg.peer(repo or ui, {}, path)
         elif path == 'default-push' or path == 'default':
-            path = ''
             remote = repo
         else:
             path, _branches = hg.parseurl(path)
--- a/hgext/phabricator.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/phabricator.py	Thu Jan 17 09:17:12 2019 -0800
@@ -277,7 +277,6 @@
     The ``old node``, if not None, is guaranteed to be the last diff of
     corresponding Differential Revision, and exist in the repo.
     """
-    url, token = readurltoken(repo)
     unfi = repo.unfiltered()
     nodemap = unfi.changelog.nodemap
 
--- a/hgext/rebase.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/rebase.py	Thu Jan 17 09:17:12 2019 -0800
@@ -1804,7 +1804,6 @@
 
 def pullrebase(orig, ui, repo, *args, **opts):
     'Call rebase after pull if the latter has been invoked with --rebase'
-    ret = None
     if opts.get(r'rebase'):
         if ui.configbool('commands', 'rebase.requiredest'):
             msg = _('rebase destination required by configuration')
--- a/hgext/remotefilelog/basepack.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/basepack.py	Thu Jan 17 09:17:12 2019 -0800
@@ -457,8 +457,6 @@
             pass
 
     def writeindex(self):
-        rawindex = ''
-
         largefanout = len(self.entries) > SMALLFANOUTCUTOFF
         if largefanout:
             params = indexparams(LARGEFANOUTPREFIX, self.VERSION)
--- a/hgext/remotefilelog/datapack.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/datapack.py	Thu Jan 17 09:17:12 2019 -0800
@@ -250,10 +250,8 @@
                     break
                 if node > midnode:
                     start = mid
-                    startnode = midnode
                 elif node < midnode:
                     end = mid
-                    endnode = midnode
             else:
                 return None
 
--- a/hgext/remotefilelog/debugcommands.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/debugcommands.py	Thu Jan 17 09:17:12 2019 -0800
@@ -175,7 +175,6 @@
     return zlib.decompress(raw)
 
 def parsefileblob(path, decompress):
-    raw = None
     f = open(path, "rb")
     try:
         raw = f.read()
--- a/hgext/remotefilelog/historypack.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/historypack.py	Thu Jan 17 09:17:12 2019 -0800
@@ -259,10 +259,8 @@
                     return self._index[mid:mid + entrylen]
                 if node > midnode:
                     start = mid
-                    startnode = midnode
                 elif node < midnode:
                     end = mid
-                    endnode = midnode
         return None
 
     def markledger(self, ledger, options=None):
@@ -514,7 +512,6 @@
 
             fileindexentries.append(rawentry)
 
-        nodecountraw = ''
         nodecountraw = struct.pack('!Q', nodecount)
         return (''.join(fileindexentries) + nodecountraw +
                 ''.join(nodeindexentries))
--- a/hgext/remotefilelog/remotefilelog.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/remotefilelog.py	Thu Jan 17 09:17:12 2019 -0800
@@ -61,8 +61,6 @@
         return t[s + 2:]
 
     def add(self, text, meta, transaction, linknode, p1=None, p2=None):
-        hashtext = text
-
         # hash with the metadata, like in vanilla filelogs
         hashtext = shallowutil.createrevlogtext(text, meta.get('copy'),
                                                 meta.get('copyrev'))
--- a/hgext/remotefilelog/repack.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/remotefilelog/repack.py	Thu Jan 17 09:17:12 2019 -0800
@@ -601,7 +601,6 @@
                 # TODO: Optimize the deltachain fetching. Since we're
                 # iterating over the different version of the file, we may
                 # be fetching the same deltachain over and over again.
-                meta = None
                 if deltabase != nullid:
                     deltaentry = self.data.getdelta(filename, node)
                     delta, deltabasename, origdeltabase, meta = deltaentry
--- a/hgext/zeroconf/Zeroconf.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/hgext/zeroconf/Zeroconf.py	Thu Jan 17 09:17:12 2019 -0800
@@ -938,7 +938,6 @@
         self.zeroconf.engine.addReader(self, self.zeroconf.socket)
 
     def handle_read(self):
-        data = addr = port = None
         sock = self.zeroconf.socket
         try:
             data, (addr, port) = sock.recvfrom(_MAX_MSG_ABSOLUTE)
@@ -1230,7 +1229,6 @@
         delay = _LISTENER_TIME
         next = now + delay
         last = now + timeout
-        result = 0
         try:
             zeroconf.addListener(self, DNSQuestion(self.name, _TYPE_ANY,
                                                    _CLASS_IN))
--- a/mercurial/bookmarks.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/bookmarks.py	Thu Jan 17 09:17:12 2019 -0800
@@ -306,7 +306,6 @@
     itself as we commit. This function returns the name of that bookmark.
     It is stored in .hg/bookmarks.current
     """
-    mark = None
     try:
         file = repo.vfs('bookmarks.current')
     except IOError as inst:
--- a/mercurial/changegroup.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/changegroup.py	Thu Jan 17 09:17:12 2019 -0800
@@ -275,7 +275,7 @@
             # because we need to use the top level value (if they exist)
             # in this function.
             srctype = tr.hookargs.setdefault('source', srctype)
-            url = tr.hookargs.setdefault('url', url)
+            tr.hookargs.setdefault('url', url)
             repo.hook('prechangegroup',
                       throw=True, **pycompat.strkwargs(tr.hookargs))
 
--- a/mercurial/cmdutil.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/cmdutil.py	Thu Jan 17 09:17:12 2019 -0800
@@ -1251,10 +1251,6 @@
                 else:
                     ui.warn(_('%s: cannot copy - %s\n') %
                             (relsrc, encoding.strtolocal(inst.strerror)))
-                    if rename:
-                        hint = _("('hg rename --after' to record the rename)\n")
-                    else:
-                        hint = _("('hg copy --after' to record the copy)\n")
                     return True # report a failure
 
         if ui.verbose or not exact:
--- a/mercurial/color.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/color.py	Thu Jan 17 09:17:12 2019 -0800
@@ -169,7 +169,7 @@
             ui._terminfoparams[key[9:]] = newval
     try:
         curses.setupterm()
-    except curses.error as e:
+    except curses.error:
         ui._terminfoparams.clear()
         return
 
--- a/mercurial/commands.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/commands.py	Thu Jan 17 09:17:12 2019 -0800
@@ -2633,7 +2633,6 @@
         raise error.Abort(_("cannot abort using an old graftstate"))
 
     # changeset from which graft operation was started
-    startctx = None
     if len(newnodes) > 0:
         startctx = repo[newnodes[0]].p1()
     else:
@@ -5503,7 +5502,6 @@
     pnode = parents[0].node()
     marks = []
 
-    ms = None
     try:
         ms = mergemod.mergestate.read(repo)
     except error.UnsupportedMergeRecords as e:
@@ -5908,7 +5906,6 @@
     ui.pager('tags')
     fm = ui.formatter('tags', opts)
     hexfunc = fm.hexfunc
-    tagtype = ""
 
     for t, n in reversed(repo.tagslist()):
         hn = hexfunc(n)
--- a/mercurial/debugcommands.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/debugcommands.py	Thu Jan 17 09:17:12 2019 -0800
@@ -745,7 +745,6 @@
         nodates = True
     datesort = opts.get(r'datesort')
 
-    timestr = ""
     if datesort:
         keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
     else:
@@ -1182,13 +1181,6 @@
     '''
     opts = pycompat.byteskwargs(opts)
 
-    def writetemp(contents):
-        (fd, name) = pycompat.mkstemp(prefix="hg-debuginstall-")
-        f = os.fdopen(fd, r"wb")
-        f.write(contents)
-        f.close()
-        return name
-
     problems = 0
 
     fm = ui.formatter('debuginstall', opts)
@@ -2569,7 +2561,6 @@
 
     source, branches = hg.parseurl(ui.expandpath(source))
     url = util.url(source)
-    addr = None
 
     defaultport = {'https': 443, 'ssh': 22}
     if url.scheme in defaultport:
--- a/mercurial/exchange.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/exchange.py	Thu Jan 17 09:17:12 2019 -0800
@@ -297,7 +297,6 @@
                                               'client'))
             elif part.type == 'stream2' and version is None:
                 # A stream2 part requires to be part of a v2 bundle
-                version = "v2"
                 requirements = urlreq.unquote(part.params['requirements'])
                 splitted = requirements.split()
                 params = bundle2._formatrequirementsparams(splitted)
--- a/mercurial/filemerge.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/filemerge.py	Thu Jan 17 09:17:12 2019 -0800
@@ -462,7 +462,6 @@
     Generic driver for _imergelocal and _imergeother
     """
     assert localorother is not None
-    tool, toolpath, binary, symlink, scriptfn = toolconf
     r = simplemerge.simplemerge(repo.ui, fcd, fca, fco, label=labels,
                                 localorother=localorother)
     return True, r
--- a/mercurial/hg.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/hg.py	Thu Jan 17 09:17:12 2019 -0800
@@ -282,7 +282,7 @@
     called.
     """
 
-    destlock = lock = None
+    destlock = None
     lock = repo.lock()
     try:
         # we use locks here because if we race with commit, we
--- a/mercurial/hgweb/hgwebdir_mod.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Jan 17 09:17:12 2019 -0800
@@ -143,7 +143,7 @@
                 path = path[:-len(discarded) - 1]
 
                 try:
-                    r = hg.repository(ui, path)
+                    hg.repository(ui, path)
                     directory = False
                 except (IOError, error.RepoError):
                     pass
--- a/mercurial/localrepo.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/localrepo.py	Thu Jan 17 09:17:12 2019 -0800
@@ -2539,7 +2539,7 @@
                             m[f] = self._filecommit(fctx, m1, m2, linkrev,
                                                     trp, changed)
                             m.setflag(f, fctx.flags())
-                    except OSError as inst:
+                    except OSError:
                         self.ui.warn(_("trouble committing %s!\n") % f)
                         raise
                     except IOError as inst:
--- a/mercurial/logexchange.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/logexchange.py	Thu Jan 17 09:17:12 2019 -0800
@@ -97,7 +97,6 @@
 
 def activepath(repo, remote):
     """returns remote path"""
-    local = None
     # is the remote a local peer
     local = remote.local()
 
--- a/mercurial/manifest.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/manifest.py	Thu Jan 17 09:17:12 2019 -0800
@@ -283,7 +283,6 @@
         if len(self.extradata) == 0:
             return
         l = []
-        last_cut = 0
         i = 0
         offset = 0
         self.extrainfo = [0] * len(self.positions)
--- a/mercurial/merge.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/merge.py	Thu Jan 17 09:17:12 2019 -0800
@@ -1186,9 +1186,6 @@
 
     diff = m1.diff(m2, match=matcher)
 
-    if matcher is None:
-        matcher = matchmod.always('', '')
-
     actions = {}
     for f, ((n1, fl1), (n2, fl2)) in diff.iteritems():
         if n1 and n2: # file exists on both local and remote side
--- a/mercurial/minirst.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/minirst.py	Thu Jan 17 09:17:12 2019 -0800
@@ -641,7 +641,6 @@
 
 def parse(text, indent=0, keep=None, admonitions=None):
     """Parse text into a list of blocks"""
-    pruned = []
     blocks = findblocks(text)
     for b in blocks:
         b['indent'] += indent
@@ -736,7 +735,6 @@
     '''return a list of (section path, nesting level, blocks) tuples'''
     nest = ""
     names = ()
-    level = 0
     secs = []
 
     def getname(b):
--- a/mercurial/patch.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/patch.py	Thu Jan 17 09:17:12 2019 -0800
@@ -1448,7 +1448,6 @@
             hunk.append(l)
             return l.rstrip('\r\n')
 
-        size = 0
         while True:
             line = getline(lr, self.hunk)
             if not line:
@@ -1903,7 +1902,6 @@
             if not gitpatches:
                 raise PatchError(_('failed to synchronize metadata for "%s"')
                                  % afile[2:])
-            gp = gitpatches[-1]
             newfile = True
         elif x.startswith('---'):
             # check for a unified diff
@@ -2353,7 +2351,6 @@
             modified = filterrel(modified)
             added = filterrel(added)
             removed = filterrel(removed)
-            relfiltered = True
         # filter out copies where either side isn't inside the relative root
         copy = dict(((dst, src) for (dst, src) in copy.iteritems()
                      if dst.startswith(relroot)
--- a/mercurial/statprof.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/statprof.py	Thu Jan 17 09:17:12 2019 -0800
@@ -816,9 +816,6 @@
             id2stack[-1].update(parent=parent)
         return myid
 
-    def endswith(a, b):
-        return list(a)[-len(b):] == list(b)
-
     # The sampling profiler can sample multiple times without
     # advancing the clock, potentially causing the Chrome trace viewer
     # to render single-pixel columns that we cannot zoom in on.  We
@@ -858,9 +855,6 @@
     # events given only stack snapshots.
 
     for sample in data.samples:
-        tos = sample.stack[0]
-        name = tos.function
-        path = simplifypath(tos.path)
         stack = tuple((('%s:%d' % (simplifypath(frame.path), frame.lineno),
                         frame.function) for frame in sample.stack))
         qstack = collections.deque(stack)
--- a/mercurial/subrepoutil.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/subrepoutil.py	Thu Jan 17 09:17:12 2019 -0800
@@ -145,7 +145,6 @@
 
     promptssrc = filemerge.partextras(labels)
     for s, l in sorted(s1.iteritems()):
-        prompts = None
         a = sa.get(s, nullstate)
         ld = l # local state with possible dirty flag for compares
         if wctx.sub(s).dirty():
@@ -218,7 +217,6 @@
                 wctx.sub(s).remove()
 
     for s, r in sorted(s2.items()):
-        prompts = None
         if s in s1:
             continue
         elif s not in sa:
--- a/mercurial/transaction.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/transaction.py	Thu Jan 17 09:17:12 2019 -0800
@@ -89,7 +89,7 @@
                 except (IOError, OSError) as inst:
                     if inst.errno != errno.ENOENT:
                         raise
-        except (IOError, OSError, error.Abort) as inst:
+        except (IOError, OSError, error.Abort):
             if not c:
                 raise
 
@@ -101,7 +101,7 @@
         for f in backupfiles:
             if opener.exists(f):
                 opener.unlink(f)
-    except (IOError, OSError, error.Abort) as inst:
+    except (IOError, OSError, error.Abort):
         # only pure backup file remains, it is sage to ignore any error
         pass
 
--- a/mercurial/ui.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/ui.py	Thu Jan 17 09:17:12 2019 -0800
@@ -566,8 +566,6 @@
             candidate = self._data(untrusted).get(s, n, None)
             if candidate is not None:
                 value = candidate
-                section = s
-                name = n
                 break
 
         if self.debugflag and not untrusted and self._reportuntrusted:
--- a/mercurial/wireprotov1server.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/mercurial/wireprotov1server.py	Thu Jan 17 09:17:12 2019 -0800
@@ -424,8 +424,6 @@
             raise error.Abort(bundle2requiredmain,
                               hint=bundle2requiredhint)
 
-    prefercompressed = True
-
     try:
         clheads = set(repo.changelog.heads())
         heads = set(opts.get('heads', set()))
@@ -578,7 +576,6 @@
                     repo.ui.debug('redirecting incoming bundle to %s\n' %
                         tempname)
                     fp = os.fdopen(fd, pycompat.sysstr('wb+'))
-                    r = 0
                     for p in payload:
                         fp.write(p)
                     fp.seek(0)
--- a/tests/run-tests.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/tests/run-tests.py	Thu Jan 17 09:17:12 2019 -0800
@@ -1225,7 +1225,6 @@
             killdaemons(env['DAEMON_PIDS'])
             return ret
 
-        output = b''
         proc.tochild.close()
 
         try:
--- a/tests/test-ancestor.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/tests/test-ancestor.py	Thu Jan 17 09:17:12 2019 -0800
@@ -123,7 +123,6 @@
             # reference slow algorithm
             naiveinc = naiveincrementalmissingancestors(ancs, bases)
             seq = []
-            revs = []
             for _ in xrange(inccount):
                 if rng.random() < 0.2:
                     newbases = samplerevs(graphnodes)
--- a/tests/test-linelog.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/tests/test-linelog.py	Thu Jan 17 09:17:12 2019 -0800
@@ -15,7 +15,6 @@
 def _genedits(seed, endrev):
     lines = []
     random.seed(seed)
-    rev = 0
     for rev in range(0, endrev):
         n = len(lines)
         a1 = random.randint(0, n)
--- a/tests/test-remotefilelog-histpack.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/tests/test-remotefilelog-histpack.py	Thu Jan 17 09:17:12 2019 -0800
@@ -161,7 +161,7 @@
         pack = self.createPack(revisions)
 
         # Verify the pack contents
-        for (filename, node), (p1, p2, lastnode) in allentries.items():
+        for (filename, node) in allentries:
             ancestors = pack.getancestors(filename, node)
             self.assertEqual(ancestorcounts[(filename, node)],
                              len(ancestors))
--- a/tests/test-revlog-raw.py	Mon Sep 24 14:46:37 2018 -0700
+++ b/tests/test-revlog-raw.py	Thu Jan 17 09:17:12 2019 -0800
@@ -417,7 +417,6 @@
         print('  got:      %s' % result15)
 
 def maintest():
-    expected = rl = None
     with newtransaction() as tr:
         rl = newrevlog(recreate=True)
         expected = writecases(rl, tr)