Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 8152:08e1baf924ca
replace set-like dictionaries with real sets
Many of the dictionaries created by dict.fromkeys were emulating sets.
These can now be replaced with real sets.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Wed, 22 Apr 2009 00:57:28 +0200 |
parents | af44d0b953c6 |
children | f3abe032fc89 |
comparison
equal
deleted
inserted
replaced
8151:127281884959 | 8152:08e1baf924ca |
---|---|
1015 if follow: | 1015 if follow: |
1016 defrange = '%s:0' % repo['.'].rev() | 1016 defrange = '%s:0' % repo['.'].rev() |
1017 else: | 1017 else: |
1018 defrange = '-1:0' | 1018 defrange = '-1:0' |
1019 revs = revrange(repo, opts['rev'] or [defrange]) | 1019 revs = revrange(repo, opts['rev'] or [defrange]) |
1020 wanted = {} | 1020 wanted = set() |
1021 slowpath = m.anypats() or (m.files() and opts.get('removed')) | 1021 slowpath = m.anypats() or (m.files() and opts.get('removed')) |
1022 fncache = {} | 1022 fncache = {} |
1023 | 1023 |
1024 if not slowpath and not m.files(): | 1024 if not slowpath and not m.files(): |
1025 # No files, no patterns. Display all revs. | 1025 # No files, no patterns. Display all revs. |
1026 wanted = dict.fromkeys(revs) | 1026 wanted = set(revs) |
1027 copies = [] | 1027 copies = [] |
1028 if not slowpath: | 1028 if not slowpath: |
1029 # Only files, no patterns. Check the history of each file. | 1029 # Only files, no patterns. Check the history of each file. |
1030 def filerevgen(filelog, node): | 1030 def filerevgen(filelog, node): |
1031 cl_count = len(repo) | 1031 cl_count = len(repo) |
1069 if rev <= maxrev: | 1069 if rev <= maxrev: |
1070 if rev < minrev: | 1070 if rev < minrev: |
1071 break | 1071 break |
1072 fncache.setdefault(rev, []) | 1072 fncache.setdefault(rev, []) |
1073 fncache[rev].append(file_) | 1073 fncache[rev].append(file_) |
1074 wanted[rev] = 1 | 1074 wanted.add(rev) |
1075 if follow and copied: | 1075 if follow and copied: |
1076 copies.append(copied) | 1076 copies.append(copied) |
1077 if slowpath: | 1077 if slowpath: |
1078 if follow: | 1078 if follow: |
1079 raise util.Abort(_('can only follow copies/renames for explicit ' | 1079 raise util.Abort(_('can only follow copies/renames for explicit ' |
1087 | 1087 |
1088 for rev, changefiles in changerevgen(): | 1088 for rev, changefiles in changerevgen(): |
1089 matches = filter(m, changefiles) | 1089 matches = filter(m, changefiles) |
1090 if matches: | 1090 if matches: |
1091 fncache[rev] = matches | 1091 fncache[rev] = matches |
1092 wanted[rev] = 1 | 1092 wanted.add(rev) |
1093 | 1093 |
1094 class followfilter: | 1094 class followfilter: |
1095 def __init__(self, onlyfirst=False): | 1095 def __init__(self, onlyfirst=False): |
1096 self.startrev = nullrev | 1096 self.startrev = nullrev |
1097 self.roots = [] | 1097 self.roots = [] |
1133 for rev in opts.get('prune', ()): | 1133 for rev in opts.get('prune', ()): |
1134 rev = repo.changelog.rev(repo.lookup(rev)) | 1134 rev = repo.changelog.rev(repo.lookup(rev)) |
1135 ff = followfilter() | 1135 ff = followfilter() |
1136 stop = min(revs[0], revs[-1]) | 1136 stop = min(revs[0], revs[-1]) |
1137 for x in xrange(rev, stop-1, -1): | 1137 for x in xrange(rev, stop-1, -1): |
1138 if ff.match(x) and x in wanted: | 1138 if ff.match(x): |
1139 del wanted[x] | 1139 wanted.discard(x) |
1140 | 1140 |
1141 def iterate(): | 1141 def iterate(): |
1142 if follow and not m.files(): | 1142 if follow and not m.files(): |
1143 ff = followfilter(onlyfirst=opts.get('follow_first')) | 1143 ff = followfilter(onlyfirst=opts.get('follow_first')) |
1144 def want(rev): | 1144 def want(rev): |