changeset 6425:2d9328a2f81f

copies: skip directory rename checks when not merging The directory rename checks are not meaningful unless we're moving or copying files across a branch during a merge.
author Matt Mackall <mpm@selenic.com>
date Sat, 29 Mar 2008 12:39:47 -0500
parents d8f44384c3ee
children e2c49ef2dd6e
files mercurial/copies.py mercurial/merge.py tests/test-mv-cp-st-diff tests/test-mv-cp-st-diff.out
diffstat 4 files changed, 333 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Sat Mar 29 12:39:47 2008 -0500
+++ b/mercurial/copies.py	Sat Mar 29 12:39:47 2008 -0500
@@ -53,7 +53,7 @@
     old.sort()
     return [o[1] for o in old]
 
-def copies(repo, c1, c2, ca):
+def copies(repo, c1, c2, ca, checkdirs=False):
     """
     Find moves and copies between context c1 and c2
     """
@@ -104,9 +104,6 @@
             elif of in ma:
                 diverge.setdefault(of, []).append(f)
 
-    if not repo.ui.configbool("merge", "followcopies", True):
-        return {}, {}
-
     repo.ui.debug(_("  searching for copies back to rev %d\n") % limit)
 
     u1 = _nonoverlap(m1, m2, ma)
@@ -140,7 +137,7 @@
             repo.ui.debug(_("   %s -> %s %s\n") % (f, fullcopy[f], note))
     del diverge2
 
-    if not fullcopy or not repo.ui.configbool("merge", "followdirs", True):
+    if not fullcopy or not checkdirs:
         return copy, diverge
 
     repo.ui.debug(_("  checking for directory renames\n"))
@@ -187,7 +184,8 @@
             for d in dirmove:
                 if f.startswith(d):
                     # new file added in a directory that was moved, move it
-                    copy[f] = dirmove[d] + f[len(d):]
+                    df = dirmove[d] + f[len(d):]
+                    copy[f] = df
                     repo.ui.debug(_("  file %s -> %s\n") % (f, copy[f]))
                     break
 
--- a/mercurial/merge.py	Sat Mar 29 12:39:47 2008 -0500
+++ b/mercurial/merge.py	Sat Mar 29 12:39:47 2008 -0500
@@ -101,7 +101,9 @@
         action.append((f, m) + args)
 
     if pa and not (backwards or overwrite):
-        copy, diverge = copies.copies(repo, p1, p2, pa)
+        if repo.ui.configbool("merge", "followcopies", True):
+            dirs = repo.ui.configbool("merge", "followdirs", True)
+            copy, diverge = copies.copies(repo, p1, p2, pa, dirs)
         copied = dict.fromkeys(copy.values())
         for of, fl in diverge.items():
             act("divergent renames", "dr", of, fl)
--- a/tests/test-mv-cp-st-diff	Sat Mar 29 12:39:47 2008 -0500
+++ b/tests/test-mv-cp-st-diff	Sat Mar 29 12:39:47 2008 -0500
@@ -11,12 +11,17 @@
 # set up a boring main branch
 add a a
 hg add a
+mkdir x
+add x/x x
+hg add x/x
 hg ci -m0
 
 add a m1
 hg ci -m1
 
 add a m2
+add x/y y1
+hg add x/y
 hg ci -m2
 
 show()
@@ -59,6 +64,7 @@
     echo
 }
 
+
 tb "add a a1" "add a a2" "hg mv a b" "rename in working dir"
 tb "add a a1" "add a a2" "hg cp a b" "copy in working dir" 
 tb "hg mv a b" "add b b1" "add b w" "single rename"
@@ -66,3 +72,5 @@
 tb "hg mv a b" "hg mv b c" "hg mv c d" "rename chain"
 tb "hg cp a b" "hg cp b c" "hg cp c d" "copy chain"
 tb "add a a1" "hg mv a b" "hg mv b a" "circular rename"
+
+tb "hg mv x y" "add y/x x1" "add y/x x2" "directory move"
--- a/tests/test-mv-cp-st-diff.out	Sat Mar 29 12:39:47 2008 -0500
+++ b/tests/test-mv-cp-st-diff.out	Sat Mar 29 12:39:47 2008 -0500
@@ -30,6 +30,7 @@
 A b
   a
 R a
+R x/y
 
 diff --git a/a b/b
 rename from a
@@ -43,6 +44,12 @@
 +0
 +a1
 +a2
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 M a
@@ -70,6 +77,7 @@
 
 - branch to parent: --rev 2 --rev .
 M a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -81,9 +89,16 @@
 +0
 +a1
 +a2
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 M a
+A x/y
 
 diff --git a/a b/a
 --- a/a
@@ -95,6 +110,12 @@
 -a2
 +m1
 +m2
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -136,6 +157,7 @@
 M a
 A b
   a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -159,6 +181,12 @@
 +1
 +a1
 +a2
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 M a
@@ -186,6 +214,7 @@
 
 - branch to parent: --rev 2 --rev .
 M a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -197,9 +226,16 @@
 +1
 +a1
 +a2
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 M a
+A x/y
 
 diff --git a/a b/a
 --- a/a
@@ -211,6 +247,12 @@
 -a2
 +m1
 +m2
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -248,6 +290,7 @@
 A b
   a
 R a
+R x/y
 
 diff --git a/a b/b
 rename from a
@@ -261,6 +304,12 @@
 +2
 +b1
 +w
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 A b
@@ -296,6 +345,7 @@
 A b
   a
 R a
