##// END OF EJS Templates
util: use built-in set and frozenset...
Martin Geisler -
r8150:bbc24c07 default
parent child Browse files
Show More
@@ -148,7 +148,7 b' class filemap_source(converter_source):'
148 148 # wanted by previous runs.
149 149 self._rebuilt = not revmap
150 150 seen = {SKIPREV: SKIPREV}
151 dummyset = util.set()
151 dummyset = set()
152 152 converted = []
153 153 for rev in revmap.order:
154 154 mapped = revmap[rev]
@@ -237,7 +237,7 b' class filemap_source(converter_source):'
237 237 # map to any revision in the restricted graph. Put SKIPREV
238 238 # in the set of wanted ancestors to simplify code elsewhere
239 239 self.parentmap[rev] = SKIPREV
240 self.wantedancestors[rev] = util.set((SKIPREV,))
240 self.wantedancestors[rev] = set((SKIPREV,))
241 241 return
242 242
243 243 # Reuse the data from our parent.
@@ -254,7 +254,7 b' class filemap_source(converter_source):'
254 254
255 255 # The set of wanted ancestors of rev is the union of the sets
256 256 # of wanted ancestors of its parents. Plus rev itself.
257 wrev = util.set()
257 wrev = set()
258 258 for p in parents:
259 259 wrev.update(self.wantedancestors[p])
260 260 wrev.add(rev)
@@ -564,7 +564,7 b' class svn_source(converter_source):'
564 564 out, e.g. 'I copied trunk into a subdirectory of itself instead
565 565 of making a branch'. The converted repository is significantly
566 566 smaller if we ignore such revisions."""
567 self.blacklist = util.set()
567 self.blacklist = set()
568 568 blacklist = self.blacklist
569 569 for line in file("blacklist.txt", "r"):
570 570 if not line.startswith("#"):
@@ -1099,7 +1099,7 b' class svn_sink(converter_sink, commandli'
1099 1099 os.rename(tempname, wdest)
1100 1100
1101 1101 def dirs_of(self, files):
1102 dirs = util.set()
1102 dirs = set()
1103 1103 for f in files:
1104 1104 if os.path.isdir(self.wjoin(f)):
1105 1105 dirs.add(f)
@@ -1155,8 +1155,8 b' class svn_sink(converter_sink, commandli'
1155 1155 return self.revid(self.childmap[parent])
1156 1156 except KeyError:
1157 1157 pass
1158 entries = util.set(self.delete)
1159 files = util.frozenset(files)
1158 entries = set(self.delete)
1159 files = frozenset(files)
1160 1160 entries.update(self.add_dirs(files.difference(entries)))
1161 1161 if self.copies:
1162 1162 for s, d in self.copies:
@@ -286,7 +286,7 b' def graphlog(ui, repo, path=None, **opts'
286 286
287 287 def graphrevs(repo, nodes, opts):
288 288 nodes.reverse()
289 include = util.set(nodes)
289 include = set(nodes)
290 290 limit = cmdutil.loglimit(opts)
291 291 count = 0
292 292 for node in nodes:
@@ -128,8 +128,8 b' def rebase(ui, repo, **opts):'
128 128
129 129 if not keepf:
130 130 # Remove no more useful revisions
131 if (util.set(repo.changelog.descendants(min(state)))
132 - util.set(state.keys())):
131 if (set(repo.changelog.descendants(min(state)))
132 - set(state.keys())):
133 133 ui.warn(_("warning: new changesets detected on source branch, "
134 134 "not stripping\n"))
135 135 else:
@@ -353,7 +353,7 b' def restorestatus(repo):'
353 353
354 354 def abort(repo, originalwd, target, state):
355 355 'Restore the repository to its original state'
356 if util.set(repo.changelog.descendants(target)) - util.set(state.values()):
356 if set(repo.changelog.descendants(target)) - set(state.values()):
357 357 repo.ui.warn(_("warning: new changesets detected on target branch, "
358 358 "not stripping\n"))
359 359 else:
@@ -368,7 +368,7 b' def abort(repo, originalwd, target, stat'
368 368
369 369 def buildstate(repo, dest, src, base, collapse):
370 370 'Define which revisions are going to be rebased and where'
371 targetancestors = util.set()
371 targetancestors = set()
372 372
373 373 if not dest:
374 374 # Destination defaults to the latest revision in the current branch
@@ -397,12 +397,12 b' def buildstate(repo, dest, src, base, co'
397 397 repo.ui.debug(_('already working on current\n'))
398 398 return None
399 399
400 targetancestors = util.set(repo.changelog.ancestors(dest))
400 targetancestors = set(repo.changelog.ancestors(dest))
401 401 if cwd in targetancestors:
402 402 repo.ui.debug(_('already working on the current branch\n'))
403 403 return None
404 404
405 cwdancestors = util.set(repo.changelog.ancestors(cwd))
405 cwdancestors = set(repo.changelog.ancestors(cwd))
406 406 cwdancestors.add(cwd)
407 407 rebasingbranch = cwdancestors - targetancestors
408 408 source = min(rebasingbranch)
@@ -412,7 +412,7 b' def buildstate(repo, dest, src, base, co'
412 412 external = nullrev
413 413 if collapse:
414 414 if not targetancestors:
415 targetancestors = util.set(repo.changelog.ancestors(dest))
415 targetancestors = set(repo.changelog.ancestors(dest))
416 416 for rev in state:
417 417 # Check externals and fail if there are more than one
418 418 for p in repo[rev].parents():
@@ -99,7 +99,7 b' def macencode(s, cmd):'
99 99
100 100 def forbidnewline(ui, repo, hooktype, node, newline, **kwargs):
101 101 halt = False
102 seen = util.set()
102 seen = set()
103 103 # we try to walk changesets in reverse order from newest to
104 104 # oldest, so that if we see a file multiple times, we take the
105 105 # newest version as canonical. this prevents us from blocking a
@@ -1306,7 +1306,7 b' def heads(ui, repo, *branchrevs, **opts)'
1306 1306 heads = repo.heads(start, closed=closed)
1307 1307 else:
1308 1308 heads = []
1309 visitedset = util.set()
1309 visitedset = set()
1310 1310 for branchrev in branchrevs:
1311 1311 branch = repo[branchrev].branch()
1312 1312 if branch in visitedset:
@@ -52,9 +52,9 b' class httprepository(repo.repository):'
52 52 def get_caps(self):
53 53 if self.caps is None:
54 54 try:
55 self.caps = util.set(self.do_read('capabilities').split())
55 self.caps = set(self.do_read('capabilities').split())
56 56 except error.RepoError:
57 self.caps = util.set()
57 self.caps = set()
58 58 self.ui.debug(_('capabilities: %s\n') %
59 59 (' '.join(self.caps or ['none'])))
60 60 return self.caps
@@ -17,7 +17,7 b' import merge as merge_'
17 17 from lock import release
18 18
19 19 class localrepository(repo.repository):
20 capabilities = util.set(('lookup', 'changegroupsubset'))
20 capabilities = set(('lookup', 'changegroupsubset'))
21 21 supported = ('revlogv1', 'store', 'fncache')
22 22
23 23 def __init__(self, parentui, path=None, create=0):
@@ -576,7 +576,7 b' class revlog(object):'
576 576 def ancestors(self, *revs):
577 577 'Generate the ancestors of revs using a breadth-first visit'
578 578 visit = list(revs)
579 seen = util.set([nullrev])
579 seen = set([nullrev])
580 580 while visit:
581 581 for parent in self.parentrevs(visit.pop(0)):
582 582 if parent not in seen:
@@ -586,7 +586,7 b' class revlog(object):'
586 586
587 587 def descendants(self, *revs):
588 588 'Generate the descendants of revs in topological order'
589 seen = util.set(revs)
589 seen = set(revs)
590 590 for i in xrange(min(revs) + 1, len(self)):
591 591 for x in self.parentrevs(i):
592 592 if x != nullrev and x in seen:
@@ -80,7 +80,7 b' class sshrepository(repo.repository):'
80 80 else:
81 81 self.abort(error.RepoError(_("no suitable response from remote hg")))
82 82
83 self.capabilities = util.set()
83 self.capabilities = set()
84 84 lines.reverse()
85 85 for l in lines:
86 86 if l.startswith("capabilities:"):
@@ -84,8 +84,8 b' def quotepath(path):'
84 84 '''
85 85 global _safeset, _hex
86 86 if _safeset is None:
87 _safeset = util.set(_safe)
88 _hex = util.set('abcdefABCDEF0123456789')
87 _safeset = set(_safe)
88 _hex = set('abcdefABCDEF0123456789')
89 89 l = list(path)
90 90 for i in xrange(len(l)):
91 91 c = l[i]
@@ -19,12 +19,6 b' import imp'
19 19
20 20 # Python compatibility
21 21
22 try:
23 set = set
24 frozenset = frozenset
25 except NameError:
26 from sets import Set as set, ImmutableSet as frozenset
27
28 22 _md5 = None
29 23 def md5(s):
30 24 global _md5
@@ -1,7 +1,7 b''
1 1 import os
2 2 import os.path
3 3 from mercurial import hg, ui
4 from mercurial.util import walkrepos, set, frozenset
4 from mercurial.util import walkrepos
5 5 from os import mkdir, chdir
6 6 from os.path import join as pjoin
7 7
General Comments 0
You need to be logged in to leave comments. Login now