From fanf@dotat.at  Mon Jan 22 15:24:24 2001
Return-Path: <fanf@dotat.at>
Received: from hand.dotat.at (sfo-gw.covalent.net [207.44.198.62])
	by hub.freebsd.org (Postfix) with ESMTP id F0E3B37B6BC
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 22 Jan 2001 15:24:23 -0800 (PST)
Received: from fanf by hand.dotat.at with local (Exim 3.15 #3)
	id 14KqJc-000311-00
	for FreeBSD-gnats-submit@freebsd.org; Mon, 22 Jan 2001 23:24:00 +0000
Message-Id: <E14KqJc-000311-00@hand.dotat.at>
Date: Mon, 22 Jan 2001 23:24:00 +0000
From: Tony Finch <dot@dotat.at>
Reply-To: Tony Finch <dot@dotat.at>
To: FreeBSD-gnats-submit@freebsd.org
Subject: local ident strings interfere with mergemaster
X-Send-Pr-Version: 3.2

>Number:         24564
>Category:       bin
>Synopsis:       local ident strings interfere with mergemaster
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 22 15:30:02 PST 2001
>Closed-Date:    Mon Mar 5 12:36:12 PST 2001
>Last-Modified:  Mon Mar 05 12:37:23 PST 2001
>Originator:     Tony Finch
>Release:        FreeBSD 4.2-BETA-20001113 i386
>Organization:
Covalent Technologies Inc.
>Environment:

FreeBSD hand.dotat.at 4.2-BETA-20001113 FreeBSD 4.2-BETA-20001113 #0: Tue Nov 14 00:42:35 UTC 2000     fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/releng4/sys/DELL-Latitude-CPx  i386

>Description:

Mergemaster has a "non-strict comparison" facility for ignoring
local changes to files if the cvs idents have not been changed from
the standard version of the file. This makes mergemaster runs much
less time-consuming.

However, if (like me) you keep system configuration files in CVS
then the ident strings will no longer match exactly, and the benefit
of non-strict comparisons is lost.

This problem can be avoided by ignoring extra ident strings in the
destination file, and instead only checking that all the ident strings
in the source file are present in the destination file.

>How-To-Repeat:

>Fix:

Index: mergemaster.sh
===================================================================
RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.sh,v
retrieving revision 1.6.2.5
diff -u -r1.6.2.5 mergemaster.sh
--- mergemaster.sh	2000/11/09 00:51:38	1.6.2.5
+++ mergemaster.sh	2001/01/22 23:09:56
@@ -671,21 +669,24 @@
 
   case "${STRICT}" in
   '' | [Nn][Oo])
-    # Compare CVS $Id's first so if the file hasn't been modified
-    # local changes will be ignored.
-    # If the files have the same $Id, delete the one in temproot so the
-    # user will have less to wade through if files are left to merge by hand.
+    # Ignore local changes unless the source file has changed, which
+    # we detect by looking at ident strings:
+    # If the destination file has all of the ident strings of the
+    # temproot file, then delete the temproot file so the user will
+    # have less to wade through if files are left to merge by hand.
+    # We allow the user to add local ident strings which are ignored.
     #
-    # Reduce complexity and improve portability by using ident
-    #
-    CVSID1=`ident ${DESTDIR}${COMPFILE#.} 2>&1`
-    CVSID1="${CVSID1#${DESTDIR}}"
-    CVSID2=`ident ${COMPFILE} 2>&1`
-
-    case "${CVSID2}" in
-    *'no id keywords'*)
-      ;;
-    ."${CVSID1}")
+    ALL_PRESENT=YES
+    ident ${COMPFILE} 2>&1 | {
+      read DISCARD_FILENAME
+      while read IDENT_STRING; do
+        if ident ${DESTDIR}${COMPFILE#.} 2>&1 | fgrep -qv "${IDENT_STRING}"; then
+          ALL_PRESENT=NO
+        fi
+      done	
+    }
+    case "${ALL_PRESENT}" in
+    [Yy][Es][Ss])
       echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
       rm "${COMPFILE}"
       ;;

>Release-Note:
>Audit-Trail:

