tests/test-merge-combination.t
changeset 46266 e8b0c519dfb3
parent 46265 8045e4aa366b
child 46267 b9b37418ac7e
equal deleted inserted replaced
46265:8045e4aa366b 46266:e8b0c519dfb3
     1 This file shows what hg says are "modified" files for a merge commit
       
     2 (hg log -T {files}), somewhat exhaustively.
       
     3 It shows merges that involves files contents changing, and merges that
       
     4 involve executable bit changing, but not merges with multiple or zero
       
     5 merge ancestors, nor copies/renames, and nor identical file contents
       
     6 with different filelog revisions.
       
     7 
       
     8   $ . $TESTDIR/testlib/merge-combination-util.sh
       
     9 
       
    10 All the merges of various file contents.
       
    11 
       
    12   $ range () {
       
    13   >   max=0
       
    14   >   for i in $@; do
       
    15   >     if [ $i = - ]; then continue; fi
       
    16   >     if [ $i -gt $max ]; then max=$i; fi
       
    17   >   done
       
    18   >   $TESTDIR/seq.py `expr $max + 1`
       
    19   > }
       
    20   $ isgood () { true; }
       
    21   $ createfile () {
       
    22   >   if [ -f a ] && [ "`cat a`" = $1 ]
       
    23   >   then touch $file
       
    24   >   else echo $v > a
       
    25   >   fi
       
    26   > }
       
    27 
       
    28   $ genmerges
       
    29   1111  : agree on ""
       
    30   1112  : agree on "a"
       
    31   111-  : agree on "a"
       
    32   1121  : agree on "a"
       
    33   1122  : agree on ""
       
    34   1123  : agree on "a"
       
    35   112-  : agree on "a"
       
    36   11-1  : hg said "", expected "a"
       
    37   11-2  : agree on "a"
       
    38   11--  : agree on ""
       
    39   1211  : agree on "a"
       
    40   1212  : agree on ""
       
    41   1213  : agree on "a"
       
    42   121-  : agree on "a"
       
    43   1221  : agree on "a"
       
    44   1222  : agree on ""
       
    45   1223  : agree on "a"
       
    46   122-  : agree on "a"
       
    47   1231 C: agree on "a"
       
    48   1232 C: agree on "a"
       
    49   1233 C: agree on "a"
       
    50   1234 C: agree on "a"
       
    51   123- C: agree on "a"
       
    52   12-1 C: agree on "a"
       
    53   12-2 C: hg said "", expected "a"
       
    54   12-3 C: agree on "a"
       
    55   12-- C: agree on "a"
       
    56   1-11  : hg said "", expected "a"
       
    57   1-12  : agree on "a"
       
    58   1-1-  : agree on ""
       
    59   1-21 C: agree on "a"
       
    60   1-22 C: hg said "", expected "a"
       
    61   1-23 C: agree on "a"
       
    62   1-2- C: agree on "a"
       
    63   1--1  : agree on "a"
       
    64   1--2  : agree on "a"
       
    65   1---  : agree on ""
       
    66   -111  : agree on ""
       
    67   -112  : agree on "a"
       
    68   -11-  : agree on "a"
       
    69   -121 C: agree on "a"
       
    70   -122 C: agree on "a"
       
    71   -123 C: agree on "a"
       
    72   -12- C: agree on "a"
       
    73   -1-1  : agree on ""
       
    74   -1-2  : agree on "a"
       
    75   -1--  : agree on "a"
       
    76   --11  : agree on ""
       
    77   --12  : agree on "a"
       
    78   --1-  : agree on "a"
       
    79   ---1  : agree on "a"
       
    80   ----  : agree on ""
       
    81 
       
    82 All the merges of executable bit.
       
    83 
       
    84   $ range () {
       
    85   >   max=a
       
    86   >   for i in $@; do
       
    87   >     if [ $i = - ]; then continue; fi
       
    88   >     if [ $i > $max ]; then max=$i; fi
       
    89   >   done
       
    90   >   if [ $max = a ]; then echo f; else echo f x; fi
       
    91   > }
       
    92   $ isgood () { case $line in *f*x*) true;; *) false;; esac; }
       
    93   $ createfile () {
       
    94   >   if [ -f a ] && (([ -x a ] && [ $v = x ]) || (! [ -x a ] && [ $v != x ]))
       
    95   >   then touch $file
       
    96   >   else touch a; if [ $v = x ]; then chmod +x a; else chmod -x a; fi
       
    97   >   fi
       
    98   > }
       
    99 
       
   100 #if execbit
       
   101   $ genmerges
       
   102   fffx  : agree on "a"
       
   103   ffxf  : agree on "a"
       
   104   ffxx  : agree on ""
       
   105   ffx-  : agree on "a"
       
   106   ff-x  : hg said "", expected "a"
       
   107   fxff  : hg said "", expected "a"
       
   108   fxfx  : hg said "a", expected ""
       
   109   fxf-  : agree on "a"
       
   110   fxxf  : agree on "a"
       
   111   fxxx  : agree on ""
       
   112   fxx-  : agree on "a"
       
   113   fx-f  : hg said "", expected "a"
       
   114   fx-x  : hg said "", expected "a"
       
   115   fx--  : hg said "", expected "a"
       
   116   f-fx  : agree on "a"
       
   117   f-xf  : agree on "a"
       
   118   f-xx  : hg said "", expected "a"
       
   119   f-x-  : agree on "a"
       
   120   f--x  : agree on "a"
       
   121   -ffx  : agree on "a"
       
   122   -fxf C: agree on "a"
       
   123   -fxx C: hg said "", expected "a"
       
   124   -fx- C: agree on "a"
       
   125   -f-x  : hg said "", expected "a"
       
   126   --fx  : agree on "a"
       
   127 #endif
       
   128 
       
   129 Files modified or cleanly merged, with no greatest common ancestors:
       
   130 
       
   131   $ hg init repo; cd repo
       
   132   $ touch a0 b0; hg commit -qAm 0
       
   133   $ hg up -qr null; touch a1 b1; hg commit -qAm 1
       
   134   $ hg merge -qr 0; rm b*; hg commit -qAm 2
       
   135   $ hg log -r . -T '{files}\n'
       
   136   b0 b1
       
   137   $ cd ../
       
   138   $ rm -rf repo
       
   139 
       
   140 A few cases of criss-cross merges involving deletions (listing all
       
   141 such merges is probably too much). Both gcas contain $files, so we
       
   142 expect the final merge to behave like a merge with a single gca
       
   143 containing $files.
       
   144 
       
   145   $ hg init repo; cd repo
       
   146   $ files="c1 u1 c2 u2"
       
   147   $ touch $files; hg commit -qAm '0 root'
       
   148   $ for f in $files; do echo f > $f; done; hg commit -qAm '1 gca1'
       
   149   $ hg up -qr0; hg revert -qr 1 --all; hg commit -qAm '2 gca2'
       
   150   $ hg up -qr 1; hg merge -qr 2; rm *1; hg commit -qAm '3 p1'
       
   151   $ hg up -qr 2; hg merge -qr 1; rm *2; hg commit -qAm '4 p2'
       
   152   $ hg merge -qr 3; echo f > u1; echo f > u2; rm -f c1 c2
       
   153   $ hg commit -qAm '5 merge with two gcas'
       
   154   $ hg log -r . -T '{files}\n' # expecting u1 u2
       
   155   
       
   156   $ cd ../
       
   157   $ rm -rf repo