diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -341,7 +341,7 @@ def updatedir(ui, repo, patches, wlock=N if not patches: return copies = [] - removes = [] + removes = {} cfiles = patches.keys() cwd = repo.getcwd() if cwd: @@ -350,16 +350,18 @@ def updatedir(ui, repo, patches, wlock=N ctype, gp = patches[f] if ctype == 'RENAME': copies.append((gp.oldpath, gp.path, gp.copymod)) - removes.append(gp.oldpath) + removes[gp.oldpath] = 1 elif ctype == 'COPY': copies.append((gp.oldpath, gp.path, gp.copymod)) elif ctype == 'DELETE': - removes.append(gp.path) + removes[gp.path] = 1 for src, dst, after in copies: if not after: copyfile(src, dst, repo.root) repo.copy(src, dst, wlock=wlock) + removes = removes.keys() if removes: + removes.sort() repo.remove(removes, True, wlock=wlock) for f in patches: ctype, gp = patches[f] diff --git a/tests/test-git-import b/tests/test-git-import --- a/tests/test-git-import +++ b/tests/test-git-import @@ -127,3 +127,19 @@ EOF hg locate copy2 hg cat rename2 + +echo % one file renamed multiple times +hg import -mmultirenames - <<EOF +diff --git a/rename2 b/rename3 +rename from rename2 +rename to rename3 +diff --git a/rename2 b/rename3-2 +rename from rename2 +rename to rename3-2 +EOF +hg log -vCr. --template '{rev} {files} / {file_copies%filecopy}\n' + +hg locate rename2 rename3 rename3-2 +hg cat rename3 +echo +hg cat rename3-2 diff --git a/tests/test-git-import.out b/tests/test-git-import.out --- a/tests/test-git-import.out +++ b/tests/test-git-import.out @@ -37,3 +37,20 @@ a b c a +% one file renamed multiple times +applying patch from stdin +9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2) +rename2: No such file or directory +rename3 +rename3-2 +a +a +b +c +a + +a +a +b +c +a