Mercurial > hg
changeset 4397:9fe267f77f56
merge: fix a bug detecting directory moves
When all the files in a directory are moved, it may be incorrectly marked as moved even if it contains subdirectories.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 03 May 2007 17:24:43 -0500 |
parents | c04c96504a12 |
children | 3b7e284b8f28 |
files | mercurial/merge.py |
diffstat | 1 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Thu May 03 17:24:43 2007 -0500 +++ b/mercurial/merge.py Thu May 03 17:24:43 2007 -0500 @@ -102,6 +102,21 @@ Find moves and copies between m1 and m2 back to limit linkrev """ + def dirname(f): + s = f.rfind("/") + if s == -1: + return "" + return f[:s] + + def dirs(files): + d = {} + for f in files: + f = dirname(f) + while f not in d: + d[f] = True + f = dirname(f) + return d + def findold(fctx): "find files that path was copied from, back to linkrev limit" old = {} @@ -146,12 +161,6 @@ continue copy[c.path()] = of - def dirs(files): - d = {} - for f in files: - d[os.path.dirname(f)] = True - return d - if not repo.ui.configbool("merge", "followcopies", True): return {} @@ -183,7 +192,7 @@ # examine each file copy for a potential directory move, which is # when all the files in a directory are moved to a new directory for dst, src in fullcopy.items(): - dsrc, ddst = os.path.dirname(src), os.path.dirname(dst) + dsrc, ddst = dirname(src), dirname(dst) if dsrc in invalid: # already seen to be uninteresting continue