Presentation is loading. Please wait.

Presentation is loading. Please wait.

Amandeep Jawa Worker Bee Software

Similar presentations


Presentation on theme: "Amandeep Jawa Worker Bee Software"— Presentation transcript:

1 Amandeep Jawa deep@worker-bee.com Worker Bee Software
Why CVS is Your Friend Amandeep Jawa Worker Bee Software Amandeep Jawa • 2/24/2019

2 Why You Should Care CVS can make your job easier
CVS saves YOUR time and effort CVS will save your butt (trust me) CVS is mandatory :-) Amandeep Jawa • 2/24/2019

3 Agenda Version Control Overview CVS Concepts Basic CVS Work Flow
Most Common Commands Additional Commands Commands you might not use Additional CVS Features Tips & Warnings References Summary Amandeep Jawa • 2/24/2019

4 What is Version Control Good For?
Maintaining project/file history - so you don’t have to worry about it. Managing collaboration on files and projects - so multiple developers can work on the same set of files Managing releases - so you know what files are in what version. Amandeep Jawa • 2/24/2019

5 CVS Concepts CVS becomes easy to use once you understand the concepts behind it: The Repository: The Magic Place That Holds All Versions of Everything Your Working Copy(ies): The place(s) where you get to do whatever you want. The CVS program manages moving files between the two. Amandeep Jawa • 2/24/2019

6 Basic CVS Work Flow Get a working copy Make changes in your copy
Test them locally Integrate them with any changes made to the Repository Commit them back to the Repository Repeat these steps until a release is ready Tag the release Start making changes again for next release Get a working copy: use checkout Make changes in your copy: with your favorite editor Test them locally:compile & debug Integrate them with any changes made to the Repository: You may want to first see what has changed with cvs -n update and THEN do a real update. Then fix conflicts and incompatibilities & test the code some more Commit them back to the Repository: commit Repeat these steps until a release is ready Tag the release: tag Start making changes again for next release Amandeep Jawa • 2/24/2019

7 CVS Command Structure (Commandline)
cvs [global options] command [command options] files There a few global options - most useful are: -n: don’t actually DO the next command - just show what you would do. Really useful for update -H: display help on the given command -q or -Q: quiet or VERY quiet Each command has its own set of options By default most commands operate recursively - be careful Don’t get bogged down in remembering all the options on the pages to follow - remember that cvs --help is always there for you. Amandeep Jawa • 2/24/2019

8 Common Commands Overview
Checkout: Makes your working copy Update: Updates your working copy with the latest files from the Repository Commit: Commits the latest changes from your working copy to the Repository Log: Look at the history of a file(s) Diff: Compare two versions of a file Tag: Label a version (also used for branching) Remember that most commands have MANY options Amandeep Jawa • 2/24/2019

9 Checkout Makes your working copy from the Repository
cvs checkout <project_name> Run this command from the parent directory of your working copy Useful command options include: -r to get a specific revision or symbolic tag E.g: cvs checkout -r 1.3 my_project -D to get a specific date E.g: cvs checkout -D 17 May 2001 my_project E.g: cvs checkout -D 2 weeks ago my_project Amandeep Jawa • 2/24/2019

10 Update Updates your working copy with the latest files from the Repository cvs update <file/directory name> Merges changes from the Repository into your code unless you tell it not to Reports the state of the files in your working copy Useful global options include: -n & -q Useful global options include: -n Instructs CVS to not actually perform an update, but rather show the output that would result if it did E.g: cvs -n update my_project_dir -q Instructs CVS to show only the files that have changed rather than all files E.g: cvs -q update my_project_dir Amandeep Jawa • 2/24/2019

11 Update (continued) Useful command options include:
-A Remove all “sticky tags” so that the latest version can be retrieved -d Creates & updates any new project directories created -j Can be used to retrieve a specific file/folder version (will set a “sticky tag”) -p Prunes empty directories We recommend always using -dp Useful command options include: -A Remove all “sticky tags” so that the latest version can be retrieved E.g: cvs update -A my_project_dir -d Creates & updates any new project directories created E.g: cvs update -d my_project_dir -j Can be used to retrieve a specific file/folder version (will set a “sticky tag”) E.g: cvs update -j1.3 Silly.java -p Prunes empty directories We recommend always using -dp Amandeep Jawa • 2/24/2019

