Bug 24564

Summary: local ident strings interfere with mergemaster
Product: Base System Reporter: Tony Finch <dot>
Component: binAssignee: Doug Barton <dougb>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Tony Finch 2001-01-22 23:30:02 UTC
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.
Comment 1 Josef Karthauser 2001-01-22 23:52:41 UTC
On Mon, Jan 22, 2001 at 11:24:00PM +0000, Tony Finch wrote:
> 
> >Number:         24564
> >Category:       bin
> >Synopsis:       local ident strings interfere with mergemaster
> >Confidential:   no
> >Severity:       serious
> >Priority:       medium
> >Responsible:    freebsd-bugs
> >State:          open
> >Quarter:        
> >Keywords:       
> >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:
> 
> 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.


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
Comment 2 Peter Pentchev 2001-01-23 07:47:22 UTC
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.
Comment 3 Tony Finch 2001-01-23 13:59:48 UTC
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."
Comment 4 Doug Barton freebsd_committer freebsd_triage 2001-01-28 07:12:30 UTC
State Changed
From-To: open->analyzed


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


Comment 5 Doug Barton freebsd_committer freebsd_triage 2001-01-28 07:12:30 UTC
Responsible Changed
From-To: freebsd-bugs->dougb


mm is my responsibility.
Comment 6 Tony Finch 2001-02-08 11:11:49 UTC
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
Comment 7 Doug Barton freebsd_committer freebsd_triage 2001-03-05 20:36:12 UTC
State Changed
From-To: analyzed->closed


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