Mercurial > hg
changeset 42057:566daffc607d
cleanup: use set literals where possible
Differential Revision: https://phab.mercurial-scm.org/D6192
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 03 Apr 2019 11:21:27 -0700 |
parents | 4950ae4d034f |
children | ec7b478f1bf8 |
files | hgext/fastannotate/commands.py hgext/largefiles/basestore.py hgext/mq.py hgext/rebase.py hgext/remotefilelog/__init__.py hgext/remotefilelog/repack.py hgext/show.py hgext/uncommit.py mercurial/bundle2.py mercurial/cmdutil.py mercurial/dagop.py mercurial/exchange.py mercurial/hbisect.py mercurial/help.py mercurial/merge.py mercurial/obsolete.py mercurial/revlogutils/deltas.py mercurial/wireprotov1server.py |
diffstat | 18 files changed, 27 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/fastannotate/commands.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/fastannotate/commands.py Wed Apr 03 11:21:27 2019 -0700 @@ -198,9 +198,9 @@ formatter.write(result, lines, existinglines=existinglines) formatter.end() -_newopts = set([]) -_knownopts = set([opt[1].replace('-', '_') for opt in - (fastannotatecommandargs[r'options'] + commands.globalopts)]) +_newopts = set() +_knownopts = {opt[1].replace('-', '_') for opt in + (fastannotatecommandargs[r'options'] + commands.globalopts)} def _annotatewrapper(orig, ui, repo, *pats, **opts): """used by wrapdefault"""
--- a/hgext/largefiles/basestore.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/largefiles/basestore.py Wed Apr 03 11:21:27 2019 -0700 @@ -136,7 +136,7 @@ failed = self._verifyfiles(contents, filestocheck) numrevs = len(verified) - numlfiles = len(set([fname for (fname, fnode) in verified])) + numlfiles = len({fname for (fname, fnode) in verified}) if contents: self.ui.status( _('verified contents of %d revisions of %d largefiles\n')
--- a/hgext/mq.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/mq.py Wed Apr 03 11:21:27 2019 -0700 @@ -1940,7 +1940,7 @@ self.ui.write(patchname, label='qseries.' + state) self.ui.write('\n') - applied = set([p.name for p in self.applied]) + applied = {p.name for p in self.applied} if length is None: length = len(self.series) - start if not missing: @@ -3658,7 +3658,7 @@ """Changesets managed by MQ. """ revsetlang.getargs(x, 0, 0, _("mq takes no arguments")) - applied = set([repo[r.node].rev() for r in repo.mq.applied]) + applied = {repo[r.node].rev() for r in repo.mq.applied} return smartset.baseset([r for r in subset if r in applied]) # tell hggettext to extract docstrings from these functions:
--- a/hgext/rebase.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/rebase.py Wed Apr 03 11:21:27 2019 -0700 @@ -1878,8 +1878,8 @@ obsolete successors. """ obsoletenotrebased = {} - obsoletewithoutsuccessorindestination = set([]) - obsoleteextinctsuccessors = set([]) + obsoletewithoutsuccessorindestination = set() + obsoleteextinctsuccessors = set() assert repo.filtername is None cl = repo.changelog
--- a/hgext/remotefilelog/__init__.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/remotefilelog/__init__.py Wed Apr 03 11:21:27 2019 -0700 @@ -804,7 +804,7 @@ return reposfile = open(repospath, 'rb') - repos = set([r[:-1] for r in reposfile.readlines()]) + repos = {r[:-1] for r in reposfile.readlines()} reposfile.close() # build list of useful files
--- a/hgext/remotefilelog/repack.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/remotefilelog/repack.py Wed Apr 03 11:21:27 2019 -0700 @@ -154,9 +154,9 @@ # Either an oversize index or datapack will trigger cleanup of the whole # pack: - oversized = set([os.path.splitext(path)[0] for path, ftype, stat in files + oversized = {os.path.splitext(path)[0] for path, ftype, stat in files if (stat.st_size > maxsize and (os.path.splitext(path)[1] - in VALIDEXTS))]) + in VALIDEXTS))} for rootfname in oversized: rootpath = os.path.join(folder, rootfname)
--- a/hgext/show.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/show.py Wed Apr 03 11:21:27 2019 -0700 @@ -243,7 +243,7 @@ else: newheads = set() - allrevs = set(stackrevs) | newheads | set([baserev]) + allrevs = set(stackrevs) | newheads | {baserev} nodelen = longestshortest(repo, allrevs) try:
--- a/hgext/uncommit.py Wed Jul 19 13:17:49 2017 -0700 +++ b/hgext/uncommit.py Wed Apr 03 11:21:27 2019 -0700 @@ -147,7 +147,7 @@ # if not everything tracked in that directory can be # uncommitted. if badfiles: - badfiles -= set([f for f in util.dirs(eligible)]) + badfiles -= {f for f in util.dirs(eligible)} for f in sorted(badfiles): if f in s.clean:
--- a/mercurial/bundle2.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/bundle2.py Wed Apr 03 11:21:27 2019 -0700 @@ -2315,7 +2315,7 @@ oldmatcher=oldmatcher, matcher=newmatcher, fullnodes=commonnodes) - cgdata = packer.generate(set([nodemod.nullid]), list(commonnodes), + cgdata = packer.generate({nodemod.nullid}, list(commonnodes), False, 'narrow_widen', changelog=False) part = bundler.newpart('changegroup', data=cgdata)
--- a/mercurial/cmdutil.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/cmdutil.py Wed Apr 03 11:21:27 2019 -0700 @@ -458,7 +458,7 @@ def __init__(self, dirpath): self.path = dirpath - self.statuses = set([]) + self.statuses = set() self.files = [] self.subdirs = {} @@ -2495,8 +2495,7 @@ if len(old.parents()) > 1: # ctx.files() isn't reliable for merges, so fall back to the # slower repo.status() method - files = set([fn for st in base.status(old)[:3] - for fn in st]) + files = {fn for st in base.status(old)[:3] for fn in st} else: files = set(old.files())
--- a/mercurial/dagop.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/dagop.py Wed Apr 03 11:21:27 2019 -0700 @@ -764,7 +764,7 @@ the input set. """ headrevs = set(revs) - parents = set([node.nullrev]) + parents = {node.nullrev} up = parents.update for rev in revs:
--- a/mercurial/exchange.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/exchange.py Wed Apr 03 11:21:27 2019 -0700 @@ -707,8 +707,8 @@ remotebookmark = listkeys(remote, 'bookmarks') - explicit = set([repo._bookmarks.expandname(bookmark) - for bookmark in pushop.bookmarks]) + explicit = {repo._bookmarks.expandname(bookmark) + for bookmark in pushop.bookmarks} remotebookmark = bookmod.unhexlifybookmarks(remotebookmark) comp = bookmod.comparebookmarks(repo, repo._bookmarks, remotebookmark)
--- a/mercurial/hbisect.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/hbisect.py Wed Apr 03 11:21:27 2019 -0700 @@ -34,7 +34,7 @@ changelog = repo.changelog clparents = changelog.parentrevs - skip = set([changelog.rev(n) for n in state['skip']]) + skip = {changelog.rev(n) for n in state['skip']} def buildancestors(bad, good): badrev = min([changelog.rev(n) for n in bad])
--- a/mercurial/help.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/help.py Wed Apr 03 11:21:27 2019 -0700 @@ -748,7 +748,7 @@ ct = mod.cmdtable except AttributeError: ct = {} - modcmds = set([c.partition('|')[0] for c in ct]) + modcmds = {c.partition('|')[0] for c in ct} rst.extend(helplist(modcmds.__contains__)) else: rst.append(_("(use 'hg help extensions' for information on enabling"
--- a/mercurial/merge.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/merge.py Wed Apr 03 11:21:27 2019 -0700 @@ -815,8 +815,8 @@ fileconflicts.add(f) allconflicts = fileconflicts | pathconflicts - ignoredconflicts = set([c for c in allconflicts - if repo.dirstate._ignore(c)]) + ignoredconflicts = {c for c in allconflicts + if repo.dirstate._ignore(c)} unknownconflicts = allconflicts - ignoredconflicts collectconflicts(ignoredconflicts, ignoredconfig) collectconflicts(unknownconflicts, unknownconfig) @@ -1104,7 +1104,7 @@ Raise an exception if the merge cannot be completed because the repo is narrowed. """ - nooptypes = set(['k']) # TODO: handle with nonconflicttypes + nooptypes = {'k'} # TODO: handle with nonconflicttypes nonconflicttypes = set('a am c cm f g r e'.split()) # We mutate the items in the dict during iteration, so iterate # over a copy.
--- a/mercurial/obsolete.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/obsolete.py Wed Apr 03 11:21:27 2019 -0700 @@ -743,7 +743,7 @@ pruned = [m for m in succsmarkers.get(current, ()) if not m[1]] direct.update(pruned) direct -= seenmarkers - pendingnodes = set([m[0] for m in direct]) + pendingnodes = {m[0] for m in direct} seenmarkers |= direct pendingnodes -= seennodes seennodes |= pendingnodes
--- a/mercurial/revlogutils/deltas.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/revlogutils/deltas.py Wed Apr 03 11:21:27 2019 -0700 @@ -637,7 +637,7 @@ deltas_limit = textlen * LIMIT_DELTA2TEXT - tested = set([nullrev]) + tested = {nullrev} candidates = _refinedgroups(revlog, p1, p2, cachedelta) while True: temptative = candidates.send(good)
--- a/mercurial/wireprotov1server.py Wed Jul 19 13:17:49 2017 -0700 +++ b/mercurial/wireprotov1server.py Wed Apr 03 11:21:27 2019 -0700 @@ -345,7 +345,7 @@ one specific branch of many. """ def decodehexstring(s): - return set([binascii.unhexlify(h) for h in s.split(';')]) + return {binascii.unhexlify(h) for h in s.split(';')} manifest = repo.vfs.tryread('pullbundles.manifest') if not manifest: