# t470 --- rcsmerge -p -kk
#
# Copyright (C) 2010-2022 Thien-Thi Nguyen
#
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

. $srcdir/common
. $srcdir/common-kn
split_std_out_err no
$hey echo '                                    -*- org -*-'

prep_b_comparison
must 'cp `bundled_commav b.d/1612.cou` $w'

##
# Check "rcsmerge -p -kk".
##

muck='rcsmerge -p -kk'

##
# * Check some invalid-input cases.  We mix in ‘-z’, ‘-T’ and ‘-V’
#   for coverage, mostly -- they are no-op here.
##

$muck -zLT -T $v \
    && problem 'rcsmerge did not fail for missing base revision number'

$muck -V3 $w $v \
    && problem 'rcsmerge did not fail for missing base revision number'

$muck -V4 r2 $w $v \
    && problem 'rcsmerge did not fail for bad revision number'

##
# * Check some valid-input cases.
##

must '$muck -r $w $v > $actual'
expected=$w
normalize_b_and_diff "$muck -r $w $v"

conflicted ()
{
    # $1 -- rev1
    # $2 -- rev2
    # $3 -- STEM for fake/b.d/STEM.cou
    # $4 -- expected output
    cmd="$muck -r$1 -r$2"
    echo "$4" | sed '1d;s/^|//;s/|$//' > $expected

    must "cp -f `bundled_commav b.d/$3.cou` $w"
    $cmd $w $v > $actual
    test 1 = $? || problem "no conflicts detected: $cmd"
    normalize_b_and_diff "$cmd"
}

expected=$wd/expected

conflicted 1.3 1.1.1.5 1612 '
|<<<<<<< t470.d/x|
|wow, rcs!$Revision: 1.6.1.2 $YES! HMMM THIS SHOULD BE NAMED "ZOW"!|
||
|;; $Author: ttn $|
|;; $Date: 2010/10/21 22:48:48 $|
|;; $Header: /home/ttn/build/GNU/rcs/tests/fake/b,v 1.6.1.2 2010/10/21 22:48:48 ttn Exp $|
|;; $Id: b,v 1.6.1.2 2010/10/21 22:48:48 ttn Exp $|
|;; $Locker:  $|
|;; $Name:  $|
|;; $RCSfile: b,v $|
|;; $Revision: 1.6.1.2 $|
|;; $Source: /home/ttn/build/GNU/rcs/tests/fake/b,v $|
|;; $State: Exp $|
|;; $Log: b,v $|
|;; Revision 1.6.1.2  2010/10/21 22:48:48  ttn|
|;; Add a name.|
|;;|
|;; Revision 1.6.1.1  2010/05/05 12:18:30  ttn|
|;; This should in theory go to 1.6.1.1.|
|;;|
|;; Revision 1.6  2010/04/12 12:16:58  ttn|
|;; Add $Revision with pre and suffix.|
|;;|
|;; Revision 1.5  2010/03/30 09:46:50  ttn|
|;; Add text after Log block.|
|;;|
|;; Revision 1.4  2010/03/30 09:46:24  zurg|
|;; Add "earthlings".|
|;;|
|;; Revision 1.3  2010/03/30 09:45:42  zurg|
|;; Add "greetings".|
|;;|
|;; Revision 1.2  2010/03/30 09:45:02  ttn|
|;; Add empty headers.|
|;;|
|;; Here is some trailing text|
|greetings|
|earthlings|
|=======|
|$Author$|
||
|$Date$|
||
|$Header$|
||
|$Id$|
||
|$Locker$|
||
|$Log$|
|Revision 1.1.1.5  2010/03/18 06:21:03  ttn|
|WOW is 1.1.1.5! (+ sorted kw)|
||
||
|$Name$|
||
|$RCSfile$|
||
|$Revision$|
||
|$Source$|
||
|$State$|
||
|>>>>>>> 1.1.1.5|'

conflicted 1.6.1.1 1.6.1.2 1612 '
|<<<<<<< t470.d/x|
|wow, rcs!$Revision: 1.6.1.2 $YES! HMMM THIS SHOULD BE NAMED "ZOW"!|
|=======|
|wow, rcs!$Revision$YES! HMMM THIS SHOULD BE NAMED "ZOW"!|
|>>>>>>> 1.6.1.2|
||
|<<<<<<< t470.d/x|
|;; $Author: ttn $|
|;; $Date: 2010/10/21 22:48:48 $|
|;; $Header: /home/ttn/build/GNU/rcs/tests/fake/b,v 1.6.1.2 2010/10/21 22:48:48 ttn Exp $|
|;; $Id: b,v 1.6.1.2 2010/10/21 22:48:48 ttn Exp $|
|;; $Locker:  $|
|;; $Name:  $|
|;; $RCSfile: b,v $|
|;; $Revision: 1.6.1.2 $|
|;; $Source: /home/ttn/build/GNU/rcs/tests/fake/b,v $|
|;; $State: Exp $|
|;; $Log: b,v $|
|;; Revision 1.6.1.2  2010/10/21 22:48:48  ttn|
|;; Add a name.|
|;;|
|=======|
|;; $Author$|
|;; $Date$|
|;; $Header$|
|;; $Id$|
|;; $Locker$|
|;; $Name$|
|;; $RCSfile$|
|;; $Revision$|
|;; $Source$|
|;; $State$|
|;; $Log$|
|;; Revision 1.6.1.2  2010/10/21 22:48:48  ttn|
|;; Add a name.|
|;;|
|>>>>>>> 1.6.1.2|
|;; Revision 1.6.1.1  2010/05/05 12:18:30  ttn|
|;; This should in theory go to 1.6.1.1.|
|;;|
|;; Revision 1.6  2010/04/12 12:16:58  ttn|
|;; Add $Revision with pre and suffix.|
|;;|
|;; Revision 1.5  2010/03/30 09:46:50  ttn|
|;; Add text after Log block.|
|;;|
|;; Revision 1.4  2010/03/30 09:46:24  zurg|
|;; Add "earthlings".|
|;;|
|;; Revision 1.3  2010/03/30 09:45:42  zurg|
|;; Add "greetings".|
|;;|
|;; Revision 1.2  2010/03/30 09:45:02  ttn|
|;; Add empty headers.|
|;;|
|;; Here is some trailing text|
|greetings|
|earthlings|'

conflicted 1.9 1.1 15 '
|<<<<<<< t470.d/x|
|;; $Author: ttn $|
|;; $Date: 2010/03/30 09:46:50 $|
|;; $Header: /home/ttn/build/GNU/rcs/tests/fake/b,v 1.5 2010/03/30 09:46:50 ttn Exp $|
|;; $Id: b,v 1.5 2010/03/30 09:46:50 ttn Exp $|
|;; $Locker:  $|
|;; $Name:  $|
|;; $RCSfile: b,v $|
|;; $Revision: 1.5 $|
|;; $Source: /home/ttn/build/GNU/rcs/tests/fake/b,v $|
|;; $State: Exp $|
|;; $Log: b,v $|
|;; Revision 1.5  2010/03/30 09:46:50  ttn|
|;; Add text after Log block.|
|;;|
|;; Revision 1.4  2010/03/30 09:46:24  zurg|
|;; Add "earthlings".|
|;;|
|;; Revision 1.3  2010/03/30 09:45:42  zurg|
|;; Add "greetings".|
|;;|
|;; Revision 1.2  2010/03/30 09:45:02  ttn|
|;; Add empty headers.|
|;;|
|;; Here is some trailing text|
|greetings|
|earthlings|
|=======|
|>>>>>>> 1.1|'

exit 0

# t470 ends here
