Mercurial > hg
changeset 8150:bbc24c0753a0
util: use built-in set and frozenset
This drops Python 2.3 compatibility.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 22 Apr 2009 00:55:32 +0200 |
parents | ddbee2d0d634 |
children | 127281884959 |
files | hgext/convert/filemap.py hgext/convert/subversion.py hgext/graphlog.py hgext/rebase.py hgext/win32text.py mercurial/commands.py mercurial/httprepo.py mercurial/localrepo.py mercurial/revlog.py mercurial/sshrepo.py mercurial/url.py mercurial/util.py tests/test-walkrepo.py |
diffstat | 13 files changed, 26 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/convert/filemap.py Fri Apr 24 10:43:12 2009 +0200 +++ b/hgext/convert/filemap.py Wed Apr 22 00:55:32 2009 +0200 @@ -148,7 +148,7 @@ # wanted by previous runs. self._rebuilt = not revmap seen = {SKIPREV: SKIPREV} - dummyset = util.set() + dummyset = set() converted = [] for rev in revmap.order: mapped = revmap[rev] @@ -237,7 +237,7 @@ # 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] = util.set((SKIPREV,)) + self.wantedancestors[rev] = set((SKIPREV,)) return # Reuse the data from our parent. @@ -254,7 +254,7 @@ # The set of wanted ancestors of rev is the union of the sets # of wanted ancestors of its parents. Plus rev itself. - wrev = util.set() + wrev = set() for p in parents: wrev.update(self.wantedancestors[p]) wrev.add(rev)
--- a/hgext/convert/subversion.py Fri Apr 24 10:43:12 2009 +0200 +++ b/hgext/convert/subversion.py Wed Apr 22 00:55:32 2009 +0200 @@ -564,7 +564,7 @@ out, e.g. 'I copied trunk into a subdirectory of itself instead of making a branch'. The converted repository is significantly smaller if we ignore such revisions.""" - self.blacklist = util.set() + self.blacklist = set() blacklist = self.blacklist for line in file("blacklist.txt", "r"): if not line.startswith("#"): @@ -1099,7 +1099,7 @@ os.rename(tempname, wdest) def dirs_of(self, files): - dirs = util.set() + dirs = set() for f in files: if os.path.isdir(self.wjoin(f)): dirs.add(f) @@ -1155,8 +1155,8 @@ return self.revid(self.childmap[parent]) except KeyError: pass - entries = util.set(self.delete) - files = util.frozenset(files) + entries = set(self.delete) + files = frozenset(files) entries.update(self.add_dirs(files.difference(entries))) if self.copies: for s, d in self.copies:
--- a/hgext/graphlog.py Fri Apr 24 10:43:12 2009 +0200 +++ b/hgext/graphlog.py Wed Apr 22 00:55:32 2009 +0200 @@ -286,7 +286,7 @@ def graphrevs(repo, nodes, opts): nodes.reverse() - include = util.set(nodes) + include = set(nodes) limit = cmdutil.loglimit(opts) count = 0 for node in nodes:
--- a/hgext/rebase.py Fri Apr 24 10:43:12 2009 +0200 +++ b/hgext/rebase.py Wed Apr 22 00:55:32 2009 +0200 @@ -128,8 +128,8 @@ if not keepf: # Remove no more useful revisions - if (util.set(repo.changelog.descendants(min(state))) - - util.set(state.keys())): + if (set(repo.changelog.descendants(min(state))) + - set(state.keys())): ui.warn(_("warning: new changesets detected on source branch, " "not stripping\n")) else: @@ -353,7 +353,7 @@ def abort(repo, originalwd, target, state): 'Restore the repository to its original state' - if util.set(repo.changelog.descendants(target)) - util.set(state.values()): + if set(repo.changelog.descendants(target)) - set(state.values()): repo.ui.warn(_("warning: new changesets detected on target branch, " "not stripping\n")) else: @@ -368,7 +368,7 @@ def buildstate(repo, dest, src, base, collapse): 'Define which revisions are going to be rebased and where' - targetancestors = util.set() + targetancestors = set() if not dest: # Destination defaults to the latest revision in the current branch @@ -397,12 +397,12 @@ repo.ui.debug(_('already working on current\n')) return None - targetancestors = util.set(repo.changelog.ancestors(dest)) + targetancestors = set(repo.changelog.ancestors(dest)) if cwd in targetancestors: repo.ui.debug(_('already working on the current branch\n')) return None - cwdancestors = util.set(repo.changelog.ancestors(cwd)) + cwdancestors = set(repo.changelog.ancestors(cwd)) cwdancestors.add(cwd) rebasingbranch = cwdancestors - targetancestors source = min(rebasingbranch) @@ -412,7 +412,7 @@ external = nullrev if collapse: if not targetancestors: - targetancestors = util.set(repo.changelog.ancestors(dest)) + targetancestors = set(repo.changelog.ancestors(dest)) for rev in state: # Check externals and fail if there are more than one for p in repo[rev].parents():
--- a/hgext/win32text.py Fri Apr 24 10:43:12 2009 +0200 +++ b/hgext/win32text.py Wed Apr 22 00:55:32 2009 +0200 @@ -99,7 +99,7 @@ def forbidnewline(ui, repo, hooktype, node, newline, **kwargs): halt = False - seen = util.set() + seen = set() # we try to walk changesets in reverse order from newest to # oldest, so that if we see a file multiple times, we take the # newest version as canonical. this prevents us from blocking a
--- a/mercurial/commands.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/commands.py Wed Apr 22 00:55:32 2009 +0200 @@ -1306,7 +1306,7 @@ heads = repo.heads(start, closed=closed) else: heads = [] - visitedset = util.set() + visitedset = set() for branchrev in branchrevs: branch = repo[branchrev].branch() if branch in visitedset:
--- a/mercurial/httprepo.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/httprepo.py Wed Apr 22 00:55:32 2009 +0200 @@ -52,9 +52,9 @@ def get_caps(self): if self.caps is None: try: - self.caps = util.set(self.do_read('capabilities').split()) + self.caps = set(self.do_read('capabilities').split()) except error.RepoError: - self.caps = util.set() + self.caps = set() self.ui.debug(_('capabilities: %s\n') % (' '.join(self.caps or ['none']))) return self.caps
--- a/mercurial/localrepo.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/localrepo.py Wed Apr 22 00:55:32 2009 +0200 @@ -17,7 +17,7 @@ from lock import release class localrepository(repo.repository): - capabilities = util.set(('lookup', 'changegroupsubset')) + capabilities = set(('lookup', 'changegroupsubset')) supported = ('revlogv1', 'store', 'fncache') def __init__(self, parentui, path=None, create=0):
--- a/mercurial/revlog.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/revlog.py Wed Apr 22 00:55:32 2009 +0200 @@ -576,7 +576,7 @@ def ancestors(self, *revs): 'Generate the ancestors of revs using a breadth-first visit' visit = list(revs) - seen = util.set([nullrev]) + seen = set([nullrev]) while visit: for parent in self.parentrevs(visit.pop(0)): if parent not in seen: @@ -586,7 +586,7 @@ def descendants(self, *revs): 'Generate the descendants of revs in topological order' - seen = util.set(revs) + seen = set(revs) for i in xrange(min(revs) + 1, len(self)): for x in self.parentrevs(i): if x != nullrev and x in seen:
--- a/mercurial/sshrepo.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/sshrepo.py Wed Apr 22 00:55:32 2009 +0200 @@ -80,7 +80,7 @@ else: self.abort(error.RepoError(_("no suitable response from remote hg"))) - self.capabilities = util.set() + self.capabilities = set() lines.reverse() for l in lines: if l.startswith("capabilities:"):
--- a/mercurial/url.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/url.py Wed Apr 22 00:55:32 2009 +0200 @@ -84,8 +84,8 @@ ''' global _safeset, _hex if _safeset is None: - _safeset = util.set(_safe) - _hex = util.set('abcdefABCDEF0123456789') + _safeset = set(_safe) + _hex = set('abcdefABCDEF0123456789') l = list(path) for i in xrange(len(l)): c = l[i]
--- a/mercurial/util.py Fri Apr 24 10:43:12 2009 +0200 +++ b/mercurial/util.py Wed Apr 22 00:55:32 2009 +0200 @@ -19,12 +19,6 @@ # Python compatibility -try: - set = set - frozenset = frozenset -except NameError: - from sets import Set as set, ImmutableSet as frozenset - _md5 = None def md5(s): global _md5
--- a/tests/test-walkrepo.py Fri Apr 24 10:43:12 2009 +0200 +++ b/tests/test-walkrepo.py Wed Apr 22 00:55:32 2009 +0200 @@ -1,7 +1,7 @@ import os import os.path from mercurial import hg, ui -from mercurial.util import walkrepos, set, frozenset +from mercurial.util import walkrepos from os import mkdir, chdir from os.path import join as pjoin