12 Update (continued 2) Update reports the state of each file with a line for every file such as: X somefile.java where X may be: A: File added but not committed C: Conflict detected - working copy must be hand-merged M: Modified - you have modified your working copy & it has not been committed to the Repository yet R: File removed but not committed U: File was updated from Repository ?: File is not in Repository & is unknown to CVS Example output from cvs update . : M Toast.java rcsmerge: warning: conflicts during merge cvs update: conflicts found in Silly.java C Silly.java ? web/WEB-INF/lib Amandeep Jawa • 2/24/2019

13 Update (continued 3) If a conflict occurs, there is nothing to panic about - conflicts are usually easy to fix. A conflict area will be marked in the working copy like this: <<<<<<< file name <the uncommitted changes in your working copy> ======= <changes committed to the Repository since you last updated> >>>>>>> 1.7 To resolve the conflict, simply edit the file & replace the conflict area with whatever SHOULD be there. You may need to discuss the area with the other developer. Example of a conflict: public static void main(String[] args) { <<<<<<< Silly.java System.out.println("This is our new version 2.0") System.out.println("this is a bug fix on a branch"); ======= System.out.println("This is our new version this is a bug fix on a branch"); System.out.println("Sheesh - here we are again"); >>>>>>> } Amandeep Jawa • 2/24/2019

14 Commit Commits the latest changes from your working copy to the Repository cvs commit <filename> After committing, you will be prompted for a log comment. You must enter a log comment when you commit Useful command options include: -m to enter a log comment without being prompted You must enter a log comment when you commit - make a it a simple 1 line english explanation of whatever changes you made - such as “added comments”, “fixed parsing algorithm” Use -m to enter a log comment without being prompted E.g: cvs commit -m”my useful comment” my_project Amandeep Jawa • 2/24/2019

15 Log Look at the history of a file(s)
cvs log <file or directory name> Amandeep Jawa • 2/24/2019

16 Diff Compare two versions of a file
If one file is specified, it is compared against the repository, a tagged version, a revision, or a dated version If 2 files are specified, they are compared. The files can be specified by revision number, tag, or date If one file is specified, the current file is compared against the repository, or the current file is compared against the version that existed with a given revision number, tag, or date: cvs diff <file or directory name> cvs diff -r <revision or tag> <file or directory name> cvs diff -D <date> <file or directory name> If 2 files are specified, they are compared. The files can be specified by revision number, tag, or date: cvs diff -r <1st revision or tag> -r <2nd revision or tag> <file or directory name> cvs diff -D <1st date> -D <2nd date> <file or directory name> cvs diff -D <date> -r <revision or tag> <file or directory name> Amandeep Jawa • 2/24/2019

