home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cvs1107.zip / intro.INF (.txt) < prev    next >
OS/2 Help File  |  1998-08-21  |  24KB  |  640 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. -Preface- ΓòÉΓòÉΓòÉ
  3.  
  4. These are the notes for Cyclic Software's two-day CVS class.  They were written 
  5. by Jim Blandy. 
  6.  
  7. Copyright (C) 1996 Jim Blandy.  All rights reserved. 
  8.  
  9. Permission is granted to make and distribute verbatim copies of this manual 
  10. provided the copyright notice and this permission notice are preserved on all 
  11. copies. 
  12.  
  13. Permission is granted to copy and distribute modified versions of this manual 
  14. under the conditions for verbatim copying, provided also that the entire 
  15. resulting derived work is distributed under the terms of a permission notice 
  16. identical to this one. 
  17.  
  18. Permission is granted to copy and distribute translations of this manual into 
  19. another language, under the above conditions for modified versions, except that 
  20. this permission notice may be stated in a translation approved by the Free 
  21. Software Foundation. 
  22.  
  23.  
  24. ΓòÉΓòÉΓòÉ 2. Introduction to CVS ΓòÉΓòÉΓòÉ
  25.  
  26.  These are the notes for Cyclic Software's two-day CVS class.  The CVS 
  27.  Versioning System is a program for maintaining and consulting the history of a 
  28.  software project, or any other directory tree of text files. 
  29.  
  30.  What is CVS for?              What is CVS for? 
  31.  How to use CVS --- First SketchHow to use CVS --- First Sketch 
  32.  
  33.  
  34. ΓòÉΓòÉΓòÉ 3. What is CVS for? ΓòÉΓòÉΓòÉ
  35.  
  36.  CVS maintains a history of a source tree, in terms of a series of changes.  It 
  37.  stamps each change with the time it was made and the user name of the person 
  38.  who made it.  Usually, the person provides a bit of text describing why they 
  39.  made the change as well.  Given that information, CVS can help developers 
  40.  answer questions like: 
  41.  
  42.      Who made a given change? 
  43.  
  44.      When did they make it? 
  45.  
  46.      Why did they make it? 
  47.  
  48.      What other changes did they make at the same time? 
  49.  
  50.  
  51. ΓòÉΓòÉΓòÉ 4. How to use CVS --- First Sketch ΓòÉΓòÉΓòÉ
  52.  
  53.  Before discussing too many vague terms and concepts, let's look over the 
  54.  essential CVS commands. 
  55.  
  56.  Setting your repository       Setting your repository 
  57.  Checking out a working directoryChecking out a working directory 
  58.  Making changes to files       Making changes to files 
  59.  Merging your changes          Merging your changes 
  60.  Committing your changes       Committing your changes 
  61.  Examining changes             Examining changes 
  62.  Writing good log entries      Writing good log entries 
  63.  Handling conflicts            Handling conflicts 
  64.  
  65.  
  66. ΓòÉΓòÉΓòÉ 4.1. Setting your repository ΓòÉΓòÉΓòÉ
  67.  
  68.  CVS records everyone's changes to a given project in a directory tree called a 
  69.  repository.  Before you can use CVS, you need to set the CVSROOT environment 
  70.  variable to the repository's path.  Whoever is in charge of your project's 
  71.  configuration management will know what this is; perhaps they've made a global 
  72.  definition for CVSROOT somewhere. 
  73.  
  74.  In any case, on our system, the CVS repository is '/u/src/master'. In that 
  75.  case, you would need to enter the commands 
  76.  
  77.                       setenv CVSROOT /u/src/master
  78.  
  79.  if your shell is csh or one of its descendents, or 
  80.  
  81.                       CVSROOT=/u/src/master
  82.                       export CVSROOT
  83.  
  84.  if your shell is Bash or some other Bourne shell variant. 
  85.  
  86.  If you forget to do this, CVS will complain when you try to use it: 
  87.  
  88.                       $ cvs checkout httpc
  89.                       cvs checkout: No CVSROOT specified!  Please use the `-d' option
  90.                       cvs [checkout aborted]: or set the CVSROOT environment variable.
  91.                       $
  92.  
  93.  
  94. ΓòÉΓòÉΓòÉ 4.2. Checking out a working directory ΓòÉΓòÉΓòÉ
  95.  
  96.  CVS doesn't work on ordinary directory trees; you need to work within a 
  97.  directory that CVS created for you.  Just as you check out a book from a 
  98.  library before taking it home to read it, you use the cvs checkout command to 
  99.  get a directory tree from CVS before working on it. For example, suppose you 
  100.  are working on a project named httpc, a trivial HTTP client: 
  101.  
  102.                       $ cd
  103.                       $ cvs checkout httpc
  104.                       cvs checkout: Updating httpc
  105.                       U httpc/.cvsignore
  106.                       U httpc/Makefile
  107.                       U httpc/httpc.c
  108.                       U httpc/poll-server
  109.                       $
  110.  
  111.  The command cvs checkout httpc means, ``Check out the source tree called httpc 
  112.  from the repository specified by the CVSROOT environment variable.'' 
  113.  
  114.  CVS puts the tree in a subdirectory named 'httpc': 
  115.  
  116.                       $ cd httpc
  117.                       $ ls -l
  118.                       total 8
  119.                       drwxr-xr-x  2 jimb      512 Oct 31 11:04 CVS
  120.                       -rw-r--r--  1 jimb      89 Oct 31 10:42 Makefile
  121.                       -rw-r--r--  1 jimb     4432 Oct 31 10:45 httpc.c
  122.                       -rwxr-xr-x  1 jimb      460 Oct 30 10:21 poll-server
  123.  
  124.  Most of these files are your working copies of the httpc sources. However, the 
  125.  subdirectory called 'CVS' (at the top) is different. CVS uses it to record 
  126.  extra information about each of the files in that directory, to help it 
  127.  determine what changes you've made since you checked it out. 
  128.  
  129.  
  130. ΓòÉΓòÉΓòÉ 4.3. Making changes to files ΓòÉΓòÉΓòÉ
  131.  
  132.  Once CVS has created a working directory tree, you can edit, compile and test 
  133.  the files it contains in the usual way --- they're just files. 
  134.  
  135.  For example, suppose we try compiling the package we just checked out: 
  136.  
  137.                       $ make
  138.                       gcc -g -Wall  -lnsl -lsocket  httpc.c  -o httpc
  139.                       httpc.c: In function `tcp_connection':
  140.                       httpc.c:48: warning: passing arg 2 of `connect' from incompatible pointer type
  141.                       $
  142.  
  143.  It seems that 'httpc.c' hasn't been ported to this operating system yet.  We 
  144.  need to cast one of the arguments to connect.  To fix that, line 48 must 
  145.  change from this: 
  146.  
  147.                         if (connect (sock, &name, sizeof (name)) >= 0)
  148.  
  149.   to this: 
  150.  
  151.                         if (connect (sock, (struct sockaddr *) &name, sizeof (name)) >= 0)
  152.  
  153.  Now it should compile: 
  154.  
  155.                       $ make
  156.                       gcc -g -Wall  -lnsl -lsocket  httpc.c  -o httpc
  157.                       $ httpc GET http://www.cyclic.com
  158.                       ┬╖┬╖┬╖ HTML text for Cyclic Software's home page follows ┬╖┬╖┬╖
  159.                       $
  160.  
  161.  
  162. ΓòÉΓòÉΓòÉ 4.4. Merging your changes ΓòÉΓòÉΓòÉ
  163.  
  164.  Since each developer uses their own working directory, the changes you make to 
  165.  your working directory aren't automatically visible to the other developers on 
  166.  your team.  CVS doesn't publish your changes until you're ready.  When you're 
  167.  done testing your changes, you must commit them to the repository to make them 
  168.  available to the rest of the group. We'll describe the cvs commit command 
  169.  below. 
  170.  
  171.  However, what if another developer has changed the same files you have, or the 
  172.  same lines?  Whose changes should prevail?  It's generally impossible to 
  173.  answer this question automatically; CVS certainly isn't competent to make that 
  174.  judgment. 
  175.  
  176.  Thus, before you can commit your changes, CVS requires your sources to be in 
  177.  sync with any changes committed by the other team members.  The cvs update 
  178.  command takes care of this: 
  179.  
  180.                       $ cvs update
  181.                       cvs update: Updating .
  182.                       U Makefile
  183.                       RCS file: /u/src/master/httpc/httpc.c,v
  184.                       retrieving revision 1.6
  185.                       retrieving revision 1.7
  186.                       Merging differences between 1.6 and 1.7 into httpc.c
  187.                       M httpc.c
  188.                       $
  189.  
  190.  Let's look at this line-by-line: 
  191.  
  192.  U Makefile 
  193.            A line of the form 'U file' means that file was simply Updated; 
  194.            someone else had made a change to the file, and CVS copied the 
  195.            modified file into your home directory. 
  196.  
  197.  RCS file: ┬╖┬╖┬╖ 
  198.  
  199.  retrieving revision 1.6 
  200.  
  201.  retrieving revision 1.7 
  202.  
  203.  Merging differences between 1.6 and 1.7 into httpc.c 
  204.            These messages indicate that someone else has changed 'httpc.c'; CVS 
  205.            merged their changes with yours, and did not find any textual 
  206.            conflicts.  The numbers '1.6' and 1.7 are revision numbers, used to 
  207.            identify a specific point in a file's history. 
  208.  
  209.            Note that CVS merges changes into your working copy only; the 
  210.            repository and the other developers' working directories are left 
  211.            undisturbed.  It is up to you to test the merged text, and make sure 
  212.            it's valid. 
  213.  
  214.  M httpc.c 
  215.            A line of the form 'M file' means that file has been Modified by 
  216.            you, and contains changes that are not yet visible to the other 
  217.            developers.  These are changes you need to commit. 
  218.  
  219.            In this case, 'httpc.c' now contains both your modifications and 
  220.            those of the other user. 
  221.  
  222.  Since CVS has merged someone else's changes into your source, it's best to 
  223.  make sure things still work: 
  224.  
  225.                       $ make
  226.                       gcc -g -Wall -Wmissing-prototypes  -lnsl -lsocket  httpc.c  -o httpc
  227.                       $ httpc GET http://www.cyclic.com
  228.                       ┬╖┬╖┬╖ HTML text for Cyclic Software's home page follows ┬╖┬╖┬╖
  229.                       $
  230.  
  231.  It seems to still work. 
  232.  
  233.  
  234. ΓòÉΓòÉΓòÉ 4.5. Committing your changes ΓòÉΓòÉΓòÉ
  235.  
  236.  Now that you have brought your sources up to date with the rest of the group 
  237.  and tested them, you are ready to commit your changes to the repository and 
  238.  make them visible to the rest of the group.  The only file you've modified is 
  239.  'httpc.c', but it's always safe to run cvs update to get a list of the 
  240.  modified files from CVS: 
  241.  
  242.                       $ cvs update
  243.                       cvs update: Updating .
  244.                       M httpc.c
  245.                       $
  246.  
  247.  As expected, the only file CVS mentions is 'httpc.c'; it says it contains 
  248.  changes which you have not yet committed.  You can commit them like so: 
  249.  
  250.                       $ cvs commit httpc.c
  251.  
  252.  At this point, CVS will start up your favorite editor and prompt you for a log 
  253.  message describing the change.  When you exit the editor, CVS will commit your 
  254.  change: 
  255.  
  256.                       Checking in httpc.c;
  257.                       /u/src/master/httpc/httpc.c,v  <--  httpc.c
  258.                       new revision: 1.8; previous revision: 1.7
  259.                       $
  260.  
  261.  Now that you have committed your changes, they are visible to the rest of the 
  262.  group.  When another developer runs cvs update, CVS will merge your changes to 
  263.  'httpc.c' into their working directory. 
  264.  
  265.  
  266. ΓòÉΓòÉΓòÉ 4.6. Examining changes ΓòÉΓòÉΓòÉ
  267.  
  268.  At this point, you might well be curious what changes the other developer made 
  269.  to 'httpc.c'.  To look at the log entries for a given file, you can use the 
  270.  cvs log command: 
  271.  
  272.                       $ cvs log httpc.c
  273.  
  274.                       RCS file: /u/src/master/httpc/httpc.c,v
  275.                       Working file: httpc.c
  276.                       head: 1.8
  277.                       branch:
  278.                       locks: strict
  279.                       access list:
  280.                       symbolic names:
  281.                       keyword substitution: kv
  282.                       total revisions: 8;   selected revisions: 8
  283.                       description:
  284.                       The one and only source file for the trivial HTTP client
  285.                       ----------------------------
  286.                       revision 1.8
  287.                       date: 1996/10/31 20:11:14;  author: jimb;  state: Exp;  lines: +1 -1
  288.                       (tcp_connection): Cast address structure when calling connect.
  289.                       ----------------------------
  290.                       revision 1.7
  291.                       date: 1996/10/31 19:18:45;  author: fred;  state: Exp;  lines: +6 -2
  292.                       (match_header): Make this test case-insensitive.
  293.                       ----------------------------
  294.                       revision 1.6
  295.                       date: 1996/10/31 19:15:23;  author: jimb;  state: Exp;  lines: +2 -6
  296.                       ┬╖┬╖┬╖
  297.                       $
  298.  
  299.  Most of the text here you can ignore; the portion to look at carefully is the 
  300.  series of log entries after the first line of hyphens.  The log entries appear 
  301.  in reverse chronological order, under the assumption that more recent changes 
  302.  are usually more interesting.  Each entry describes one change to the file, 
  303.  and may be parsed as follows: 
  304.  
  305.  'revision 1.8' 
  306.            Each version of a file has a unique revision number.  Revision 
  307.            numbers look like '1.1', '1.2', '1.3.2.2' or even '1.3.2.2.4.5'.  By 
  308.            default revision 1.1 is the first revision of a file.  Each 
  309.            successive revision is given a new number by increasing the 
  310.            rightmost number by one. 
  311.  
  312.  'date: 1996/10/31 20:11:14;  author: jimb; ┬╖┬╖┬╖' 
  313.            This line gives the date of the change, and the username of the 
  314.            person who committed it; the remainder of the line is not very 
  315.            interesting. 
  316.  
  317.  '(tcp_connection): Cast ┬╖┬╖┬╖' 
  318.            This (pretty obviously) is the log entry describing that change. 
  319.  
  320.  The cvs log command can select log entries by date range, or by revision 
  321.  number; see the manual for details on this. 
  322.  
  323.  If you would actually like to see the change in question, you can use the cvs 
  324.  diff command.  For example, if you would like to see the changes Fred 
  325.  committed as revision 1.7, you can use the following command: 
  326.  
  327.                       $ cvs diff -c -r 1.6 -r 1.7 httpc.c
  328.  
  329.  Before we look at the output from this command, let's look at what the various 
  330.  parts mean: 
  331.  
  332.  -c 
  333.            This requests that cvs diff use a more human-readable format for its 
  334.            output.  (I'm not sure why it isn't the default.) 
  335.  
  336.  -r 1.6 -r 1.7 
  337.            This tells CVS to display the changes needed to turn revision 1.6 of 
  338.            httpc.c into revision 1.7.  You can request a wider range of 
  339.            revisions if you like; for example, -r 1.6 -r 1.8 would display both 
  340.            fred's changes and your most recent change.  (You can even request 
  341.            that changes be displayed backwards --- as if they were being undone 
  342.            --- by specifying the revisions backwards: -r 1.7 -r 1.6.  This 
  343.            sounds odd, but it is useful sometimes.) 
  344.  
  345.  httpc.c 
  346.            This is the name of the file to inspect.  If you don't give it 
  347.            specific files to report on, CVS will produce a report for the 
  348.            entire directory. 
  349.  
  350.  Here is the output from the command: 
  351.  
  352.                       Index: httpc.c
  353.                       ===================================================================
  354.                       RCS file: /u/src/master/httpc/httpc.c,v
  355.                       retrieving revision 1.6
  356.                       retrieving revision 1.7
  357.                       diff -c -r1.6 -r1.7
  358.                       *** httpc.c   1996/10/31 19:15:23   1.6
  359.                       --- httpc.c   1996/10/31 19:18:45   1.7
  360.                       ***************
  361.                       *** 62,68 ****
  362.                        }
  363.  
  364.  
  365.                       ! /* Return non-zero iff HEADER is a prefix of TEXT.  HEADER should be
  366.                          null-terminated; LEN is the length of TEXT.  */
  367.                        static int
  368.                        match_header (char *header, char *text, size_t len)
  369.                       --- 62,69 ----
  370.                        }
  371.  
  372.  
  373.                       ! /* Return non-zero iff HEADER is a prefix of TEXT, ignoring
  374.                       !   differences in case.  HEADER should be lower-case, and
  375.                          null-terminated; LEN is the length of TEXT.  */
  376.                        static int
  377.                        match_header (char *header, char *text, size_t len)
  378.                       ***************
  379.                       *** 76,81 ****
  380.                       --- 77,84 ----
  381.                         for (i = 0; i < header_len; i++)
  382.                          {
  383.                           char t = text[i];
  384.                       +    if ('A' <= t && t <= 'Z')
  385.                       +     t += 'a' - 'A';
  386.                           if (header[i] != t)
  387.                            return 0;
  388.                          }
  389.                       $
  390.  
  391.  This output takes a bit of effort to get used to, but it is definitely worth 
  392.  understanding. 
  393.  
  394.  The interesting portion starts with the first two lines beginning with *** and 
  395.  ---; those describe the older and newer files compared.  The remainder 
  396.  consists of two hunks, each of which starts with a line of asterisks.  Here is 
  397.  the first hunk: 
  398.  
  399.                       ***************
  400.                       *** 62,68 ****
  401.                        }
  402.  
  403.  
  404.                       ! /* Return non-zero iff HEADER is a prefix of TEXT.  HEADER should be
  405.                          null-terminated; LEN is the length of TEXT.  */
  406.                        static int
  407.                        match_header (char *header, char *text, size_t len)
  408.                       --- 62,69 ----
  409.                        }
  410.  
  411.  
  412.                       ! /* Return non-zero iff HEADER is a prefix of TEXT, ignoring
  413.                       !   differences in case.  HEADER should be lower-case, and
  414.                          null-terminated; LEN is the length of TEXT.  */
  415.                        static int
  416.                        match_header (char *header, char *text, size_t len)
  417.  
  418.  Text from the older version appears after the *** 62,68 *** line; text from 
  419.  the new appears after the --- 62,69 --- line.  The pair of numbers in each 
  420.  indicates the range of lines shown.  CVS provides context around the change, 
  421.  and marks the actual lines affected with '!' characters.  Thus, one can see 
  422.  that the single line in the top half was replaced with the two lines in the 
  423.  bottom half. 
  424.  
  425.  Here is the second hunk: 
  426.  
  427.                       ***************
  428.                       *** 76,81 ****
  429.                       --- 77,84 ----
  430.                         for (i = 0; i < header_len; i++)
  431.                          {
  432.                           char t = text[i];
  433.                       +    if ('A' <= t && t <= 'Z')
  434.                       +     t += 'a' - 'A';
  435.                           if (header[i] != t)
  436.                           return 0;
  437.                          }
  438.  
  439.  This hunk describes the insertion of two lines, marked with '+' characters. 
  440.  CVS omits the old text in this case, because it would be redundant.  CVS uses 
  441.  a similar hunk format to describe deletions. 
  442.  
  443.  Like the Unix diff command, output from cvs diff is usually called a patch, 
  444.  because developers have traditionally used the format to distribute bug fixes 
  445.  or small new features.  While reasonably readable to humans, a patch contains 
  446.  enough information for a program to apply the changes it describes to an 
  447.  unmodified text file. In fact, the Unix patch command does exactly this, given 
  448.  a patch as input. 
  449.  
  450.  
  451. ΓòÉΓòÉΓòÉ 4.7. Adding and deleting files ΓòÉΓòÉΓòÉ
  452.  
  453.  CVS treats file creation and deletion like other changes, recording such 
  454.  events in the files' histories.  One way to look at this is to say that CVS 
  455.  records the history of directories as well as the files they contain. 
  456.  
  457.  CVS doesn't assume that newly created files should be placed under its 
  458.  control; this would do the wrong thing in many circumstances.  For example, 
  459.  one needn't record changes to object files and executables, since their 
  460.  contents can always be recreated from the source files (one hopes).  Instead, 
  461.  if you create a new file, cvs update will flag it with a '?' character until 
  462.  you tell CVS what you intend to do with it. 
  463.  
  464.  To add a file to a project, you must first create the file, and then use the 
  465.  cvs add command to mark it for addition.  Then, the next call to cvs commit 
  466.  will add the file to the repository.  For example, here's how you might add a 
  467.  README file to the httpc project: 
  468.  
  469.                       $ ls
  470.                       CVS      Makefile   httpc.c    poll-server
  471.                       $ vi README
  472.                       ┬╖┬╖┬╖ enter a description of httpc ┬╖┬╖┬╖
  473.                       $ ls
  474.                       CVS      Makefile   README    httpc.c    poll-server
  475.                       $ cvs update
  476.                       cvs update: Updating .
  477.                       ? README --- CVS doesn't know about this file yet.
  478.                       $ cvs add README
  479.                       cvs add: scheduling file `README' for addition
  480.                       cvs add: use 'cvs commit' to add this file permanently
  481.                       $ cvs update --- Now what does CVS think?
  482.                       cvs update: Updating .
  483.                       A README --- The file is marked for addition.
  484.                       $ cvs commit README
  485.                       ┬╖┬╖┬╖ CVS prompts you for a log entry ┬╖┬╖┬╖
  486.                       RCS file: /u/jimb/cvs-class/rep/httpc/README,v
  487.                       done
  488.                       Checking in README;
  489.                       /u/src/master/httpc/README,v  <--  README
  490.                       initial revision: 1.1
  491.                       done
  492.                       $
  493.  
  494.  CVS treats deleted files similarly.  If you delete a file and then run cvs 
  495.  update, CVS doesn't assume you intend the file for deletion. Instead, it does 
  496.  something benign --- it recreates the file with its last recorded contents, 
  497.  and flags it with a 'U' character, as for any other update.  (This means that 
  498.  if you want to undo the changes you've made to a file in your working 
  499.  directory, you can simply delete the files, and then let cvs update recreate 
  500.  them.) 
  501.  
  502.  To remove a file from a project, you must first delete the file, and then use 
  503.  the cvs rm command to mark it for deletion.  Then, the next call to cvs commit 
  504.  will delete the file from the repository. 
  505.  
  506.  Committing a file marked with cvs rm does not destroy the file's history.  It 
  507.  simply adds a new revision, which is marked as ``non-existent.''  The 
  508.  repository still has records of the file's prior contents, and can recall them 
  509.  as needed --- for example, by cvs diff or cvs log. 
  510.  
  511.  There are several strategies for renaming files; the simplest is to simply 
  512.  rename the file in your working directory, and run cvs rm on the old name, and 
  513.  cvs add on the new name.  The disadvantage of this approach is that the log 
  514.  entries for the old file's content do not carry over to the new file.  Other 
  515.  strategies avoid this quirk, but have other, stranger problems. 
  516.  
  517.  You can add directories just as you would ordinary files; 
  518.  
  519.  
  520. ΓòÉΓòÉΓòÉ 4.8. Writing good log entries ΓòÉΓòÉΓòÉ
  521.  
  522.  If one can use cvs diff to retrieve the actual text of a change, why should 
  523.  one bother writing a log entry?  Obviously, log entries can be shorter than a 
  524.  patch, and allow the reader to get a general understanding of the change 
  525.  without delving into its details. 
  526.  
  527.  However, a good log entry describes the reason the developer made the change. 
  528.  For example, a bad log entry for revision 1.7 shown above might say, ``Convert 
  529.  t to lower-case.''  This would be accurate, but completely useless; cvs diff 
  530.  provides all the same information, more clearly.  A better log entry would be, 
  531.  ``Make this test case-insensitive,'' because it makes the purpose clear to 
  532.  anyone with a general understanding of the code: HTTP clients should ignore 
  533.  case differences when parsing reply headers. 
  534.  
  535.  
  536. ΓòÉΓòÉΓòÉ 4.9. Handling conflicts ΓòÉΓòÉΓòÉ
  537.  
  538.  As mentioned above, the cvs update command incorporates changes made by other 
  539.  developers into your working directory.  If both you and another developer 
  540.  have modified the same file, CVS merges their changes with yours. 
  541.  
  542.  It's straightforward to imagine how this works when the changes apply to 
  543.  distant regions of a file, but what happens when you and another developer 
  544.  have changed the same line?  CVS calls this situation a conflict, and leaves 
  545.  it up to you to resolve it. 
  546.  
  547.  For example, suppose that you have just added some error checking to the host 
  548.  name lookup code.  Before you commit your change, you must run cvs update, to 
  549.  bring your sources into sync: 
  550.  
  551.                       $ cvs update
  552.                       cvs update: Updating .
  553.                       RCS file: /u/src/master/httpc/httpc.c,v
  554.                       retrieving revision 1.8
  555.                       retrieving revision 1.9
  556.                       Merging differences between 1.8 and 1.9 into httpc.c
  557.                       rcsmerge: warning: conflicts during merge
  558.                       cvs update: conflicts found in httpc.c
  559.                       C httpc.c
  560.                       $
  561.  
  562.  In this case, another developer has changed the same region of the file you 
  563.  have, so CVS complains about a conflict.  Instead of printing 'M httpc.c', as 
  564.  it usually does, it prints 'C httpc.c', to indicate that a conflict has 
  565.  occurred in that file. 
  566.  
  567.  To resolve the conflict, bring up the file in your editor.  CVS marks the 
  568.  conflicting text this way: 
  569.  
  570.                        /* Look up the IP address of the host.  */
  571.                        host_info = gethostbyname (hostname);
  572.                       <<<<<<< httpc.c
  573.                        if (! host_info)
  574.                         {
  575.                          fprintf (stderr, "%s: host not found: %s\n", progname, hostname);
  576.                          exit (1);
  577.                         }
  578.                       =======
  579.                        if (! host_info)
  580.                         {
  581.                          printf ("httpc: no host");
  582.                          exit (1);
  583.                         }
  584.                       >>>>>>> 1.9
  585.                        sock = socket (PF_INET, SOCK_STREAM, 0);
  586.  
  587.  The text from your working file appears at the top, after the '<<<' 
  588.  characters; below it is the conflicting text from the other developer. The 
  589.  revision number '1.9' indicates that the conflicting change was introduced in 
  590.  version 1.9 of the file, making it easier for you to check the logs, or 
  591.  examine the entire change with cvs diff. 
  592.  
  593.  Once you've decided how the conflict should be resolved, remove the markers 
  594.  from the code, and put it in its proper state.  In this case, since your error 
  595.  handling code is clearly superior, you could simply throw out the other 
  596.  developer's change, leaving the text like this: 
  597.  
  598.                        /* Look up the IP address of the host.  */
  599.                        host_info = gethostbyname (hostname);
  600.                        if (! host_info)
  601.                         {
  602.                          fprintf (stderr, "%s: host not found: %s\n", progname, hostname);
  603.                          exit (1);
  604.                         }
  605.                        sock = socket (PF_INET, SOCK_STREAM, 0);
  606.  
  607.  Once this is done, you can test your change and commit the file: 
  608.  
  609.                       $ make
  610.                       gcc -g -Wall -Wmissing-prototypes  -lnsl -lsocket  httpc.c  -o httpc
  611.                       $ httpc GET http://www.cyclic.com
  612.                       HTTP/1.0 200 Document follows
  613.                       Date: Thu, 31 Oct 1996 23:04:06 GMT
  614.                       ┬╖┬╖┬╖
  615.                       $ httpc GET http://www.frobnitz.com
  616.                       httpc: host not found: www.frobnitz.com
  617.                       $ cvs commit httpc.c
  618.  
  619.  It's important to understand what CVS does and doesn't consider a conflict. 
  620.  CVS does not understand the semantics of your program; it simply treats its 
  621.  source code as a tree of text files.  If one developer adds a new argument to 
  622.  a function and fixes its callers, while another developer simultaneously adds 
  623.  a new call to that function, and does not pass the new argument, that is 
  624.  certainly a conflict --- the two changes are incompatible --- but CVS will not 
  625.  report it.  CVS's understanding of conflicts is strictly textual. 
  626.  
  627.  In practice, fortunately, conflicts are rare.  Usually, they seem to result 
  628.  from two developers attempting to address the same problem, a lack of 
  629.  communication between developers, or disagreement about the design of the 
  630.  program.  Allocating tasks to developers in a reasonable way reduces the 
  631.  likelihood of conflicts. 
  632.  
  633.  Many version control systems allow a developer to lock a file, preventing 
  634.  others from making changes to it until she has committed her changes.  While 
  635.  locking is appropriate in some situations, it is not clearly a better solution 
  636.  than the approach CVS takes.  Changes can usually be merged correctly, and 
  637.  developers occasionally forget to release locks; in both cases, explicit 
  638.  locking causes unnecessary delays.  Furthermore, locks prevent only textual 
  639.  conflicts; they do not prevent semantic conflicts of the sort described above, 
  640.  if the two developers make their changes to different files.