comparison mercurial/copies.py @ 16178:828fe2ca7cbb

copies: use ctx.dirs() for directory rename detection
author Matt Mackall <mpm@selenic.com>
date Sun, 26 Feb 2012 16:45:59 -0600
parents b8c1a8a57540
children ad394c897b16
comparison
equal deleted inserted replaced
16177:b8c1a8a57540 16178:828fe2ca7cbb
15 def _dirname(f): 15 def _dirname(f):
16 s = f.rfind("/") 16 s = f.rfind("/")
17 if s == -1: 17 if s == -1:
18 return "" 18 return ""
19 return f[:s] 19 return f[:s]
20
21 def _dirs(files):
22 d = set()
23 for f in files:
24 f = _dirname(f)
25 while f not in d:
26 d.add(f)
27 f = _dirname(f)
28 return d
29 20
30 def _findlimit(repo, a, b): 21 def _findlimit(repo, a, b):
31 """Find the earliest revision that's an ancestor of a or b but not both, 22 """Find the earliest revision that's an ancestor of a or b but not both,
32 None if no such revision exists. 23 None if no such revision exists.
33 """ 24 """
314 return copy, diverge 305 return copy, diverge
315 306
316 repo.ui.debug(" checking for directory renames\n") 307 repo.ui.debug(" checking for directory renames\n")
317 308
318 # generate a directory move map 309 # generate a directory move map
319 d1, d2 = _dirs(m1), _dirs(m2) 310 d1, d2 = c1.dirs(), c2.dirs()
320 invalid = set() 311 invalid = set([""])
321 dirmove = {} 312 dirmove = {}
322 313
323 # examine each file copy for a potential directory move, which is 314 # examine each file copy for a potential directory move, which is
324 # when all the files in a directory are moved to a new directory 315 # when all the files in a directory are moved to a new directory
325 for dst, src in fullcopy.iteritems(): 316 for dst, src in fullcopy.iteritems():