17 Diff (continued) A difference area will be marked in the working copy like this: < <the lines from the 1st file (or the repository> --- > <the lines from the 2nd file (or the current version> Various useful options exist including -c which shows lines of context around each area of difference Output example cvs diff -r1.6 -r1.1 Silly.java: Index: Silly.java =================================================================== RCS file: /Users/deep/Documents/Development/Projects/cvstest/my_cvs_root/my_project/Silly.java,v retrieving revision 1.6 retrieving revision 1.1 diff -r1.6 -r1.1 34c32 < System.out.println("This is our new version this is a bug fix on a branch"); --- > System.out.println("Hoa nelly!"); Amandeep Jawa • 2/24/2019

18 Tag Label a version or create a branch cvs tag <tag_name>
Tag names must start with a letter & can only contain numbers, letters, “-”, & “_” Useful command options: -d removes the tag -F moves the tag to the given revision or current version -b is used to create a branch tag - which is how a branch is started. Amandeep Jawa • 2/24/2019

19 Additional Commands Overview
Add: Adds a new file or folder to the Repository (be careful with binary files) Remove: removes a file from the Repository Branch: Allows you to make changes to an old version of the project & later integrate this into the latest version Status: Gives you detailed information about a file Amandeep Jawa • 2/24/2019

20 Add Adds a new file or folder to the Repository
cvs add <file or folder> Adding a folder is simple - but note it does not add the contents Adding files is a 2 step process If the file is a binary file, make sure you add it with the -kb option Adding a folder is simple - but note it does not add the contents - you can add the folder & then add what is inside it with cvs add . Adding files is a 2 step process - first add & then commit Amandeep Jawa • 2/24/2019

21 Remove Removes a file or folder from the Repository
cvs remove <file or folder> After removing a folder you should prune it When removing a file you must remove it from the file system first Removing files is a 2 step process After removing a folder you should cd into it and run cvs update -p to prune it. When removing a file you must either remove it from the file system first or you must specify the -f option to do this for you. Removing files is a 2 step process - first remove & then commit. Amandeep Jawa • 2/24/2019

22 Branch Allows you to make changes to an old version of the code & later integrate this into the latest version The image is from Mozilla.org Amandeep Jawa • 2/24/2019

23 Branch (Continued) To create a branch:
Make a new directory you want to use for the branch Cd to the new directory’s parent directory Get the version you want to branch from: cvs checkout -d <new_directory> -r <original_tag> <project_name> Cd into the new project directory Make a branch: cvs tag -b <branch_tag_name> Prepare the branch for editing: cvs update -r <branch_tag_name> Make a new directory you want to use for the branch: mkdir myprojbranch Cd to the new directory’s parent directory Get the version you want to branch from: cvs checkout -d <new_directory> -r <original_tag> <project_name> e.g: cvs checkout -d myprojbranch -r basic_version my_project -Cd into the new project directory - Make a branch: cvs tag -b <branch_tag_name> cvs tag -b new_bugfix - Prepare the branch for editing: cvs update -r <branch_tag_name> cvs update -r new_bugfix Amandeep Jawa • 2/24/2019

24 Branch (Continued 2) To merge a branch back into the main development tree: cvs update -j <branch_tag_name> If you have any conflicts, deal with them as usual. Example output from merge cvs update -j new_bugfix . : cvs update: Updating . M Silly.class M Silly.java RCS file: /Users/deep/Documents/Development/Projects/cvstest/my_cvs_root/my_project/Silly.java,v retrieving revision 1.6 retrieving revision Merging differences between 1.6 and into Silly.java rcsmerge: warning: conflicts during merge ? a_mysterious_file.txt Amandeep Jawa • 2/24/2019

25 Status Gives you detailed information about a file
cvs status <file name> Tells you about any sticky tags that are set Example output from cvs status Silly.java: =================================================================== File: Silly.java Status: File had conflicts on merge Working revision: Result of merge Repository revision: /Users/deep/Documents/Development/Projects/cvstest/my_cvs_root/my_project/Silly.java,v Sticky Tag: basic_version (revision: 1.6) Sticky Date: (none) Sticky Options: (none) Amandeep Jawa • 2/24/2019

26 Commands you might not use
Import: For putting an entire set of files into the Repository - used to start a project Export: Create a working copy with NO CVS information - good for src dumps Help: Prints out command summaries Admin: Allows you to modify various things such as log messages & the file’s keyword substitution mode Amandeep Jawa • 2/24/2019

27 Additional CVS Features
cvsrc: lets you set default command options for yourself cvswrappers: set default options for specific file types cvsignore: sets file types to just ignore loginfo, taginfo, etc: set requirements for logging & tagging format etc. Keyword expansion Watches, s, Locking etc. Annotation Examples of keyword expansion: $Revision$ --> $Revision 1.2$ Author, Date, Header, Id, Name, etc. Amandeep Jawa • 2/24/2019

28 Tips & Warnings Turn off keyword expansion for binary files
Sticky Tags are set whenever you get a file by revision, tag or date Checkout from top Add & commit -dp for latest directories Important to turn off keyword expansion for binary files when you add them (-kb) - Recommend setting up .cvswrappers Sticky Tags are set whenever you get a file by revision, tag or date - just remember that & you will not get confused as to why you can’t commit a file. Use update -A to clear a sticky tag Amandeep Jawa • 2/24/2019

29 More Tips & Warnings Date can be specified in English like “yesterday” or “2 weeks ago” Recursive Amandeep Jawa • 2/24/2019

30 References Version Management with CVS: by Per Cederqvist, CVS Pocket Reference: Gregor Purdy, published by O’Reilly Open Source Development with CVS : Fogel & Bar, published by Coriolis cvsbook.red-bean.com (Book/Partially Online) Amandeep Jawa • 2/24/2019

31 Summary CVS makes your job easier by maintaining your files’ history & making it possible to have multiple developers working on the same set of files without bloodshed CVS moves files between the Repository & your working copy Help: Prints out command summaries Amandeep Jawa • 2/24/2019


Download ppt "Amandeep Jawa Worker Bee Software"

Similar presentations


Ads by Google