[comp.software-eng] Looking for a program to merge two files interactively

pratt@paul.rutgers.edu (Lorien Y. Pratt) (07/22/88)

I have a program which consists of about 100 different files.  A couple of
months ago, I began two sets of modifications to this program, each of which
was kept in a different directory.  I now would like to merge these
modifications into a single program.

However, there is no way that I want this to happen automatically.  What
I would like is:
  1) A two-up listing of each file which is different, showing where the
     differences are and what they are.
  2) An interactive program which will take as input the two different files,
     and for each section which is different, prompt me interactively
     as to whether one or the other or both should be included in a
     third, output file.  I would also like an option to flag a block
     of just-included text so that I can look at it later and make
     modifications in an editor.

Since I'm sure I'm not the first person in the world to need to do
this, I thought I'd post this request for any programs that anyone
might have which do what I ask.  I know about diff and sccs, but they
seem to have an awful lot more complexity than the fairly simple
functions listed above that I want.  Thanks for any pointers or help,
-- 
-------------------------------------------------------------------
Lorien Y. Pratt                            Computer Science Department
pratt@paul.rutgers.edu                     Rutgers University
                                           Busch Campus
(201) 932-4714                             Piscataway, NJ  08854

mende@porthos.rutgers.edu (Bob Mende Pie) (07/22/88)

In article <Jul.22.07.54.48.1988.21328@paul.rutgers.edu>
pratt@paul.rutgers.edu (Lorien Y. Pratt) writes:
] I have a program which consists of about 100 different files.  A couple of
] months ago, I began two sets of modifications to this program, each of which
] was kept in a different directory.  I now would like to merge these
] modifications into a single program.
]
] However, there is no way that I want this to happen automatically.  What
] I would like is:
]   1) A two-up listing of each file which is different, showing where the
]      differences are and what they are.

the program you want is sdiff.   sdiff is a side-to-side diff between
files.  On the suns it lives is /usr/5bin and on a pyramid it is
gotten via att sdiff.   Look at the man page for more info.  It should
do exactly what you want.

]   2) An interactive program which will take as input the two different files,
]      and for each section which is different, prompt me interactively
]      as to whether one or the other or both should be included in a
]      third, output file.  I would also like an option to flag a block
]      of just-included text so that I can look at it later and make
]      modifications in an editor.

There is a program called patch that takes the output diff (not sdiff)
and merges files, look at man diff and man patch for more infomation
 
] Since I'm sure I'm not the first person in the world to need to do
] this, I thought I'd post this request for any programs that anyone
] might have which do what I ask.  I know about diff and sccs, but they
] seem to have an awful lot more complexity than the fairly simple
] functions listed above that I want.  Thanks for any pointers or help,

while sccs/rcs and diff may seem complicated, they are the way to
go... the kind of thing that you are talking about is what {r,sc}cs
was created for.    And diff is not complicated unless you want it to
be... 


					/Bob...
-- 
{...}!rutgers!mende	  mende@aramis.rutgers.edu	   mende@zodiac.bitnet

Let's send the Russians defective lifestyle accessories!

les@chinet.chi.il.us (Leslie Mikesell) (07/23/88)

In article <Jul.22.07.54.48.1988.21328@paul.rutgers.edu> pratt@paul.rutgers.edu (Lorien Y. Pratt) writes:
 >I have a program which consists of about 100 different files.  A couple of
 >months ago, I began two sets of modifications to this program, each of which
 >was kept in a different directory.  I now would like to merge these
 >modifications into a single program.

I've done this sort of thing by generating a file containing context diffs
and editing this file to delete the changes that I don't want to install.
Patch can then install all the changes at once.  This is not exactly an
interactive prompt like you requested, but it gives you time to get it right.

  Les Mikesell

squires@hpcvlx.HP.COM (Matt Squires) (07/24/88)

/ hpcvlx:comp.software-eng /
pratt@paul.rutgers.edu (Lorien Y. Pratt) 
/  4:54 am  Jul 22, 1988 /

> ... What I would like is:
>   1) A two-up listing of each file which is different, showing where the
>      differences are and what they are.
>   2) An interactive program which will take as input the two different files,
>      and for each section which is different, prompt me interactively
>      as to whether one or the other or both should be included in a
>      third, output file.  I would also like an option to flag a block
>      of just-included text so that I can look at it later and make
>      modifications in an editor.

Perhaps you might want to look at "idiff", a program developed in section 6.8
of Kernighan + Pike's THE UNIX PROGRAMMING ENVIRONMENT (C) 1984.

"idiff" does not quite match your "flagging" specs, but here is their
description:

"A common problem is to have two versions of a file, somewhat different,
each containing part of a desired file; this often results when changes are
made independently by two different people.  diff(1) will tell you how the
files differ, but it's of no direct help if you want to select some parts
of the first file and some of the second.
	In this section, we will write a program idiff ("interactive diff")
that presents each chunk of diff output and offers the user the option of
choosing the "from" part, choosing the "to" part, or editing the parts. idiff
produces the selected pieces in the proper order, in a file called idiff.out."

The editor idiff uses is ed(1), but it is trivial to modify that to a different
editor, such as mg(1) or emacsclient(1).  When a section of differing text is
brought into the editor, the diff(1) output of the differing sections is
loaded.  Thus, you can merge the section of differing code yourself, or insert
your own "flags" at the beginning and end of the text yourself, using the
editor.

The code is written in C for a Unix programming environment, and is about 3
pages long.

I stongly recommend THE UNIX PROGRAMMING ENVIRONMENT for everybody who uses
Unix beyond reading and sending mail.

mcs

hoey@ai.etl.army.mil (Dan Hoey) (08/06/88)

In article <...21328...> pratt@paul.rutgers.edu (Lorien Y. Pratt) writes:
>I have a program which consists of about 100 different files.  A couple of
>months ago, I began two sets of modifications to this program, each of which
>was kept in a different directory.  I now would like to merge these
>modifications into a single program.

You haven't mentioned whether you kept around a crucial piece of information:
the common ancestor from which both versions were derived.  There are several
programs such as RCS's "merge" (based on Unix's "diff3") that can be used to
merge the versions semi-automatically.  Where the modifications overlap, both
pieces are included in the output, and you get to merge them automatically with
your favorite editor.

Dan