From: Josef Karthauser <joe@tao.org.uk>
To: Tony Finch <dot@dotat.at>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/24564: local ident strings interfere with mergemaster
Date: Mon, 22 Jan 2001 23:52:41 +0000

 --+g7M9IMkV8truYOl
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Mon, Jan 22, 2001 at 11:24:00PM +0000, Tony Finch wrote:
 >=20
 > >Number:         24564
 > >Category:       bin
 > >Synopsis:       local ident strings interfere with mergemaster
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       medium
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Quarter:       =20
 > >Keywords:      =20
 > >Date-Required:
 > >Class:          change-request
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Mon Jan 22 15:30:02 PST 2001
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Tony Finch
 > >Release:        FreeBSD 4.2-BETA-20001113 i386
 > >Organization:
 > Covalent Technologies Inc.
 > >Environment:
 >=20
 > FreeBSD hand.dotat.at 4.2-BETA-20001113 FreeBSD 4.2-BETA-20001113 #0: Tue=
  Nov 14 00:42:35 UTC 2000     fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/relen=
 g4/sys/DELL-Latitude-CPx  i386
 >=20
 > >Description:
 >=20
 > Mergemaster has a "non-strict comparison" facility for ignoring
 > local changes to files if the cvs idents have not been changed from
 > the standard version of the file. This makes mergemaster runs much
 > less time-consuming.
 >=20
 > However, if (like me) you keep system configuration files in CVS
 > then the ident strings will no longer match exactly, and the benefit
 > of non-strict comparisons is lost.
 >=20
 > This problem can be avoided by ignoring extra ident strings in the
 > destination file, and instead only checking that all the ident strings
 > in the source file are present in the destination file.
 
 Or using a different tag instead of $FreeBSD$, in your local
 repository.  In this case mergemaster will do exactly the right
 thing :).
 
 It's fairly straightforward to configure a copy of the project's
 CVSROOT scripts to do the job.
 
 Joe
 
 --+g7M9IMkV8truYOl
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.4 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iEYEARECAAYFAjpsx8gACgkQXVIcjOaxUBao0gCgohwOa+iwdMWGY7T5fAH/g2vt
 mZsAnjCTmg7W2Dl/BCszvr1MNIAQd1gF
 =O+zi
 -----END PGP SIGNATURE-----
 
 --+g7M9IMkV8truYOl--
 

From: Peter Pentchev <roam@orbitel.bg>
To: Josef Karthauser <joe@tao.org.uk>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/24564: local ident strings interfere with mergemaster
Date: Tue, 23 Jan 2001 09:47:22 +0200

 On Mon, Jan 22, 2001 at 04:00:02PM -0800, Josef Karthauser wrote:
 > The following reply was made to PR bin/24564; it has been noted by GNATS.
 > 
 > From: Josef Karthauser <joe@tao.org.uk>
 > To: Tony Finch <dot@dotat.at>
 > Cc: FreeBSD-gnats-submit@FreeBSD.ORG
 > Subject: Re: bin/24564: local ident strings interfere with mergemaster
 > Date: Mon, 22 Jan 2001 23:52:41 +0000
 > 
 >  --+g7M9IMkV8truYOl
 >  Content-Type: text/plain; charset=us-ascii
 >  Content-Disposition: inline
 >  Content-Transfer-Encoding: quoted-printable
 >  
 >  On Mon, Jan 22, 2001 at 11:24:00PM +0000, Tony Finch wrote:
 >  >=20
 >  > >Number:         24564
 >  > >Category:       bin
 >  > >Synopsis:       local ident strings interfere with mergemaster
 >  > >Originator:     Tony Finch
 >  > >Organization:
 >  > Covalent Technologies Inc.
 >  > >Environment:
 >  >=20
 >  > FreeBSD hand.dotat.at 4.2-BETA-20001113 FreeBSD 4.2-BETA-20001113 #0: Tue=
 >   Nov 14 00:42:35 UTC 2000     fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/relen=
 >  g4/sys/DELL-Latitude-CPx  i386
 >  >=20
 >  > >Description:
 >  >=20
 >  > Mergemaster has a "non-strict comparison" facility for ignoring
 >  > local changes to files if the cvs idents have not been changed from
 >  > the standard version of the file. This makes mergemaster runs much
 >  > less time-consuming.
 >  >=20
 >  > However, if (like me) you keep system configuration files in CVS
 >  > then the ident strings will no longer match exactly, and the benefit
 >  > of non-strict comparisons is lost.
 >  >=20
 >  > This problem can be avoided by ignoring extra ident strings in the
 >  > destination file, and instead only checking that all the ident strings
 >  > in the source file are present in the destination file.
 >  
 >  Or using a different tag instead of $FreeBSD$, in your local
 >  repository.  In this case mergemaster will do exactly the right
 >  thing :).
 >  
 >  It's fairly straightforward to configure a copy of the project's
 >  CVSROOT scripts to do the job.
 
 Actually, this is not strictly true.  mergemaster was recently changed
 so it does a comparison on *all* CVS $Tags$ for a file, so even going
 with the plain vanilla Id tags makes mergemaster complain.
 
 When this was done, I emailed Doug Barton and -hackers about it, and
 in Message-ID: <3A07BA12.A3CD8C88@FreeBSD.org> Doug said:
 
 <quote from Doug's email>
 
 Peter Pentchev wrote:
 >
 > Is there a way to make mergemaster revert to its old behavior - only
 > comparing $FreeBSD tags on files which have those?
 
         Of course there is a way, the question is how likely it is to happen.
 :)  You've stated the solution, just take the local tags out for now.
 They don't tell you anything that 'cvs status' doesn't already tell you.
 
         I struggled with this change, because I myself use a CVS repo to store
 local mods to config files. One of the goals of the current round of
 mergemaster mods is to make the thing more palatable across *BSD
 platforms. There were already too many if it's one $Id tag or another
 definitions in the old code, and it was going to get bigger. If there is
 a great hue and cry over this problem, I'll look at changing it back,
 but frankly my inclination is that using 'ident' is going to be the best
 solution long term.
 
 </quote from Doug's email>
 
 After which I found out that 'cvs status' does indeed do all I wanted :)
 
 Tony, is this answer enough?  'Cause I do not really think Doug is going
 to back out his change, when it does not really need to be backed out or
 made configurable..
 
 G'luck,
 Peter
 
 -- 
 If this sentence were in Chinese, it would say something else.
 

