Patchwork [12,of,14] tests: better test coverage of merges of flags

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 13, 2013, 7:02 p.m.
Message ID <0261266356f25c23224b.1358103767@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/587/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Headers show

Comments

Mads Kiilerich - Jan. 13, 2013, 7:02 p.m.
# HG changeset patch
# User Mads Kiilerich <mads@kiilerich.com>
# Date 1358102812 -3600
# Node ID 0261266356f25c23224b09de6aebbb2c39c9c242
# Parent  1f39ee198f6a290827b1dc4b5eb0ae39db752bcb
tests: better test coverage of merges of flags

This makes existing problems with merges of symlinks and files more obvious and
add test coverage for tricky merges without real common ancestors.

Patch

diff --git a/tests/test-flags.t b/tests/test-flags.t
--- a/tests/test-flags.t
+++ b/tests/test-flags.t
@@ -81,6 +81,9 @@  the changelog should mention file a:
   resolving manifests
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
+  $ cat a
+  123
+  $ [ -x a ]
 
   $ cd ../test3
   $ echo 123 >>b
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -1,21 +1,34 @@ 
   $ "$TESTDIR/hghave" symlink execbit || exit 80
 
-  $ hg init
+  $ tellmeabout() {
+  > if [ -h $1 ]; then
+  >     echo $1 is a symlink:
+  >     $TESTDIR/readlink.py $1
+  > elif [ -x $1 ]; then
+  >     echo $1 is an executable file with content:
+  >     cat $1
+  > else
+  >     echo $1 is a plain file with content:
+  >     cat $1
+  > fi
+  > }
+
+  $ hg init test1
+  $ cd test1
 
   $ echo a > a
-  $ hg ci -Amadd
-  adding a
-
+  $ hg ci -Aqmadd
   $ chmod +x a
   $ hg ci -mexecutable
 
-  $ hg up 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg up -q 0
   $ rm a
   $ ln -s symlink a
   $ hg ci -msymlink
   created new head
 
+Symlink is local parent, executable is other:
+
   $ hg merge --debug
     searching for copies back to rev 1
   resolving manifests
@@ -28,18 +41,11 @@ 
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
+  $ tellmeabout a
+  a is a plain file with content:
+  symlink (no-eol)
 
-Symlink is local parent, executable is other:
-
-  $ if [ -h a ]; then
-  >     echo a is a symlink
-  >     $TESTDIR/readlink.py a
-  > elif [ -x a ]; then
-  >     echo a is executable
-  > else
-  >     echo "a has no flags (default for conflicts)"
-  > fi
-  a has no flags (default for conflicts)
+Symlink is other parent, executable is local:
 
   $ hg update -C 1
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -57,18 +63,9 @@  Symlink is local parent, executable is o
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
 
-
-Symlink is other parent, executable is local:
-
-  $ if [ -h a ]; then
-  >    echo a is a symlink
-  >    $TESTDIR/readlink.py a
-  > elif [ -x a ]; then
-  >     echo a is executable
-  > else
-  >     echo "a has no flags (default for conflicts)"
-  > fi
-  a has no flags (default for conflicts)
+  $ tellmeabout a
+  a is a plain file with content:
+  symlink (no-eol)
 
 Update to link without local change should get us a symlink (issue3316):
 
@@ -80,8 +77,7 @@  Update to link without local change shou
 
 Update to link with local change should cause a merge prompt (issue3200):
 
-  $ hg up -C 0
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg up -Cq 0
   $ echo data > a
   $ HGMERGE= hg up -y --debug
     searching for copies back to rev 2
@@ -108,3 +104,228 @@  Update to link with local change should 
   +data
 
 
