##// END OF EJS Templates
copies: use set instead of dict
Benoit Boissinot -
r8468:b35d11d1 default
parent child Browse files
Show More
@@ -20,18 +20,18 b' def _dirname(f):'
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:
@@ -39,7 +39,7 b' def _findoldnames(fctx, limit):'
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:
@@ -184,7 +184,7 b' def copies(repo, c1, c2, ca, checkdirs=F'
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
@@ -196,13 +196,13 b' def copies(repo, c1, c2, ca, checkdirs=F'
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 + "/"
General Comments 0
You need to be logged in to leave comments. Login now