diff --git a/contrib/import-checker.py b/contrib/import-checker.py index 5d8c223d6b..684735499b 100755 --- a/contrib/import-checker.py +++ b/contrib/import-checker.py @@ -213,7 +213,7 @@ def list_stdlib_modules(): yield m for m in ['cffi']: yield m - stdlib_prefixes = set([sys.prefix, sys.exec_prefix]) + stdlib_prefixes = {sys.prefix, sys.exec_prefix} # We need to supplement the list of prefixes for the search to work # when run from within a virtualenv. for mod in (BaseHTTPServer, zlib): diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py index ae9410bf5e..e5cd53794c 100644 --- a/contrib/synthrepo.py +++ b/contrib/synthrepo.py @@ -71,7 +71,7 @@ testedwith = 'ships-with-hg-core' cmdtable = {} command = cmdutil.command(cmdtable) -newfile = set(('new fi', 'rename', 'copy f', 'copy t')) +newfile = {'new fi', 'rename', 'copy f', 'copy t'} def zerodict(): return collections.defaultdict(lambda: 0) @@ -336,7 +336,7 @@ def synthesize(ui, repo, descpath, **opts): wlock = repo.wlock() lock = repo.lock() - nevertouch = set(('.hgsub', '.hgignore', '.hgtags')) + nevertouch = {'.hgsub', '.hgignore', '.hgtags'} progress = ui.progress _synthesizing = _('synthesizing') diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py index bffff8b7ce..64c193da95 100644 --- a/hgext/convert/filemap.py +++ b/hgext/convert/filemap.py @@ -310,7 +310,7 @@ class filemap_source(common.converter_source): # map to any revision in the restricted graph. Put SKIPREV # in the set of wanted ancestors to simplify code elsewhere self.parentmap[rev] = SKIPREV - self.wantedancestors[rev] = set((SKIPREV,)) + self.wantedancestors[rev] = {SKIPREV} return # Reuse the data from our parent. diff --git a/hgext/convert/git.py b/hgext/convert/git.py index 52dd4444c8..f7558a6e33 100644 --- a/hgext/convert/git.py +++ b/hgext/convert/git.py @@ -32,7 +32,7 @@ class submodule(object): return "%s %s" % (self.node, self.path) # Keys in extra fields that should not be copied if the user requests. -bannedextrakeys = set([ +bannedextrakeys = { # Git commit object built-ins. 'tree', 'parent', @@ -41,7 +41,7 @@ bannedextrakeys = set([ # Mercurial built-ins. 'branch', 'close', -]) +} class convert_git(common.converter_source, common.commandline): # Windows does not support GIT_DIR= construct while other systems @@ -455,9 +455,9 @@ class convert_git(common.converter_source, common.commandline): ('refs/heads/', '') ] - exclude = set([ + exclude = { 'refs/remotes/origin/HEAD', - ]) + } try: output, status = self.gitrunlines('show-ref') diff --git a/hgext/histedit.py b/hgext/histedit.py index aaba2719e8..2271f5ab5f 100644 --- a/hgext/histedit.py +++ b/hgext/histedit.py @@ -1641,8 +1641,8 @@ def stripwrapper(orig, ui, repo, nodelist, *args, **kwargs): if os.path.exists(os.path.join(repo.path, 'histedit-state')): state = histeditstate(repo) state.read() - histedit_nodes = set([action.node for action - in state.actions if action.node]) + histedit_nodes = {action.node for action + in state.actions if action.node} common_nodes = histedit_nodes & set(nodelist) if common_nodes: raise error.Abort(_("histedit in progress, can't strip %s") diff --git a/hgext/journal.py b/hgext/journal.py index b71e45bfa6..f84c4e25d9 100644 --- a/hgext/journal.py +++ b/hgext/journal.py @@ -158,7 +158,7 @@ def unsharejournal(orig, ui, repo, repopath): util.safehasattr(repo, 'journal')): sharedrepo = share._getsrcrepo(repo) sharedfeatures = _readsharedfeatures(repo) - if sharedrepo and sharedfeatures > set(['journal']): + if sharedrepo and sharedfeatures > {'journal'}: # there is a shared repository and there are shared journal entries # to copy. move shared date over from source to destination but # move the local file first diff --git a/hgext/largefiles/__init__.py b/hgext/largefiles/__init__.py index daa5116367..cd148349b3 100644 --- a/hgext/largefiles/__init__.py +++ b/hgext/largefiles/__init__.py @@ -129,7 +129,7 @@ reposetup = reposetup.reposetup def featuresetup(ui, supported): # don't die on seeing a repo with the largefiles requirement - supported |= set(['largefiles']) + supported |= {'largefiles'} def uisetup(ui): localrepo.localrepository.featuresetupfuncs.add(featuresetup) diff --git a/hgext/rebase.py b/hgext/rebase.py index 5f23b29502..7f005b6651 100644 --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -242,7 +242,7 @@ class rebaseruntime(object): skipped = set() # recompute the set of skipped revs if not collapse: - seen = set([dest]) + seen = {dest} for old, new in sorted(state.items()): if new != revtodo and new in seen: skipped.add(old) @@ -250,7 +250,7 @@ class rebaseruntime(object): repo.ui.debug('computed skipped revs: %s\n' % (' '.join(str(r) for r in sorted(skipped)) or None)) repo.ui.debug('rebase status resumed\n') - _setrebasesetvisibility(repo, set(state.keys()) | set([originalwd])) + _setrebasesetvisibility(repo, set(state.keys()) | {originalwd}) self.originalwd = originalwd self.dest = dest @@ -1235,7 +1235,7 @@ def buildstate(repo, dest, rebaseset, collapse, obsoletenotrebased): rebaseset: set of rev ''' originalwd = repo['.'].rev() - _setrebasesetvisibility(repo, set(rebaseset) | set([originalwd])) + _setrebasesetvisibility(repo, set(rebaseset) | {originalwd}) # This check isn't strictly necessary, since mq detects commits over an # applied patch. But it prevents messing up the working directory when diff --git a/hgext/shelve.py b/hgext/shelve.py index eba2634a5d..53106c4d51 100644 --- a/hgext/shelve.py +++ b/hgext/shelve.py @@ -352,7 +352,7 @@ def mutableancestors(ctx): """return all mutable ancestors for ctx (included) Much faster than the revset ancestors(ctx) & draft()""" - seen = set([nodemod.nullrev]) + seen = {nodemod.nullrev} visit = collections.deque() visit.append(ctx) while visit: @@ -1006,17 +1006,17 @@ def shelvecmd(ui, repo, *pats, **opts): all shelved changes, use ``--cleanup``. ''' allowables = [ - ('addremove', set(['create'])), # 'create' is pseudo action - ('unknown', set(['create'])), - ('cleanup', set(['cleanup'])), -# ('date', set(['create'])), # ignored for passing '--date "0 0"' in tests - ('delete', set(['delete'])), - ('edit', set(['create'])), - ('list', set(['list'])), - ('message', set(['create'])), - ('name', set(['create'])), - ('patch', set(['patch', 'list'])), - ('stat', set(['stat', 'list'])), + ('addremove', {'create'}), # 'create' is pseudo action + ('unknown', {'create'}), + ('cleanup', {'cleanup'}), +# ('date', {'create'}), # ignored for passing '--date "0 0"' in tests + ('delete', {'delete'}), + ('edit', {'create'}), + ('list', {'list'}), + ('message', {'create'}), + ('name', {'create'}), + ('patch', {'patch', 'list'}), + ('stat', {'stat', 'list'}), ] def checkopt(opt): if opts.get(opt): diff --git a/hgext/show.py b/hgext/show.py index 8c4a5da884..2e4f6951a7 100644 --- a/hgext/show.py +++ b/hgext/show.py @@ -185,7 +185,7 @@ def underwayrevset(repo, subset, x): # Add working directory parent. wdirrev = repo['.'].rev() if wdirrev != nullrev: - relevant += revset.baseset(set([wdirrev])) + relevant += revset.baseset({wdirrev}) return subset & relevant diff --git a/mercurial/__init__.py b/mercurial/__init__.py index fd458cb764..5d578dec7f 100644 --- a/mercurial/__init__.py +++ b/mercurial/__init__.py @@ -22,14 +22,14 @@ modulepolicy = policy.policy # Modules that have both Python and C implementations. See also the # set of .py files under mercurial/pure/. -_dualmodules = set([ +_dualmodules = { 'mercurial.base85', 'mercurial.bdiff', 'mercurial.diffhelpers', 'mercurial.mpatch', 'mercurial.osutil', 'mercurial.parsers', -]) +} class hgimporter(object): """Object that conforms to import hook interface defined in PEP-302.""" diff --git a/mercurial/ancestor.py b/mercurial/ancestor.py index d4450c567a..bd15a822bd 100644 --- a/mercurial/ancestor.py +++ b/mercurial/ancestor.py @@ -47,7 +47,7 @@ def commonancestorsheads(pfunc, *nodes): sv |= poison if v in nodes: # history is linear - return set([v]) + return {v} if sv < poison: for p in pfunc(v): sp = seen[p] @@ -151,7 +151,7 @@ class incrementalmissingancestors(object): def hasbases(self): '''whether the common set has any non-trivial bases''' - return self.bases and self.bases != set([nullrev]) + return self.bases and self.bases != {nullrev} def addbases(self, newbases): '''grow the ancestor set by adding new bases''' diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py index ccd3f9622e..db51e5e7fd 100644 --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1693,7 +1693,7 @@ def walkfilerevs(repo, match, follow, revs, fncache): last = filelog.rev(node) # keep track of all ancestors of the file - ancestors = set([filelog.linkrev(last)]) + ancestors = {filelog.linkrev(last)} # iterate from latest to oldest revision for rev, flparentlinkrevs, copied in filerevgen(filelog, last): diff --git a/mercurial/color.py b/mercurial/color.py index c3882679bb..9c9f2e6fe4 100644 --- a/mercurial/color.py +++ b/mercurial/color.py @@ -442,10 +442,10 @@ if pycompat.osname == 'nt': 'inverse': _COMMON_LVB_REVERSE_VIDEO, # double-byte charsets only } - passthrough = set([_FOREGROUND_INTENSITY, - _BACKGROUND_INTENSITY, - _COMMON_LVB_UNDERSCORE, - _COMMON_LVB_REVERSE_VIDEO]) + passthrough = {_FOREGROUND_INTENSITY, + _BACKGROUND_INTENSITY, + _COMMON_LVB_UNDERSCORE, + _COMMON_LVB_REVERSE_VIDEO} stdout = _kernel32.GetStdHandle( _STD_OUTPUT_HANDLE) # don't close the handle returned diff --git a/mercurial/copies.py b/mercurial/copies.py index 81e76d04d6..1e4cb5181e 100644 --- a/mercurial/copies.py +++ b/mercurial/copies.py @@ -637,7 +637,7 @@ def _checkcopies(ctx, f, m1, m2, base, tca, remotebase, limit, data): return of = None - seen = set([f]) + seen = {f} for oc in getfctx(f, m1[f]).ancestors(): ocr = oc.linkrev() of = oc.path() diff --git a/mercurial/discovery.py b/mercurial/discovery.py index 6854b6912d..97a802e080 100644 --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -254,7 +254,7 @@ def _oldheadssummary(repo, remoteheads, outgoing, inc=False): newheads = list(c.node() for c in r) # set some unsynced head to issue the "unsynced changes" warning if inc: - unsynced = set([None]) + unsynced = {None} else: unsynced = set() return {None: (oldheads, newheads, unsynced)} diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py index f08b64844a..e05f7434e4 100644 --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -749,7 +749,7 @@ def _dispatch(req): # imported and commands.table is populated. debugcommands.command - uis = set([ui, lui]) + uis = {ui, lui} if req.repo: uis.add(req.repo.ui) diff --git a/mercurial/encoding.py b/mercurial/encoding.py index b559ca546b..0f1a7fb145 100644 --- a/mercurial/encoding.py +++ b/mercurial/encoding.py @@ -30,9 +30,9 @@ _ignore = [unichr(int(x, 16)).encode("utf-8") for x in "206a 206b 206c 206d 206e 206f feff".split()] # verify the next function will work if pycompat.ispy3: - assert set(i[0] for i in _ignore) == set([ord(b'\xe2'), ord(b'\xef')]) + assert set(i[0] for i in _ignore) == {ord(b'\xe2'), ord(b'\xef')} else: - assert set(i[0] for i in _ignore) == set(["\xe2", "\xef"]) + assert set(i[0] for i in _ignore) == {"\xe2", "\xef"} def hfsignoreclean(s): """Remove codepoints ignored by HFS+ from s. diff --git a/mercurial/exchange.py b/mercurial/exchange.py index 21f2c505f4..816983c054 100644 --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -43,7 +43,7 @@ _bundlespeccgversions = {'v1': '01', } # Compression engines allowed in version 1. THIS SHOULD NEVER CHANGE. -_bundlespecv1compengines = set(['gzip', 'bzip2', 'none']) +_bundlespecv1compengines = {'gzip', 'bzip2', 'none'} def parsebundlespec(repo, spec, strict=True, externalnames=False): """Parse a bundle string specification into parts. @@ -1522,7 +1522,7 @@ def _pullobsolete(pullop): def caps20to10(repo): """return a set with appropriate options to use bundle20 during getbundle""" - caps = set(['HG20']) + caps = {'HG20'} capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) caps.add('bundle2=' + urlreq.quote(capsblob)) return caps diff --git a/mercurial/extensions.py b/mercurial/extensions.py index 57c2f85be5..13f959147c 100644 --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -28,8 +28,8 @@ _extensions = {} _disabledextensions = {} _aftercallbacks = {} _order = [] -_builtin = set(['hbisect', 'bookmarks', 'parentrevspec', 'progress', 'interhg', - 'inotify', 'hgcia']) +_builtin = {'hbisect', 'bookmarks', 'parentrevspec', 'progress', 'interhg', + 'inotify', 'hgcia'} def extensions(ui=None): if ui: diff --git a/mercurial/fancyopts.py b/mercurial/fancyopts.py index 3a742c2253..c6371d3ef5 100644 --- a/mercurial/fancyopts.py +++ b/mercurial/fancyopts.py @@ -14,7 +14,7 @@ from . import ( ) # Set of flags to not apply boolean negation logic on -nevernegate = set([ +nevernegate = { # avoid --no-noninteractive 'noninteractive', # These two flags are special because they cause hg to do one @@ -22,7 +22,7 @@ nevernegate = set([ # like aliases anyway. 'help', 'version', - ]) +} def gnugetopt(args, options, longoptions): """Parse options mostly like getopt.gnu_getopt. diff --git a/mercurial/fileset.py b/mercurial/fileset.py index b94d476631..efa7a495af 100644 --- a/mercurial/fileset.py +++ b/mercurial/fileset.py @@ -37,7 +37,7 @@ elements = { "end": (0, None, None, None, None), } -keywords = set(['and', 'or', 'not']) +keywords = {'and', 'or', 'not'} globchars = ".*{}[]?/\\_" diff --git a/mercurial/help.py b/mercurial/help.py index fc40ac9c9c..a487d23de7 100644 --- a/mercurial/help.py +++ b/mercurial/help.py @@ -34,7 +34,7 @@ from .hgweb import ( webcommands, ) -_exclkeywords = set([ +_exclkeywords = { "(ADVANCED)", "(DEPRECATED)", "(EXPERIMENTAL)", @@ -44,7 +44,7 @@ _exclkeywords = set([ _("(DEPRECATED)"), # i18n: "(EXPERIMENTAL)" is a keyword, must be translated consistently _("(EXPERIMENTAL)"), - ]) +} def listexts(header, exts, indent=1, showdeprecated=False): '''return a text listing of the given extensions''' diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py index 3965af26d6..9ecf4bb2f5 100644 --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -113,9 +113,9 @@ def unfilteredmethod(orig): return orig(repo.unfiltered(), *args, **kwargs) return wrapper -moderncaps = set(('lookup', 'branchmap', 'pushkey', 'known', 'getbundle', - 'unbundle')) -legacycaps = moderncaps.union(set(['changegroupsubset'])) +moderncaps = {'lookup', 'branchmap', 'pushkey', 'known', 'getbundle', + 'unbundle'} +legacycaps = moderncaps.union({'changegroupsubset'}) class localpeer(peer.peerrepository): '''peer for a local repo; reflects only the most recent API''' @@ -247,11 +247,11 @@ class locallegacypeer(localpeer): class localrepository(object): - supportedformats = set(('revlogv1', 'generaldelta', 'treemanifest', - 'manifestv2')) - _basesupported = supportedformats | set(('store', 'fncache', 'shared', - 'relshared', 'dotencode')) - openerreqs = set(('revlogv1', 'generaldelta', 'treemanifest', 'manifestv2')) + supportedformats = {'revlogv1', 'generaldelta', 'treemanifest', + 'manifestv2'} + _basesupported = supportedformats | {'store', 'fncache', 'shared', + 'relshared', 'dotencode'} + openerreqs = {'revlogv1', 'generaldelta', 'treemanifest', 'manifestv2'} filtername = None # a list of (ui, featureset) functions. @@ -2020,7 +2020,7 @@ def newreporequirements(repo): new repositories. """ ui = repo.ui - requirements = set(['revlogv1']) + requirements = {'revlogv1'} if ui.configbool('format', 'usestore', True): requirements.add('store') if ui.configbool('format', 'usefncache', True): diff --git a/mercurial/match.py b/mercurial/match.py index 1a2c740302..a91b948f86 100644 --- a/mercurial/match.py +++ b/mercurial/match.py @@ -236,7 +236,7 @@ class match(object): @propertycache def _dirs(self): - return set(util.dirs(self._fileroots)) | set(['.']) + return set(util.dirs(self._fileroots)) | {'.'} def visitdir(self, dir): '''Decides whether a directory should be visited based on whether it diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py index f0ccea8f54..4892a5bc7a 100644 --- a/mercurial/namespaces.py +++ b/mercurial/namespaces.py @@ -46,7 +46,7 @@ class namespaces(object): logfmt=_("tag: %s\n"), listnames=tagnames, namemap=tagnamemap, nodemap=tagnodemap, - deprecated=set(['tip'])) + deprecated={'tip'}) self.addnamespace(n) bnames = lambda repo: repo.branchmap().keys() diff --git a/mercurial/node.py b/mercurial/node.py index 9fab37009c..c7c9774a8e 100644 --- a/mercurial/node.py +++ b/mercurial/node.py @@ -23,7 +23,7 @@ newnodeid = '!' * 20 addednodeid = ('0' * 15) + 'added' modifiednodeid = ('0' * 12) + 'modified' -wdirnodes = set((newnodeid, addednodeid, modifiednodeid)) +wdirnodes = {newnodeid, addednodeid, modifiednodeid} # pseudo identifiers for working directory # (they are experimental, so don't add too many dependencies on them) diff --git a/mercurial/posix.py b/mercurial/posix.py index 34c8f3d13e..17f7c863f0 100644 --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -474,7 +474,7 @@ def findexe(command): def setsignalhandler(): pass -_wantedkinds = set([stat.S_IFREG, stat.S_IFLNK]) +_wantedkinds = {stat.S_IFREG, stat.S_IFLNK} def statfiles(files): '''Stat each file in files. Yield each stat, or None if a file does not diff --git a/mercurial/revlog.py b/mercurial/revlog.py index b19d7d9599..43ace92647 100644 --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -913,8 +913,8 @@ class revlog(object): stop = [] stoprevs = set([self.rev(n) for n in stop]) startrev = self.rev(start) - reachable = set((startrev,)) - heads = set((startrev,)) + reachable = {startrev} + heads = {startrev} parentrevs = self.parentrevs for r in self.revs(start=startrev + 1): @@ -2039,7 +2039,7 @@ class revlog(object): DELTAREUSESAMEREVS = 'samerevs' DELTAREUSENEVER = 'never' - DELTAREUSEALL = set(['always', 'samerevs', 'never']) + DELTAREUSEALL = {'always', 'samerevs', 'never'} def clone(self, tr, destrevlog, addrevisioncb=None, deltareuse=DELTAREUSESAMEREVS, aggressivemergedeltas=None): diff --git a/mercurial/revset.py b/mercurial/revset.py index d5e4a91578..828e8ee7c4 100644 --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -451,9 +451,8 @@ def bookmark(repo, subset, x): for bmrev in matchrevs: bms.add(repo[bmrev].rev()) else: - bms = set([repo[r].rev() - for r in repo._bookmarks.values()]) - bms -= set([node.nullrev]) + bms = {repo[r].rev() for r in repo._bookmarks.values()} + bms -= {node.nullrev} return subset & bms @predicate('branch(string or set)', safe=True) @@ -1276,7 +1275,7 @@ def named(repo, subset, x): if name not in ns.deprecated: names.update(repo[n].rev() for n in ns.nodes(repo, name)) - names -= set([node.nullrev]) + names -= {node.nullrev} return subset & names @predicate('id(string)', safe=True) @@ -1363,8 +1362,8 @@ def origin(repo, subset, x): return src src = prev - o = set([_firstsrc(r) for r in dests]) - o -= set([None]) + o = {_firstsrc(r) for r in dests} + o -= {None} # XXX we should turn this into a baseset instead of a set, smartset may do # some optimizations from the fact this is a baseset. return subset & o @@ -1393,7 +1392,7 @@ def outgoing(repo, subset, x): outgoing = discovery.findcommonoutgoing(repo, other, onlyheads=revs) repo.ui.popbuffer() cl = repo.changelog - o = set([cl.rev(r) for r in outgoing.missing]) + o = {cl.rev(r) for r in outgoing.missing} return subset & o @predicate('p1([set])', safe=True) @@ -1410,7 +1409,7 @@ def p1(repo, subset, x): cl = repo.changelog for r in getset(repo, fullreposet(repo), x): ps.add(cl.parentrevs(r)[0]) - ps -= set([node.nullrev]) + ps -= {node.nullrev} # XXX we should turn this into a baseset instead of a set, smartset may do # some optimizations from the fact this is a baseset. return subset & ps @@ -1433,7 +1432,7 @@ def p2(repo, subset, x): cl = repo.changelog for r in getset(repo, fullreposet(repo), x): ps.add(cl.parentrevs(r)[1]) - ps -= set([node.nullrev]) + ps -= {node.nullrev} # XXX we should turn this into a baseset instead of a set, smartset may do # some optimizations from the fact this is a baseset. return subset & ps @@ -1458,7 +1457,7 @@ def parents(repo, subset, x): up(p.rev() for p in repo[r].parents()) else: up(parentrevs(r)) - ps -= set([node.nullrev]) + ps -= {node.nullrev} return subset & ps def _phase(repo, subset, *targets): @@ -1965,7 +1964,7 @@ def _toposort(revs, parentsfunc, firstbranch=()): else: # This is a new head. We create a new subgroup for it. targetidx = len(groups) - groups.append(([], set([rev]))) + groups.append(([], {rev})) gr = groups[targetidx] @@ -2098,11 +2097,11 @@ def tag(repo, subset, x): if tn is None: raise error.RepoLookupError(_("tag '%s' does not exist") % pattern) - s = set([repo[tn].rev()]) + s = {repo[tn].rev()} else: - s = set([cl.rev(n) for t, n in repo.tagslist() if matcher(t)]) + s = {cl.rev(n) for t, n in repo.tagslist() if matcher(t)} else: - s = set([cl.rev(n) for t, n in repo.tagslist() if t != 'tip']) + s = {cl.rev(n) for t, n in repo.tagslist() if t != 'tip'} return subset & s @predicate('tagged', safe=True) diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py index c746361355..fee7e500eb 100644 --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -44,9 +44,9 @@ elements = { "end": (0, None, None, None, None), } -keywords = set(['and', 'or', 'not']) +keywords = {'and', 'or', 'not'} -_quoteletters = set(['"', "'"]) +_quoteletters = {'"', "'"} _simpleopletters = set(pycompat.iterbytestr("():=,-|&+!~^%")) # default set of valid characters for the initial letter of symbols diff --git a/mercurial/server.py b/mercurial/server.py index e46dfe44d5..a8280207c7 100644 --- a/mercurial/server.py +++ b/mercurial/server.py @@ -123,7 +123,7 @@ def _createhgwebservice(ui, repo, opts): if opts.get('port'): opts['port'] = util.getport(opts.get('port')) - alluis = set([ui]) + alluis = {ui} if repo: baseui = repo.baseui alluis.update([repo.baseui, repo.ui]) diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py index b7b1d0036e..886654c370 100644 --- a/mercurial/setdiscovery.py +++ b/mercurial/setdiscovery.py @@ -243,7 +243,7 @@ def findcommonheads(ui, local, remote, raise error.Abort(_("repository is unrelated")) else: ui.warn(_("warning: repository is unrelated\n")) - return (set([nullid]), True, srvheadhashes,) + return ({nullid}, True, srvheadhashes,) anyincoming = (srvheadhashes != [nullid]) return dag.externalizeall(result), anyincoming, srvheadhashes diff --git a/mercurial/sslutil.py b/mercurial/sslutil.py index 7e43f53baa..b104ed2e73 100644 --- a/mercurial/sslutil.py +++ b/mercurial/sslutil.py @@ -29,17 +29,17 @@ from . import ( # modern/secure or legacy/insecure. Many operations in this module have # separate code paths depending on support in Python. -configprotocols = set([ +configprotocols = { 'tls1.0', 'tls1.1', 'tls1.2', -]) +} hassni = getattr(ssl, 'HAS_SNI', False) # TLS 1.1 and 1.2 may not be supported if the OpenSSL Python is compiled # against doesn't support them. -supportedprotocols = set(['tls1.0']) +supportedprotocols = {'tls1.0'} if util.safehasattr(ssl, 'PROTOCOL_TLSv1_1'): supportedprotocols.add('tls1.1') if util.safehasattr(ssl, 'PROTOCOL_TLSv1_2'): @@ -296,7 +296,7 @@ def protocolsettings(protocol): # disable protocols via SSLContext.options and OP_NO_* constants. # However, SSLContext.options doesn't work unless we have the # full/real SSLContext available to us. - if supportedprotocols == set(['tls1.0']): + if supportedprotocols == {'tls1.0'}: if protocol != 'tls1.0': raise error.Abort(_('current Python does not support protocol ' 'setting %s') % protocol, @@ -430,7 +430,7 @@ def wrapsocket(sock, keyfile, certfile, ui, serverhostname=None): # is really old. (e.g. server doesn't support TLS 1.0+ or # client doesn't support modern TLS versions introduced # several years from when this comment was written). - if supportedprotocols != set(['tls1.0']): + if supportedprotocols != {'tls1.0'}: ui.warn(_( '(could not communicate with %s using security ' 'protocols %s; if you are using a modern Mercurial ' diff --git a/mercurial/statprof.py b/mercurial/statprof.py index 014aee3f2f..8ba92c0e7e 100755 --- a/mercurial/statprof.py +++ b/mercurial/statprof.py @@ -126,14 +126,14 @@ contextmanager = contextlib.contextmanager __all__ = ['start', 'stop', 'reset', 'display', 'profile'] -skips = set(["util.py:check", "extensions.py:closure", - "color.py:colorcmd", "dispatch.py:checkargs", - "dispatch.py:", "dispatch.py:_runcatch", - "dispatch.py:_dispatch", "dispatch.py:_runcommand", - "pager.py:pagecmd", "dispatch.py:run", - "dispatch.py:dispatch", "dispatch.py:runcommand", - "hg.py:", "evolve.py:warnobserrors", - ]) +skips = {"util.py:check", "extensions.py:closure", + "color.py:colorcmd", "dispatch.py:checkargs", + "dispatch.py:", "dispatch.py:_runcatch", + "dispatch.py:_dispatch", "dispatch.py:_runcommand", + "pager.py:pagecmd", "dispatch.py:run", + "dispatch.py:dispatch", "dispatch.py:runcommand", + "hg.py:", "evolve.py:warnobserrors", +} ########################################################################### ## Utils diff --git a/mercurial/transaction.py b/mercurial/transaction.py index 3c4787b3bc..3621e0f702 100644 --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -26,10 +26,10 @@ version = 2 # These are the file generators that should only be executed after the # finalizers are done, since they rely on the output of the finalizers (like # the changelog having been written). -postfinalizegenerators = set([ +postfinalizegenerators = { 'bookmarks', 'dirstate' -]) +} gengroupall='all' gengroupprefinalize='prefinalize' diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py index 236562c582..a5ebe01dde 100644 --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -28,12 +28,12 @@ def requiredsourcerequirements(repo): An upgrade will not be allowed if the repository doesn't have the requirements returned by this function. """ - return set([ + return { # Introduced in Mercurial 0.9.2. 'revlogv1', # Introduced in Mercurial 0.9.2. 'store', - ]) + } def blocksourcerequirements(repo): """Obtain requirements that will prevent an upgrade from occurring. @@ -41,7 +41,7 @@ def blocksourcerequirements(repo): An upgrade cannot be performed if the source repository contains a requirements in the returned set. """ - return set([ + return { # The upgrade code does not yet support these experimental features. # This is an artificial limitation. 'manifestv2', @@ -51,7 +51,7 @@ def blocksourcerequirements(repo): 'parentdelta', # Upgrade should operate on the actual store, not the shared link. 'shared', - ]) + } def supportremovedrequirements(repo): """Obtain requirements that can be removed during an upgrade. @@ -70,13 +70,13 @@ def supporteddestrequirements(repo): Extensions should monkeypatch this to add their custom requirements. """ - return set([ + return { 'dotencode', 'fncache', 'generaldelta', 'revlogv1', 'store', - ]) + } def allowednewrequirements(repo): """Obtain requirements that can be added to a repository during upgrade. @@ -88,11 +88,11 @@ def allowednewrequirements(repo): bad additions because the whitelist approach is safer and will prevent future, unknown requirements from accidentally being added. """ - return set([ + return { 'dotencode', 'fncache', 'generaldelta', - ]) + } deficiency = 'deficiency' optimisation = 'optimization' @@ -628,7 +628,7 @@ def _upgraderepo(ui, srcrepo, dstrepo, requirements, actions): ui.write(_('marking source repository as being upgraded; clients will be ' 'unable to read from repository\n')) scmutil.writerequires(srcrepo.vfs, - srcrepo.requirements | set(['upgradeinprogress'])) + srcrepo.requirements | {'upgradeinprogress'}) ui.write(_('starting in-place swap of repository data\n')) ui.write(_('replaced files will be backed up at %s\n') % diff --git a/mercurial/util.py b/mercurial/util.py index af8b3b93e3..b0c6c29251 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1097,7 +1097,7 @@ def checksignature(func): return check # a whilelist of known filesystems where hardlink works reliably -_hardlinkfswhitelist = set([ +_hardlinkfswhitelist = { 'btrfs', 'ext2', 'ext3', @@ -1109,7 +1109,7 @@ _hardlinkfswhitelist = set([ 'ufs', 'xfs', 'zfs', -]) +} def copyfile(src, dest, hardlink=False, copystat=False, checkambig=False): '''copy a file, preserving mode and optionally other stat info like diff --git a/mercurial/windows.py b/mercurial/windows.py index 28bdd813f8..35047860f2 100644 --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -334,7 +334,7 @@ def findexe(command): return executable return findexisting(os.path.expanduser(os.path.expandvars(command))) -_wantedkinds = set([stat.S_IFREG, stat.S_IFLNK]) +_wantedkinds = {stat.S_IFREG, stat.S_IFLNK} def statfiles(files): '''Stat each file in files. Yield each stat, or None if a file diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py index f803922006..c10e939cd6 100644 --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -759,7 +759,7 @@ def _capabilities(repo, proto): caps.append('stream-preferred') requiredformats = repo.requirements & repo.supportedformats # if our local revlogs are just revlogv1, add 'stream' cap - if not requiredformats - set(('revlogv1',)): + if not requiredformats - {'revlogv1'}: caps.append('stream') # otherwise, add 'streamreqs' detailing our local revlog format else: diff --git a/tests/check-perf-code.py b/tests/check-perf-code.py index 95f1ca3e42..df58c65bed 100755 --- a/tests/check-perf-code.py +++ b/tests/check-perf-code.py @@ -26,7 +26,7 @@ def modulewhitelist(names): replacement = [('.py', ''), ('.c', ''), # trim suffix ('mercurial%s' % (os.sep), ''), # trim "mercurial/" path ] - ignored = set(['__init__']) + ignored = {'__init__'} modules = {} # convert from file name to module name, and count # of appearances diff --git a/tests/drawdag.py b/tests/drawdag.py index 48bf22996f..d5d63faca9 100644 --- a/tests/drawdag.py +++ b/tests/drawdag.py @@ -145,7 +145,7 @@ def _parseasciigraph(text): def parents(y, x): """(int, int) -> [str]. follow the ASCII edges at given position, return a list of parents""" - visited = set([(y, x)]) + visited = {(y, x)} visit = [] result = [] diff --git a/tests/generate-working-copy-states.py b/tests/generate-working-copy-states.py index 5dffb90ca2..ccb09767c8 100644 --- a/tests/generate-working-copy-states.py +++ b/tests/generate-working-copy-states.py @@ -47,7 +47,7 @@ def generatestates(maxchangesets, parentcontents): content in parentcontents]) + "-" + tracked yield (filename, parentcontents) else: - for content in (set([None, 'content' + str(depth + 1)]) | + for content in ({None, 'content' + str(depth + 1)} | set(parentcontents)): for combination in generatestates(maxchangesets, parentcontents + [content]): diff --git a/tests/test-ancestor.py b/tests/test-ancestor.py index fdb1950c60..cd62933073 100644 --- a/tests/test-ancestor.py +++ b/tests/test-ancestor.py @@ -49,7 +49,7 @@ def buildgraph(rng, nodes=100, rootprob=0.05, mergeprob=0.2, prevprob=0.7): def buildancestorsets(graph): ancs = [None] * len(graph) for i in xrange(len(graph)): - ancs[i] = set([i]) + ancs[i] = {i} if graph[i] == [nullrev]: continue for p in graph[i]: diff --git a/tests/test-duplicateoptions.py b/tests/test-duplicateoptions.py index 9158975167..a635ad5c82 100644 --- a/tests/test-duplicateoptions.py +++ b/tests/test-duplicateoptions.py @@ -6,7 +6,7 @@ from mercurial import ( ui as uimod, ) -ignore = set(['highlight', 'win32text', 'factotum']) +ignore = {'highlight', 'win32text', 'factotum'} if os.name != 'nt': ignore.add('win32mbcs') diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t index 8327f5cc32..01a3771238 100644 --- a/tests/test-histedit-fold.t +++ b/tests/test-histedit-fold.t @@ -154,7 +154,7 @@ check saving last-message.txt > from mercurial import util > def abortfolding(ui, repo, hooktype, **kwargs): > ctx = repo[kwargs.get('node')] - > if set(ctx.files()) == set(['c', 'd', 'f']): + > if set(ctx.files()) == {'c', 'd', 'f'}: > return True # abort folding commit only > ui.warn('allow non-folding commit\\n') > EOF diff --git a/tests/test-requires.t b/tests/test-requires.t index 0d1bd1a6cc..c728ca504d 100644 --- a/tests/test-requires.t +++ b/tests/test-requires.t @@ -37,7 +37,7 @@ another repository of push/pull/clone on localhost: > for name, module in extensions.extensions(ui): > if __name__ == module.__name__: > # support specific feature locally - > supported |= set(['featuresetup-test']) + > supported |= {'featuresetup-test'} > return > def uisetup(ui): > localrepo.localrepository.featuresetupfuncs.add(featuresetup)