+Test only 'l' change - happens rarely, except when recovering from situations
+where that was what happened.
+
+  $ hg init test2
+  $ cd test2
+  $ printf base > f
+  $ hg ci -Aqm0
+  $ echo file > f
+  $ echo content >> f
+  $ hg ci -qm1
+  $ hg up -qr0
+  $ rm f
+  $ ln -s base f
+  $ hg ci -qm2
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ tellmeabout f
+  f is a symlink:
+  f -> file
+  content
+  
+
+  $ hg up -Cqr1
+  $ hg merge
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ tellmeabout f
+  f is a plain file with content:
+  file
+  content
+
+  $ cd ..
+
+Test removed 'x' flag merged with change to symlink
+
+  $ hg init test3
+  $ cd test3
+  $ echo f > f
+  $ chmod +x f
+  $ hg ci -Aqm0
+  $ chmod -x f
+  $ hg ci -qm1
+  $ hg up -qr0
+  $ rm f
+  $ ln -s dangling f
+  $ hg ci -qm2
+  $ hg merge
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ tellmeabout f
+  f is a symlink:
+  f -> dangling
+
+  $ hg up -Cqr1
+  $ hg merge
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ tellmeabout f
+  f is a symlink:
+  f -> dangling
+
+  $ cd ..
+
+Test merge with no common ancestor:
+a: just different
+b: x vs -, different (cannot calculate x, cannot ask merge tool)
+c: x vs -, same (cannot calculate x, merge tool is no good)
+d: x vs l, different
+e: x vs l, same
+f: - vs l, different
+g: - vs l, same
+h: l vs l, different
+(where same means the filelog entry is shared and there thus is an ancestor!)
+
+  $ hg init test4
+  $ cd test4
+  $ echo 0 > 0
+  $ hg ci -Aqm0
+
+  $ echo 1 > a
+  $ echo 1 > b
+  $ chmod +x b
+  $ echo x > c
+  $ chmod +x c
+  $ echo 1 > d
+  $ chmod +x d
+  $ printf x > e
+  $ chmod +x e
+  $ echo 1 > f
+  $ printf x > g
+  $ ln -s 1 h
+  $ hg ci -qAm1
+
+  $ hg up -qr0
+  $ echo 2 > a
+  $ echo 2 > b
+  $ echo x > c
+  $ ln -s 2 d
+  $ ln -s x e
+  $ ln -s 2 f
+  $ ln -s x g
+  $ ln -s 2 h
+  $ hg ci -Aqm2
+
+  $ hg merge
+   conflicting flags for e
+  (n)one, e(x)ec or sym(l)ink? n
+   conflicting flags for d
+  (n)one, e(x)ec or sym(l)ink? n
+  merging a
+  warning: conflicts during merge.
+  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging b
+  warning: conflicts during merge.
+  merging b incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging d
+  warning: internal:merge cannot merge symlinks for d
+  merging d incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging f
+  warning: internal:merge cannot merge symlinks for f
+  merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging h
+  warning: internal:merge cannot merge symlinks for h
+  merging h incomplete! (edit conflicts, then use 'hg resolve --mark')
+  2 files updated, 0 files merged, 0 files removed, 5 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  [1]
+  $ hg resolve -l
+  U a
+  U b
+  U d
+  U f
+  U h
+  $ tellmeabout a
+  a is a plain file with content:
+  <<<<<<< local
+  2
+  =======
+  1
+  >>>>>>> other
+  $ tellmeabout b
+  b is an executable file with content:
+  <<<<<<< local
+  2
+  =======
+  1
+  >>>>>>> other
+  $ tellmeabout c
+  c is an executable file with content:
+  x
+  $ tellmeabout d
+  d is a plain file with content:
+  2 (no-eol)
+  $ tellmeabout e
+  e is a plain file with content:
+  x (no-eol)
+  $ tellmeabout f
+  f is a symlink:
+  f -> 2
+  $ tellmeabout g
+  g is a symlink:
+  g -> x
+  $ tellmeabout h
+  h is a symlink:
+  h -> 2
+
+  $ hg up -Cqr1
+  $ hg merge
+   conflicting flags for e
+  (n)one, e(x)ec or sym(l)ink? n
+   conflicting flags for d
+  (n)one, e(x)ec or sym(l)ink? n
+  merging a
+  warning: conflicts during merge.
+  merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging b
+  warning: conflicts during merge.
+  merging b incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging d
+  warning: internal:merge cannot merge symlinks for d
+  merging d incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging f
+  warning: internal:merge cannot merge symlinks for f
+  merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
+  merging h
+  warning: internal:merge cannot merge symlinks for h
+  merging h incomplete! (edit conflicts, then use 'hg resolve --mark')
+  1 files updated, 0 files merged, 0 files removed, 5 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  [1]
+  $ tellmeabout a
+  a is a plain file with content:
+  <<<<<<< local
+  1
+  =======
+  2
+  >>>>>>> other
+  $ tellmeabout b
+  b is an executable file with content:
+  <<<<<<< local
+  1
+  =======
+  2
+  >>>>>>> other
+  $ tellmeabout c
+  c is an executable file with content:
+  x
+  $ tellmeabout d
+  d is a plain file with content:
+  1
+  $ tellmeabout e
+  e is a plain file with content:
+  x (no-eol)
+  $ tellmeabout f
+  f is a plain file with content:
+  1
+  $ tellmeabout g
+  g is a plain file with content:
+  x (no-eol)
+  $ tellmeabout h
+  h is a symlink:
+  h -> 1
+
+  $ cd ..