changeset 4115:c95060a5391a

merge: fix renaming of subdirectories under renamed directories
author Matt Mackall <mpm@selenic.com>
date Tue, 27 Feb 2007 16:20:06 -0600
parents f5f171785e29
children bb70d5fa02ae 306055f5b65c
files mercurial/merge.py tests/test-rename-dir-merge2 tests/test-rename-dir-merge2.out
diffstat 3 files changed, 52 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Sat Feb 17 09:54:44 2007 +0100
+++ b/mercurial/merge.py	Tue Feb 27 16:20:06 2007 -0600
@@ -184,7 +184,7 @@
             invalid[dsrc] = True
             del dirmove[dsrc]
         else:
-            dirmove[dsrc] = ddst
+            dirmove[dsrc + "/"] = ddst + "/"
 
     del d1, d2, invalid
 
@@ -194,9 +194,10 @@
     # check unaccounted nonoverlapping files
     for f in u1 + u2:
         if f not in fullcopy:
-            d = os.path.dirname(f)
-            if d in dirmove:
-                copy[f] = dirmove[d] + "/" + os.path.basename(f)
+            for d in dirmove:
+                if f.startswith(d):
+                    copy[f] = dirmove[d] + f[len(d):]
+                    break
 
     return copy
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-rename-dir-merge2	Tue Feb 27 16:20:06 2007 -0600
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+mkdir r1
+cd r1
+hg init
+mkdir a
+echo foo > a/f
+hg add a
+hg ci -m "a/f == foo"
+cd ..
+
+hg clone r1 r2
+cd r2
+hg mv a b
+echo foo1 > b/f
+hg ci -m" a -> b, b/f == foo1"
+cd ..
+
+cd r1
+mkdir a/aa
+echo bar > a/aa/g
+hg add a/aa
+hg ci -m "a/aa/g"
+hg pull ../r2
+
+hg merge
+
+hg st -C
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-rename-dir-merge2.out	Tue Feb 27 16:20:06 2007 -0600
@@ -0,0 +1,19 @@
+adding a/f
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+copying a/f to b/f
+removing a/f
+adding a/aa/g
+pulling from ../r2
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files (+1 heads)
+(run 'hg heads' to see heads, 'hg merge' to merge)
+2 files updated, 0 files merged, 1 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+M b/f
+A b/aa/g
+  a/aa/g
+R a/aa/g
+R a/f