You are on page 1of 19

CVS Tutorial

An Introduction to Using
C VS
Versions System
Concurrent
* history: when? why?
* collaboration * examine old revisions
* bugfix releases

Steve Robbins – p. 1/1


CVS Tutorial

checkout

Repository

commit

Workspace – p. 2/1
CVS Tutorial

checkout

commit commit

edit edit

– p. 3/1
CVS Tutorial

      
      
     
  
    









cvs −d repository−name checkout module−name

> cvs −d /software/examples checkout hello


cvs checkout: Updating hello
U hello/Makefile
U hello/hello.c
U hello/world.c
– p. 4/1
U hello/world.h
CVS Tutorial
> cd ~/src
> cvs −d /software/examples checkout hello
cvs checkout: Updating hello
U hello/Makefile
U hello/hello.c
U hello/world.c
U hello/world.h

checkout
> cd hello
> ls
CVS Makefile hello.c world.c world.h

> ls CVS
Entries Repository Root
– p. 5/1
CVS Tutorial

> cvs commit


cvs commit: Examining .

CVS: −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
CVS: Enter Log. Lines beginning with ‘CVS:’ are removed automatically
CVS:
CVS: Committing in .
$CVSEDITOR
$EDITOR

Checking in hello.c;
/software/examples/hello/hello.c,v <−− hello.c
commit new revision: 1.2; previous revision: 1.1
done

– p. 6/1
CVS Tutorial
> cvs add README
cvs add: scheduling file ‘README’ for addition
cvs add: use ’cvs commit’ to add this file permanently
> cvs commit
cvs commit: Examining .
RCS file: /software/examples/hello/README,v
done
Checking in README;
/software/examples/hello/README,v <−− README
initial revision: 1.1
done
add commit

create ChangeLog ChangeLog


file

Remove files: rm filename; cvs remove filename


– p. 7/1
Rename files: remove then add
CVS Tutorial
The Source Tree

1.1.3
release−2_0

1.4
1.3
1.2
1.3

1.2
1.1.2

1.1
1.0.1
1.2.2.1

release−1_1
1.3
1.0
1.1

file C
1.2

1.2
1.1

1.1

release−1_0
1.0
1.0

1.0
1.0

file D file E – p. 8/1


file A file B
CVS Tutorial

1.4
1.2 1.3
1.1
README Makefile

1.1
1.0

1.0
1.1

tag

1.0
hello.c

1.0
1.4
README hello.c
Makefile

> cvs tag release−1_0


release−1_0
cvs tag: Tagging .

1.4
T Makefile

1.2 1.3
T README
T hello.c

1.1

1.1
1.0

1.0
1.0
README hello.c

Moral: use cvs tag −c ... Makefile


– p. 9/1
CVS Tutorial
Collaborative Development

checkout checkout

You Developer X. – p. 10/1


CVS Tutorial

update commit

You Developer X.
> cvs update
cvs update: Updating .
U ChangeLog
– p. 11/1
U README
CVS Tutorial
> cvs commit
cvs commit: Examining .
cvs commit: Up−to−date check failed for ‘README’
cvs commit: Up−to−date check failed for ‘hello.c’
cvs [commit aborted]: correct above errors first!

1.4
1.1
commit
1.3
checkout
1.2
1.1

1.1
1.0

1.0
1.0

README hello.c
Makefile

You Developer X.
Moral: update before commit. – p. 12/1
CVS Tutorial
Update (revisited)
> cvs update
cvs update: Updating .
U ChangeLog
M Makefile
RCS file: /software/examples/hello/hello.c,v
retrieving revision 1.5
retrieving revision 1.6
Merging differences between 1.5 and 1.6 into hello.c

1.3
M hello.c

1.6
? hello

1.5
1.1

1.2
1.4
1.3

1.1
1.2
1.1
1.0

1.1

1.0
1.0
1.0
README ChangeLog
hello.c – p. 13/1
Makefile
CVS Tutorial
> cvs update
cvs update: Updating .
RCS file: /software/examples/hello/hello.c,v
retrieving revision 1.9
retrieving revision 1.10
Merging differences between 1.9 and 1.10 into hello.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in hello.c
C hello.c
int main( int ac, char* av[] )
{
int show_doom = 0;
int main( int ac, char* av[] )
{ if ( ac > 1 && strcmp( av[1], "−d" ) == 0 )
if ( ac != 1 ) show_doom = 1;
{
fprintf( stderr, "usage ..." ); printf( "Hello, world.\n" );
return 1;
} if ( show_doom )
printf( "Hello, world.\n" ); printf( "You have %f days until the "
" millenium.\n", doom_days() );
} }

commit
1.10

int main( int ac, char* av[] ) int main( int ac, char* av[] )
1.9

{ {
printf( "Hello, world.\n" ); printf( "Hello, world.\n" );
} }
hello.c

You Developer X. – p. 14/1


CVS Tutorial
Conflict Resolution

int main( int ac, char* av[] ) int main( int ac, char* av[] )
{ {
if ( ac != 1 ) { int show_doom = 0;
fprintf( stderr, "usage ..." );
return 1; if ( ac > 1 && strcmp( av[1], "−d" ) == 0 )
} show_doom = 1;
printf( "Hello, world.\n" );
} printf( "Hello, world.\n" );

if ( show_doom )
hello.c before update printf( "You have %f days until the "
" millenium.\n", doom_days() );
}

revision 1.10
int main( int ac, char* av[] )
{
<<<<<<< hello.c
if ( ac != 1 ) {
fprintf( stderr, "usage: hello\n" );
return 1;
}

=======
int show_doom = 0;

if ( ac > 1 && strcmp( av[1], "−d" ) == 0 )


show_doom = 1;

>>>>>>> 1.10
printf( "Hello, world.\n" );

if ( show_doom )
printf( "You have %f days until the "
" millenium.\n", doom_days() );
}

– p. 15/1
hello.c after update
CVS Tutorial
Why Branch?

1.1
1.6
1.5
1.1

1.0
ChangeLog
1.4

release−1_0
1.3
1.1
1.0

1.2
1.1
1.0
1.0

– p. 16/1
README Makefile hello.c
CVS Tutorial
release−3_5

2.2.
1.1

3.7
1.1

1.0

2.4
2.5. 3.6.
1.2 1.1

foo.c
2.5.
1.1

2.3
rele
ase−
4_1

3_4
−fix
es
−3_

release−3_4
ase
rele

2.5

> cvs tag −b release−3_4−fixes


cvs tag: Tagging .
2.4

3.6

2.1.2

T README
T Makefile README Makefile hello.c
– p. 17/1
T hello.c
CVS Tutorial
checkout (revisited)
cvs −d repository−name checkout module−name
= latest revisions on HEAD branch (main trunk)

cvs −d repository−name checkout −r release−tag module−name


= revisions selected by tag name

cvs −d repository−name checkout −r branch−tag module−name


= latest revisions on specified branch

also: −D date examples: −D "13:45 1 December 1997"


−D "5 days ago" – p. 18/1
CVS Tutorial
Command Summary
cvs −d repository init
= create a new repository

cvs −d repository import module vendor−tag release−tag


= create a new module

cvs −d repository checkout [−r tag] module


cvs update [−r tag]

cvs add file ...


cvs remove file ...
cvs commit
cvs tag −c [−b] tag

cvs log
= list log messages, tags, etc
cvs status
= up−to−date, locally−modified, etc

cvs diff −r rev1 −r rev2 file


– p. 19/1
= difference between specified revisions

You might also like