From: Tony Finch <dot@dotat.at>
To: Josef Karthauser <joe@tao.org.uk>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/24564: local ident strings interfere with mergemaster
Date: Tue, 23 Jan 2001 13:59:48 +0000

 Josef Karthauser <joe@tao.org.uk> wrote:
 >On Mon, Jan 22, 2001 at 11:24:00PM +0000, Tony Finch wrote:
 >> 
 >> This problem can be avoided by ignoring extra ident strings in the
 >> destination file, and instead only checking that all the ident strings
 >> in the source file are present in the destination file.
 >
 >Or using a different tag instead of $FreeBSD$, in your local
 >repository.  In this case mergemaster will do exactly the right
 >thing :).
 
 No that doesn't work for me. I use $Header$ so that my cvs repository
 is maximally portable. In fact I haven't done any configuration of it
 beyond `cvs init` and I don't need to do any more than that for a
 personal repository.
 
 Tony.
 -- 
 f.a.n.finch    fanf@covalent.net    dot@dotat.at
 "Perhaps on your way home you will pass someone in the dark,
 and you will never know it, for they will be from outer space."
 
State-Changed-From-To: open->analyzed 
State-Changed-By: dougb 
State-Changed-When: Sat Jan 27 23:12:30 PST 2001 
State-Changed-Why:  

I'll be looking at a different solution for this problem. 


Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Sat Jan 27 23:12:30 PST 2001 
Responsible-Changed-Why:  

mm is my responsibility. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24564 

From: Tony Finch <dot@dotat.at>
To: dougb@FreeBSD.org
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: bin/24564: local ident strings interfere with mergemaster
Date: Thu, 8 Feb 2001 11:11:49 +0000

 There's a bug in the patch I originally submitted (changing the
 variable in the loop doesn't propagate out to the wider scope), and
 I'm not sure why I didn't find it in testing, but anyway, here's a
 diff that works.
 
 Index: mergemaster.sh
 ===================================================================
 RCS file: /home/ncvs/src/usr.sbin/mergemaster/mergemaster.sh,v
 retrieving revision 1.6.2.5
 diff -u -r1.6.2.5 mergemaster.sh
 --- mergemaster.sh	2000/11/09 00:51:38	1.6.2.5
 +++ mergemaster.sh	2001/02/08 11:03:44
 @@ -671,25 +669,23 @@
  
    case "${STRICT}" in
    '' | [Nn][Oo])
 -    # Compare CVS $Id's first so if the file hasn't been modified
 -    # local changes will be ignored.
 -    # If the files have the same $Id, delete the one in temproot so the
 -    # user will have less to wade through if files are left to merge by hand.
 +    # Ignore local changes unless the source file has changed, which
 +    # we detect by looking at ident strings:
 +    # If the destination file has all of the ident strings of the
 +    # temproot file, then delete the temproot file so the user will
 +    # have less to wade through if files are left to merge by hand.
 +    # We allow the user to add local ident strings which are ignored.
      #
 -    # Reduce complexity and improve portability by using ident
 -    #
 -    CVSID1=`ident ${DESTDIR}${COMPFILE#.} 2>&1`
 -    CVSID1="${CVSID1#${DESTDIR}}"
 -    CVSID2=`ident ${COMPFILE} 2>&1`
 -
 -    case "${CVSID2}" in
 -    *'no id keywords'*)
 -      ;;
 -    ."${CVSID1}")
 +    ident ${COMPFILE} 2>&1 | {
 +      read DISCARD_FILENAME
 +      while read IDENT_STRING; do
 +        echo $IDENT_STRING
 +	ident ${DESTDIR}${COMPFILE#.} 2>&1 | fgrep -q "${IDENT_STRING}" || echo no
 +      done
 +    } | grep -q no || {
        echo " *** Temp ${COMPFILE} and installed have the same CVS Id, deleting"
        rm "${COMPFILE}"
 -      ;;
 -    esac
 +    }
      ;;
    esac
  
 
State-Changed-From-To: analyzed->closed 
State-Changed-By: dougb 
State-Changed-When: Mon Mar 5 12:36:12 PST 2001 
State-Changed-Why:  

A different solution for this problem (namely, return to the 
way CVS $Id strings were used previously) was committed to 
-current and releng_4.  

http://www.freebsd.org/cgi/query-pr.cgi?pr=24564 
>Unformatted:
