diff, and patchdiffpatch engl401paper.doc
engl401paper-revision.doc
engl401paper-version1.doc
engl401paper-version2.doc
diff, and patchdiffdifffile1: This is a poem
about a bear
who got lost
in State College
and ate a dog.
file2: This is a poem
about a bear
who got lost
in State College
and ate a professor.
diff file1 file2 5c5
< and ate a dog.
---
> and ate a professor.
diff -c file1 file2 *** file1 2014-09-28 12:29:40.000000000 -0400
--- file2 2014-09-28 12:29:51.000000000 -0400
***************
*** 2,5 ****
about a bear
who got lost
in State College
! and ate a dog.
--- 2,5 ----
about a bear
who got lost
in State College
! and ate a professor.
diff -y file1 file2 This is a poem This is a poem
about a bear about a bear
who got lost who got lost
in State College in State College
and ate a dog. | and ate a professor.

patchdiff -u file1 file2 --- file1 2014-09-28 12:29:40.000000000 -0400
+++ file2 2014-09-28 12:29:51.000000000 -0400
@@ -2,4 +2,4 @@
about a bear
who got lost
in State College
-and ate a dog.
+and ate a professor.
file1file2 is a newer, “updated” version of the poem. We want everyone we know to update the older version of the poem (in file1) to the new version. So we distribute the output of diff (with the -u flag) as a “patch file” named bear-poem-update:
$ diff -u file1 file2 > bear-poem-update.diff
Individual users can then use the patch utility to update their copies of the poem using the patch file bear-poem-update:
$ patch < bear-poem-update.diff
patching file file1
file1 has now been updated to contain the new version of the poem:
$ cat file1
This is a poem
about a bear
who got lost
in State College
and ate a professor.
Three important capabilities (Raymond):
major.minor is very popular10.0 (“Cheetah”) … 10.10 (“Yosemite”)10.9.0 (“Mavericks”) … 10.9.5 (“Mavericks,” version 5)major.minor: 1.0 … 3.0 (1981-1992)95, 98, ME (Millennium) (1995-2000)XP, Vista (2001-2006)major.minor: 7.0, 8.0 (2009-)We are going to edit the poem, changing the line “ate a dog” to “ate a professor” and using RCS to keep track of that change.
First, we “check in” the file to beging tracking its versions:
$ ci file1
file1,v <-- file1
enter description, terminated with single '.' or end of file:
NOTE: This is NOT the log message!
>> Poem about bear.
initial revision: 1.1
done
RCS asks us for a description of the file. Notice also that RCS automatically provides our first version number, 1.1.
This creates a file named file1,v (the v marks it as a version control file). Here’s what that file looks like:
head 1.1;
access;
symbols;
locks; strict;
comment @# @;
1.1
date 2014.09.28.17.00.25; author blennon; state Exp;
branches;
next ;
desc
@Poem about bear.
@
1.1
log
@Initial revision
@
text
@This is a poem
about a bear
who got lost
in downtown State College
and ate a dog.
@
Now we “check out” a working copy of the file so we can edit it.
$ co -l file1
We open an editor and change the line “ate a dog” to “ate a professor.” Then we check the file back in, this time providing a description of the change we made:
$ ci file1
file1,v <-- file1
new revision: 1.2; previous revision: 1.1
enter log message, terminated with single '.' or end of file:
>> Change "ate a dog" to "ate a professor"
done
Notice also that RCS automatically increments our version number from 1.1 to 1.2. Here’s what the file file1,v looks like now:
head 1.2;
access;
symbols;
locks; strict;
comment @# @;
1.2
date 2014.09.28.17.01.49; author blennon; state Exp;
branches;
next 1.1;
1.1
date 2014.09.28.17.00.25; author blennon; state Exp;
branches;
next ;
desc
@Poem about bear.
@
1.2
log
@Change "ate a dog" to "ate a professor"
@
text
@This is a poem
about a bear
who got lost
in downtown State College
and ate a professor.
@
1.1
log
@Initial revision
@
text
@d5 1
a5 1
and ate a dog.
@
We can also look at the log (history) of versions and changes made to the file:
$ rlog file1
RCS file: file1,v
Working file: file1
head: 1.2
branch:
locks: strict
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
Poem about bear.
----------------------------
revision 1.2
date: 2014/09/28 17:01:49; author: blennon; state: Exp; lines: +1 -1
Change "ate a dog" to "ate a professor"
----------------------------
revision 1.1
date: 2014/09/28 17:00:25; author: blennon; state: Exp;
Initial revision