Version control with CVS - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Version control with CVS

Description:

Reverting Changes. to revert a file in your local copy (based ... directory and file renames cannot be reverted. 2005-04-16. 28 /33. DP&NM. Adding Binary Files ... – PowerPoint PPT presentation

Number of Views:62
Avg rating:3.0/5.0
Slides: 34
Provided by: homePos
Category:

less

Transcript and Presenter's Notes

Title: Version control with CVS


1
Version control with CVS
  • Apr. 16. 2005
  • Joonmyung Kang
  • eliot_at_postech.ac.kr
  • DPNM Lab., Dept. of CSE, POSTECH

2
Presentation Outline
  • Introduction
  • Version Control Basics
  • CVS
  • Usage
  • Demo

3
Version Control Basics
  • copy of the source code kept in a repository
  • repository records the history of code
  • developers keep a local copy of their code
  • developers can update their local copy to get
    changes others committed to the repository
  • commit changes to the repository

4
Source Code Management
  • The Problem you and a couple partners are
    working on a project. How do you handle the
    source code?
  • The hard way you designate a guy to maintain the
    golden copy. As you finish code you give it to
    him, and he places it in a directory.
  • Forces a guy to do this manually
  • What if two people are working on the same file?
  • What if you want to go back to an older version
    of a file?
  • What if you want to maintain multiple forks of
    the program?

5
Source Code Management
  • These are the problems source code management
    intended to solve. Effectively it is a database
    for source code that eases the problems of
  • Multiple people in many places working on the
    same code
  • Retrieving old versions of files
  • Keeping logs about what changed in a file
  • Integrating changed code
  • Generating release builds

6
The Concept
Repository
Checkout
7
CVS
  • manages changes on a per file basis
  • log messages for each change
  • remote repository access
  • tagging a set of files for later access
  • invoked as cvs from the command line
  • most operations are not atomic
  • never Ctrl-C cvs because it will leave your
    repository in an inconsistent state

8
Basic Tasks
  • administrative setup
  • getting a working copy
  • committing and understanding changes
  • adding a file
  • removing a file
  • updating to the latest code

9
What You Can Do
  • You can save every version of every file.
  • Storing only the differences between versions
  • When bugs creep in, you can retrieve old versions
    and see differences
  • CVS merges the different work of each developer

10
How to use CVS
  • Repository setup
  • Creating a directory tree
  • Getting the working copy
  • Committing changes

11
CVS Environment Variables
  • CVSROOT tells CVS the location of your repository
  • CVS_RSH tells CVS how to connect to remote
    repositories
  • you want to use ssh
  • CVSEDITOR the program CVS invokes for editing
    commit messages
  • CVS will use EDITOR if CVSEDITOR is not defined
  • defaults to vi if neither defined

12
Repository Setup
  • .cshrc or .tcshrc (C shell)
  • setenv CVSROOT pserveryourid_at_fraser.postech.ac.k
    r/home/cvs
  • .bashrc (bash shell)
  • Export CVSROOTpserveryourid_at_fraser.postech.ac.k
    r/home/cvs

13
Creating a Directory Tree
  • cd wdir
  • cvs import m Message rdir vtag rtag
  • wdir working directory
  • rdir remote directory
  • vtag vendor tag
  • rtag release tag
  • cvs import m Message Project park D100

14
Getting the Working Copy
  • cd ..
  • mv wdir wdir.orig
  • cvs checkout rdir
  • mv Project Project.orig
  • cvs checkout Project

15
Committing Changes
  • cvs diff main.c
  • cvs commit m Message main.c

16
Getting the Working Copy with Date
  • cvs checkout D date_spec Project
  • Date_spec a date description
  • cvs checkout D 2004-09-01 Project

17
Update Codes
  • M file modified in your local copy
  • U file brought up to date with repository
  • P (same as U but happens more quickly)
  • ? file is in your local copy but not in the
    repository
  • C a conflict was detected between your local
    copy and the repository copy
  • A file is scheduled to be added to the repository
  • R file is scheduled to be removed from the
    repository

18
Conflicts on Update
  • your partners may have made changes that conflict
    with your changes
  • known as a conflict
  • C code on update
  • edit the file to resolve the conflict
  • commit only after you have resolved the conflict

19
Others
  • Adding new files
  • Removing files
  • Getting a working copy with date

20
Adding Files and Directories
  • to schedule a file in a directory already in the
    repository to be added
  • cvs add file
  • you must commit the file before it is added
  • to add a directory inside a directory already in
    the repository
  • cvs add dir
  • there is no need to commit the directory because
    cvs doesnt really understand directories

21
Removing a File
  • files are not removed from the repository until
    you commit them.
  • to remove a file from the repository and then
    from cvs
  • rm file
  • cvs remove file

22
Removing a Directory
  • cvs doesnt really understand directories, and
    thus has special behavior that works most of the
    time it prunes empty directories
  • remove all the files in the directory and from
    cvs
  • cd dir
  • rm file1 file2
  • cvs rm file1 file2
  • make this easier with some shell magic
  • rm file1 file2
  • cvs !!

23
Tagging the Current State
  • you can mark the current state of your repository
    with a tag
  • cvs tag tag-name
  • to checkout a tagged release
  • cvs checkout -r tag-name
  • this sets a stick tag which will stay with your
    file until you unset it with
  • cvs update -A

24
Viewing Changes
  • to view the difference between your current file
    and the latest file in the repository
  • cvs diff file
  • for differences between your file and a some
    previous version X.Y
  • cvs diff -r X.Y file
  • to view the commit messages for a file
  • cvs log file

25
Renaming a File
  • to rename a file
  • mv old new
  • cvs remove old
  • cvs add new
  • cvs commit old new
  • note that you loose a files revision history
    when you move it

26
Renaming Directories
  • mkdir newdir
  • cvs add newdir
  • mv olddir/ newdir
  • cd olddir
  • cvs remove file1 file2
  • cd ../newdir
  • cvs add file1 file2
  • cvs commit
  • cvs update -P

27
Reverting Changes
  • to revert a file in your local copy (based on
    version X.Y) to version W.Z in the repository
  • cvs update -j X.Y -j W.Z file
  • order matters
  • directory and file renames cannot be reverted

28
Adding Binary Files
  • cvs expands the magic keywords like Id
  • bad for binary files
  • to add a binary file to cvs use
  • cvs add -kb binary-file
  • -kb tells cvs that the file is a binary file
  • this is a sticky option

29
Branching
30
Keyword expansion
  • Author
  • Author eliot
  • Date
  • Date 2005/03/21 143232
  • Id
  • Id hello.c,v 1.1 2005/03/21 143232 eliot Exp
  • Revison
  • Revision 1.1
  • Source
  • Source /home/cvs/hello_world/hello.c,v
  • Log
  • Log hello.c,v Revision 1.2 2005/03/21
    143532 eliotlog messageRevision 1.1
    2005/03/21 143232 eliotThis is the first log
    messages

31
The Future of Version Control
  • bitkeeper http//www.bitkeeper.com
  • subversion http//subversion.tigris.org
  • arch http//arch.quackerhead.com/lord
  • opencm http//www.opencm.org

32
Conclusion
  • Do not trust CVS
  • CVS is not Backup system
  • DPNM CVS
  • http//dpnm.postech.ac.kr/cvs/
  • DPNM homepage -gt Links -gt DPNM CVS Homepage

33
Demo
Write a Comment
User Comments (0)
About PowerShow.com