+R x/y
 
 diff --git a/a b/b
 rename from a
@@ -308,10 +358,17 @@
 -m2
 +2
 +b1
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 A a
   b
+A x/y
 R b
 
 diff --git a/b b/a
@@ -325,6 +382,12 @@
 -b1
 +m1
 +m2
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -367,6 +430,7 @@
 M a
 A b
   a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -388,6 +452,12 @@
 -m2
 +3
 +b1
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 M a
@@ -433,6 +503,7 @@
 M a
 A b
   a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -453,9 +524,16 @@
 -m2
 +3
 +b1
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 M a
+A x/y
 R b
 
 diff --git a/a b/a
@@ -474,6 +552,12 @@
 -a
 -3
 -b1
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -506,6 +590,7 @@
 A d
   a
 R a
+R x/y
 
 diff --git a/a b/d
 rename from a
@@ -517,6 +602,12 @@
 -m1
 -m2
 +4
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 A c
@@ -550,6 +641,7 @@
 A c
   a
 R a
+R x/y
 
 diff --git a/a b/c
 rename from a
@@ -561,10 +653,17 @@
 -m1
 -m2
 +4
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 A a
   c
+A x/y
 R c
 
 diff --git a/c b/a
@@ -577,6 +676,12 @@
 -4
 +m1
 +m2
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -638,6 +743,7 @@
   a
 A d
   a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -677,6 +783,12 @@
 -m1
 -m2
 +5
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 M a
@@ -740,6 +852,7 @@
   a
 A c
   a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -769,9 +882,16 @@
 -m1
 -m2
 +5
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 M a
+A x/y
 R b
 R c
 
@@ -797,6 +917,12 @@
 @@ -1,2 +0,0 @@
 -a
 -5
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
 created new head
@@ -824,6 +950,7 @@
 
 - working to branch: --rev 2
 M a
+R x/y
 
 diff --git a/a b/a
 --- a/a
@@ -834,6 +961,12 @@
 -m2
 +6
 +a1
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - root to parent: --rev 0 --rev .
 A b
@@ -869,6 +1002,7 @@
 A b
   a
 R a
+R x/y
 
 diff --git a/a b/b
 rename from a
@@ -881,10 +1015,17 @@
 -m2
 +6
 +a1
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
 
 - parent to branch: --rev . --rev 2
 A a
   b
+A x/y
 R b
 
 diff --git a/b b/a
@@ -898,5 +1039,182 @@
 -a1
 +m1
 +m2
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
 
 
+created new head
+moving x/x to y/x
+** directory move **
+** hg mv x y / add y/x x1 / add y/x x2
+- working to parent: 
+M y/x
+
+diff --git a/y/x b/y/x
+--- a/y/x
++++ b/y/x
+@@ -1,2 +1,3 @@
+ x
+ x1
++x2
+
+- working to root: --rev 0
+M a
+A y/x
+  x/x
+R x/x
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,1 +1,2 @@
+ a
++7
+diff --git a/x/x b/y/x
+rename from x/x
+rename to y/x
+--- a/x/x
++++ b/y/x
+@@ -1,1 +1,3 @@
+ x
++x1
++x2
+
+- working to branch: --rev 2
+M a
+A y/x
+  x/x
+R x/x
+R x/y
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,3 +1,2 @@
+ a
+-m1
+-m2
++7
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
+diff --git a/x/x b/y/x
+rename from x/x
+rename to y/x
+--- a/x/x
++++ b/y/x
+@@ -1,1 +1,3 @@
+ x
++x1
++x2
+
+- root to parent: --rev 0 --rev .
+M a
+A y/x
+  x/x
+R x/x
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,1 +1,2 @@
+ a
++7
+diff --git a/x/x b/y/x
+rename from x/x
+rename to y/x
+--- a/x/x
++++ b/y/x
+@@ -1,1 +1,2 @@
+ x
++x1
+
+- parent to root: --rev . --rev 0
+M a
+A x/x
+  y/x
+R y/x
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,2 +1,1 @@
+ a
+-7
+diff --git a/y/x b/x/x
+rename from y/x
+rename to x/x
+--- a/y/x
++++ b/x/x
+@@ -1,2 +1,1 @@
+ x
+-x1
+
+- branch to parent: --rev 2 --rev .
+M a
+A y/x
+  x/x
+R x/x
+R x/y
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,3 +1,2 @@
+ a
+-m1
+-m2
++7
+diff --git a/x/y b/x/y
+deleted file mode 100644
+--- a/x/y
++++ /dev/null
+@@ -1,1 +0,0 @@
+-y1
+diff --git a/x/x b/y/x
+rename from x/x
+rename to y/x
+--- a/x/x
++++ b/y/x
+@@ -1,1 +1,2 @@
+ x
++x1
+
+- parent to branch: --rev . --rev 2
+M a
+A x/x
+  y/x
+A x/y
+R y/x
+
+diff --git a/a b/a
+--- a/a
++++ b/a
+@@ -1,2 +1,3 @@
+ a
+-7
++m1
++m2
+diff --git a/y/x b/x/x
+rename from y/x
+rename to x/x
+--- a/y/x
++++ b/x/x
+@@ -1,2 +1,1 @@
+ x
+-x1
+diff --git a/x/y b/x/y
+new file mode 100644
+--- /dev/null
++++ b/x/y
+@@ -0,0 +1,1 @@
++y1
+
+