comparison mercurial/copies.py @ 8468:b35d11d10646

copies: use set instead of dict
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sun, 17 May 2009 04:20:59 +0200
parents 0e73e21d81ff
children f9a80054dd3c
comparison
equal deleted inserted replaced
8467:9890151a7f30 8468:b35d11d10646
18 if s == -1: 18 if s == -1:
19 return "" 19 return ""
20 return f[:s] 20 return f[:s]
21 21
22 def _dirs(files): 22 def _dirs(files):
23 d = {} 23 d = set()
24 for f in files: 24 for f in files:
25 f = _dirname(f) 25 f = _dirname(f)
26 while f not in d: 26 while f not in d:
27 d[f] = True 27 d.add(f)
28 f = _dirname(f) 28 f = _dirname(f)
29 return d 29 return d
30 30
31 def _findoldnames(fctx, limit): 31 def _findoldnames(fctx, limit):
32 "find files that path was copied from, back to linkrev limit" 32 "find files that path was copied from, back to linkrev limit"
33 old = {} 33 old = {}
34 seen = {} 34 seen = set()
35 orig = fctx.path() 35 orig = fctx.path()
36 visit = [(fctx, 0)] 36 visit = [(fctx, 0)]
37 while visit: 37 while visit:
38 fc, depth = visit.pop() 38 fc, depth = visit.pop()
39 s = str(fc) 39 s = str(fc)
40 if s in seen: 40 if s in seen:
41 continue 41 continue
42 seen[s] = 1 42 seen.add(s)
43 if fc.path() != orig and fc.path() not in old: 43 if fc.path() != orig and fc.path() not in old:
44 old[fc.path()] = (depth, fc.path()) # remember depth 44 old[fc.path()] = (depth, fc.path()) # remember depth
45 if fc.rev() < limit and fc.rev() is not None: 45 if fc.rev() < limit and fc.rev() is not None:
46 continue 46 continue
47 visit += [(p, depth - 1) for p in fc.parents()] 47 visit += [(p, depth - 1) for p in fc.parents()]
182 182
183 repo.ui.debug(_(" checking for directory renames\n")) 183 repo.ui.debug(_(" checking for directory renames\n"))
184 184
185 # generate a directory move map 185 # generate a directory move map
186 d1, d2 = _dirs(m1), _dirs(m2) 186 d1, d2 = _dirs(m1), _dirs(m2)
187 invalid = {} 187 invalid = set()
188 dirmove = {} 188 dirmove = {}
189 189
190 # examine each file copy for a potential directory move, which is 190 # examine each file copy for a potential directory move, which is
191 # when all the files in a directory are moved to a new directory 191 # when all the files in a directory are moved to a new directory
192 for dst, src in fullcopy.iteritems(): 192 for dst, src in fullcopy.iteritems():
194 if dsrc in invalid: 194 if dsrc in invalid:
195 # already seen to be uninteresting 195 # already seen to be uninteresting
196 continue 196 continue
197 elif dsrc in d1 and ddst in d1: 197 elif dsrc in d1 and ddst in d1:
198 # directory wasn't entirely moved locally 198 # directory wasn't entirely moved locally
199 invalid[dsrc] = True 199 invalid.add(dsrc)
200 elif dsrc in d2 and ddst in d2: 200 elif dsrc in d2 and ddst in d2:
201 # directory wasn't entirely moved remotely 201 # directory wasn't entirely moved remotely
202 invalid[dsrc] = True 202 invalid.add(dsrc)
203 elif dsrc in dirmove and dirmove[dsrc] != ddst: 203 elif dsrc in dirmove and dirmove[dsrc] != ddst:
204 # files from the same directory moved to two different places 204 # files from the same directory moved to two different places
205 invalid[dsrc] = True 205 invalid.add(dsrc)
206 else: 206 else:
207 # looks good so far 207 # looks good so far
208 dirmove[dsrc + "/"] = ddst + "/" 208 dirmove[dsrc + "/"] = ddst + "/"
209 209
210 for i in invalid: 210 for i in invalid: