CVS - Concordia University

advertisement
DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING
CONCORDIA UNIVERSITY
CVS & Eclipse
revision 1.3 – Jan 19, 2009
by Emil Vassev & Joey Paquet
CVS & Eclipse
1
Feb 26, 2006
Outline




Version Control Systems - Intro
CVS
 Basic Concepts
 CVS Branches
 Quick Reference to CVS Commands
CVS & Eclipse
 Getting Started
 Putting a Project into CVS
 Getting a Project from CVS
 Updating/Committing Changes
 Comparing Two File Versions
Rational ClearCase
CVS & Eclipse
2
Version Control Systems
CVS & Eclipse
3
Version Control Systems
:: Why do We Need Them? - I

Why use a version control system?




To have a common repository for all project files available and
updated remotely.
To make sure that concurrent changes to the same file are
properly handled.
To allow the branching of versions in a seamless operation.
To avoid copying all files when creating a new version of a
project.
CVS & Eclipse
4
Version Control Systems
:: Why do We Need Them? - II

Why use a version control system?




To make sure that everybody in a team is always using the
correct version of project files.
To ensure a proper rollback sequence in the event that some
changes need to be undone.
To compare the differences between different file versions
(using diff).
To access previous project versions seamlessly (using version
tagging)
CVS & Eclipse
5
Version Control Systems
:: General Goals
Maximizing productivity by automating tasks.
 Reducing confusion, minimizing mistakes.
 Maximizing
software integrity, traceability, and
accountability.
 Assisting developers in providing coordinated changes
to software products and components.
 Accurately recording the composition of versioned
software products evolving into many revisions and
variants.
 Reconstructing
previously
recorded
software
components versions and configurations.

CVS & Eclipse
6
Version Control Systems
:: Multiple Developers & Merging Changes
More advanced version control systems, like Rational’s
ClearCase and Microsoft’s SourceSafe allow for
multiple developers to work on the same file.
 Then, when the last person checks it in, they have to
option to merge the different paths together. Meaning
that two people can change the same file and both save
their changes.
 Merging changes is a useful feature, but it has its flaws.
What if two people complete different variations of the
same change, which one should you keep?

CVS & Eclipse
7
Version Control Systems
:: Baseline - I
A major concept of a version control system is the
concept of a baseline.
 All projects have this, for example, MS PowerPoint we
are using for this presentation is Version 11.24.8036
 11 is the major product version, 24 is the minor version,
and 8036 is the build version.
 The build version generally goes up by one every time a
file is checked in, while the major/minor versions are
usually advanced manually as the product is rolled out.

CVS & Eclipse
8
Version Control Systems
:: Baseline - II
As a developer, you would have the option of rolling
back to a previous baseline if something failed.
 Baselines are also important in project management and
planning, especially in iterative development.
 A project manager might decide Prototype Version 1.0
would have certain features, and Version 1.1 would have
others, so the final version of 1.0 might be 1.0.1087.

CVS & Eclipse
9
CVS
CVS & Eclipse
10
CVS
:: Basic Concepts






Version control is a process by which you can keep a recorded
history of the changes to your files.
CVS states for Concurrent Version System (CVS).
A version control system typically has two parts - a version
control server and clients.
The version control server is accessed over a network – a local
network or wide area network such as the Internet – by a version
control client.
The version control server manages access to the version control
repository.
Version control clients come in a variety of flavors: command
line clients, window/GUI clients (WinCVS), plug-in clients (for
applications like Eclipse and file explorers).
CVS & Eclipse
11
CVS
:: Basic Concepts

Repository
 This is where a copy of your files and directories are stored.
CVS uses some special file structure for tracking the
differences between subsequent versions of a file.

Working Copy and Workspace
 This is a copy of a file(s) (or project) in your local file system
(not in the Repository). Workspaces map to Eclipse projects.

Project
 Group of files. A project is often a complete program;
although, a project could be code for a software library or the
XML/HTML files for documentation.
CVS & Eclipse
12
CVS
:: Basic Concepts

Commit
 This is the process of saving files to the Repository. You may
commit specific files or a whole project to the Repository.

Synchronize
 This is the process of updating the local files on your computer
with corresponding files in the repository.

Checkout
 This is the process of retrieving files from the Repository, i.e.
downloading a local copy to your machine.
CVS & Eclipse
13
CVS
:: CVS Branches

What is a Branch?
 A CVS branch is a collection of revisions that for some reason
should not be committed onto the main trunk of development.
If we want to work on a part of the code doing changes that we are not
going to share until we are not satisfied with the result we could work on
our own branch, without disturbing anyone else.




Branching is a powerful mechanism for controlled isolation.
The original set of versions, before the branch was created, is
called the main line or main branch.
After a branch is created the main line is still the default
version.
We can always merge changes from a branch into the main line
or vice-versa.
CVS & Eclipse
14
CVS
:: CVS Branches

Branching Scenario

Two programmers, Paul and Wing, working on
separate branches of the same project.
 Paul will branch off main and modify some files
while Wing continues to work on the main branch,
also modifying files.
 Paul will then merge his branch back to the main
branch. In doing so, Paul will address the resulting
merge conflicts.
CVS & Eclipse
15
CVS
:: CVS Revisions



CVS maintains unique numbers for each each version of the files
under CVS.
Revision numbers could be somewhat like “1.1”, “1.2”, “1.3.2.2”
or “1.3.2.2.4.5”.
By default revision 1.1 is the first revision of a file. Each
successive revision is given a new number by increasing the
rightmost number by one.
Example: 1.1, 1.2, 1.3, 1.4
CVS & Eclipse
16
CVS
:: Assigning Revisions - I




Useful when we want to distinguish different releases of same
software by its version number.
Example: 1.x states for release “one” and 2.x for release “two”
We use the “-r” option to “cvs commit” to assign revisions
manually.
Example: To bring all the files up to revision 2.0 (including
those that haven't changed), we invoke:
cvs commit -r 2.0
The number we specify with “-r” must be larger than any existing
revision number.
If we want to maintain several releases in parallel, we need to use
a branch.
CVS & Eclipse
17
CVS
:: Assigning Revisions - II





Eclipse does not support "cvs commit -r“.
Usually we would like to change the revision number from 1.x to
2.x if, for example, we completely re-written the file.
Changing revisions from 1.x to 2.x would typically be something
we should do on a whole project, in order to baseline for a new
release of the project.
That sort of thing is often better managed by using branches,
though.
Eclipse support for maintaining different releases “Versions”.
CVS & Eclipse
18
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Global options:





--allow-root=rootdir
Specifies legal CVSROOT directory (server only)
-a
Authenticates all communication (client only)
-b
Specifies RCS location
-d root
Specifies the CVSROOT.
-e editor
Edits messages with editor.
CVS & Eclipse
19
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Global options - Continue:






-f
Does not read the `~/.cvsrc' file.
-H
--help
Prints a help message.
-n
Does not change any files.
-Q
Be really quiet.
-q
Be somewhat quiet.
CVS & Eclipse
20
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Global options - Continue:




-r
Makes new working files read-only.
-s variable=value
Sets a user variable.
-T tempdir
Puts temporary files in tempdir.
-t
Traces CVS execution.
CVS & Eclipse
21
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Global options - Continue:


-v
--version
Displays version and copyright information for CVS.



-w
Makes new working files read-write.
-x
Encrypts all communication (client only).
-z gzip-level
Sets the compression level (client only).
CVS & Eclipse
22
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands:





add [options] [files…]
Adds a new file/directory.
admin [options] [files…]
Administration of history files in the repository.
annotate [options] [files…]
Shows last revision where each line was modified.
checkout [options] modules…
Gets a copy of the sources.
commit [options] [files…]
Checks changes into the repository.
CVS & Eclipse
23
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:





diff [options] [files…]
Shows differences between revisions.
edit [options] [files…]
Gets ready to edit a watched file.
editors [options] [files…]
Sees who is editing a watched file.
export [options] modules…
Exports files from CVS.
history [options] [files…]
Shows repository access history.
CVS & Eclipse
24
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:




import [options] repository vendor-tag release-tags…
Imports files into CVS, using vendor branches.
init
Creates a CVS repository if it doesn't exist.
kserver
Kerberos authenticated server.
log [options] [files…]
Prints out history information for files.
CVS & Eclipse
25
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:





login
Prompts for password for authenticating server.
logout
Removes stored password for authenticating server.
pserver
Password authenticated server.
rannotate [options] [modules…]
Shows last revision where each line was modified.
rdiff [options] modules…
Shows differences between releases.
CVS & Eclipse
26
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:





release [options] directory
Indicates that a directory is no longer in use.
remove [options] [files…]
Removes an entry from the repository.
rlog [options] [files…]
Prints out history information for modules.
rtag [options] tag modules…
Adds a symbolic tag to a module.
server
Rsh server.
CVS & Eclipse
27
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:

status [options] files…
Displays status information in a working directory.
 tag [options] tag [files…]
Adds a symbolic tag to checked out version of files.
 unedit [options] [files…]
Undoes an edit command.
 update [options] [files…]
Brings work tree in sync with repository.
CVS & Eclipse
28
CVS
:: Quick Reference to CVS Commands

A CVS Command looks like this:
cvs [ global_options ] command [ command_options ] [ command_args ]

Commands - Continue:

version
Display the version of CVS being used. If the repository is remote, display
both the client and server versions.


watch [on|off|add|remove] [options] [files…]
on/off: turns on/off read-only checkouts of files.
add/remove: adds or removes notification on actions.
watchers [options] [files…]
Sees who is watching a file.
CVS & Eclipse
29
CVS & Eclipse
CVS & Eclipse
30
CVS and Eclipse
:: Getting Started
First, you should enable the Eclipse perspective for CVS.
 From Window menu: [Window  Open Perspective  Other …]
 From the “Select Perspective” window pick up CVS Repository Exploring.
Second, you should show the CVS Repositories view.
 From Window menu: [Window  Show View  CVS Repositories]
CVS & Eclipse
31
CVS and Eclipse
:: Getting Started
Next, you should connect to a CVS Repository.
 Right mouse click in the CVS Repositories
window.
 From the right mouse click menu select
[New → Repository Location ...]
 Complete the Add CVS Repository dialog as
shown.
 Location Host: alpha.cs.concordia.ca
 Repository path: enter the path of the cvs
repository.
 Connection Type: extssh
CVS & Eclipse
32
CVS and Eclipse
:: Getting Started


After validation, CVS Repositories window in Eclipse will show the
connected repository.
You can have multiple repositories.
CVS & Eclipse
33
CVS and Eclipse
:: Putting a Project into CVS








Select the project in the Navigator or other view.
Right click [Context MenuTeamShare Project...]
Follow the wizard for identifying your repository location and
and repository module name.
The Synchronize view opens, showing all your outgoing
changes.
Select the project in the Synchronize view.
Right click [Context MenuCommit].
Answer yes when prompted to add new files to version control.
Supply a release comment if you like.
The project now exists in the repository.
CVS & Eclipse
34
CVS and Eclipse
:: Putting a Project into CVS
Right mouse click in the CVS Repositories view and select Refresh
View to see your project in the repository.
CVS & Eclipse
35
CVS and Eclipse
:: Getting a Project from CVS







Select [WindowShow ViewOther].
Select [CVSCVS Repositories].
Right click [Context MenuNewRepository Location...].
Fill in the location information identifying your repository and
click Finish.
Expand the newly-created repository location.
Find the module you are interested in.
Right click [Context MenuCheck Out].
CVS & Eclipse
36
CVS and Eclipse
:: Updating/Committing Changes
If you have changed your source files and wish to commit those changes in your
files that are in CVS, you do the following:
 From the Java Perspective (or other similar perspective), right mouse click
on the project and select [Team  Commit... ]
 Enter a comment in the Commit dialog and press Finish.
New version for modified files
CVS & Eclipse
37
CVS and Eclipse
:: Comparing Two File Revisions (Versions)




From the Java Perspective (or other similar perspective), right mouse click on
the changed file and select [Team  Show Resource History]
The version history appears in the History Window.
Select the version you wish to compare with the current one.
Right mouse click and select Compare with Current Revision.
CVS & Eclipse
38
CVS and Eclipse
:: Comparing Two File Revisions (Versions)
Java Source Compare window shows up both file versions and highlights the
differences.
CVS & Eclipse
39
CVS and Eclipse
:: Branching with Eclipse and CVS
If you want to create an independent branch on which to work,
right-click on the project name and select [Team  Branch].
CVS & Eclipse
40
CVS and Eclipse
:: Branching with Eclipse and CVS
 A Create Branch dialog box is displayed.
 Enter a branch name like “JUnitTesting_B1“.
 Leave the check box checked for Start working in the branch.
 Notice that a version name is automatically filled in for you
called "Root_ JUnitTesting_B1“.
 You may choose a different name (so long as it doesn't conflict
with an existing CVS tag). It will be used later by the merge
editor to determine what has changed since branch creation.
 Click OK.
CVS & Eclipse
41
CVS and Eclipse
:: Branching with Eclipse and CVS
You should be able to see the result of your branch in two ways:
 By right-clicking the project and selecting Properties and then
CVS, you should see the JUnitTesting_B1 in the tag field.
 In the CVS Repositories view expand the Branches node.
CVS & Eclipse
42
CVS and Eclipse
:: Merging - I
 How to merge the changes done in a branch into another branch?
 The first step of the merge is to point the workspace to the target
branch. In our case, the target of the merge is the main branch.
 To switch the project contents to that of the main branch, rightclick on the JUnitTesting project in the Navigator view and
select [Replace With  Another Branch or Version].
 You should see a branch selection similar to the one below.
CVS & Eclipse
43
CVS and Eclipse
:: Merging - II
 The JUnitTesting_B1 branch is the one we were working on.
 To switch back to the main branch, select HEAD. This is the
CVS name for the main branch.
 The resource view should look like the one below. Notice the
version numbers correspond to what we committed. All the
version numbers are two digits. The branch name is gone which
implies the HEAD branch (or main).
CVS & Eclipse
44
CVS and Eclipse
:: Versioning - I
 Eclipse supports different software releases via versioning.
 To create a new version of your application right-click on the
project name in the Navigator view and select [Team  Tag as
Version].
CVS & Eclipse
45
CVS and Eclipse
:: Versioning - II
 Enter the version’s name.

The new version can be found in the CVS repositories under
“Versions” node:
CVS & Eclipse
46
Rational ClearCase
CVS & Eclipse
47
Rational ClearCase
:: Characteristics

ClearCase is a Software Configuration Management
System from Rational Software at IBM Inc.
Feature
Benefit
Sophisticated version
control
Manage files, directories and
other development assets across
the lifecycle
Gain control over personal
workspaces and enable seamless
access to the exact files and
directory versions that are
needed
Automated workspace
management
CVS & Eclipse
48
Rational ClearCase
:: Characteristics
Feature
Benefit
Parallel development
support including automatic
branching and advanced
merging and differencing
technology
Transparent, real-time
access to files and
directories
Work on the same code or
release, more easily resolve
conflicts, reduce confusion, and
get more done in a short amount
of time
Fast access to virtually any
version of any element
Support for disconnected
usage
Continue development efforts
while disconnected from the
network, easily synchronize
changes when reconnected to the
network
CVS & Eclipse
49
Rational ClearCase
:: Characteristics
Feature
Activity-based change
management
Build and release
management
IBM development support
Local, remote (WAN) and
Web client access
Benefit
Define and manage related
changes to assets as activities for
improved insight and efficiency
Optimize build times, improve
reproducibility of builds
Provide unified enterprise
application development
Access from the environments
and locations from which
developers work
CVS & Eclipse
50
Rational ClearCase
:: Characteristics
Feature
Benefit
Integration with leading IDEs
including Rational Application
Developer, Microsoft Visual
Studio 2005 and others
Allow developers to work in their
preferred environment
User authentication
Control access to software assets
Audit trails
Trace the origin and detail of changes
made to software assets, help meet
compliance requirements
Scalability from small
workgroups to geographically
distributed enterprises
Support evolving organizational needs
Integration with design,
development, build, test and
deployment tools
Manage and control software assets
across the lifecycle
CVS & Eclipse
51
Rational ClearCase
:: ClearCase Development Environment - I

The development environment managed by ClearCase
at its heart is a permanent, secure data repository.
 It contains data that is shared by all users: this includes
current and historical versions of source files, along
with derived objects built from the sources by
compilers, linkers, and so on.
 In addition, the repository stores detailed “accounting”
data on the development process itself: who created a
particular version (and when, and why), what versions
of sources went into a particular build, and other
relevant information.
CVS & Eclipse
52
Rational ClearCase
:: ClearCase Development Environment - II

Only ClearCase commands can modify the permanent data repository.
This ensures orderly evolution of the repository and minimizes the likelihood
of accidental damage or malicious destruction.
CVS & Eclipse
53
Rational ClearCase
:: Views and Transparent Access



Users access the ClearCase data repository through views.
A view is a software development work environment that is
similar to — but greatly improves on — a traditional
“development sandbox”.
Each view can easily be configured to access just the right source
data from the central repository:
 the up-to-date versions for development of the next major
release
 the versions that went into the port of Release X.Y to
hardware architecture Z
 the versions being used to fix bug #ABC in Release D.E
CVS & Eclipse
54
Rational ClearCase
:: Views and Transparent Access



A view is an isolated “virtual workspace”, which provides
dynamic access to the entire data repository. The changes being
made to a source file in a particular view are invisible to other
views.
Working in views, ClearCase users access version-controlled data
using standard pathnames and their accustomed commands and
programs.
A view can be accessed from any host in the local area network.
For example, a distributed build involves execution of build scripts on
several hosts at once, all in the same view.

Similarly, a view can be shared by several users, working on a
single host or on multiple hosts. One user might “peek” into
another's view, just to see what changes are being made.
CVS & Eclipse
55
Rational ClearCase
:: Version Control

The most basic requirement for a software configuration
management system is version control — maintaining multiple
versions of software development objects.
 Traditional version-control systems handle text files only.
 ClearCase manages all software development objects: any kind
of file, and directories and links, as well.
 Versions of text and non-text files are also stored efficiently,
using data compression.
 Version control of directories enables the tracking of changes to
the organization of the source code base, which are just as
important as changes to the contents of individual files.
 Such changes include creation of new files, renaming of files,
and even major source tree “cleanups”.
CVS & Eclipse
56
Rational ClearCase
:: Version Object Bases

ClearCase development data is organized into any number of
versioned object bases (VOBs).
 Each VOB provides permanent storage for all the historical
versions of all the source objects in a particular directory tree.
 As seen through a ClearCase view, a VOB seems to be a standard
directory tree.
CVS & Eclipse
57
Rational ClearCase
:: Parallel Development - I

Each (sub)branch in an element's version tree represents
an independent “line of development”.
 This enables parallel development — creating and
maintaining multiple variants of a software system
concurrently.
 Creation of a variant might be a major project (porting
an application to a new platform), or a minor detour
(fixing a bug; creating a “special release” for an
important customer).
CVS & Eclipse
58
Rational ClearCase
:: Parallel Development - II
The overall ClearCase parallel development strategy is as follows:
 Establish a baselevel — Development work on a new variant
begins with a consistent set of source versions, identified (for
example) by a common version label.
 Use dedicated branches — All changes for a particular variant
are made on newly-created branches with a common name.
 Isolate changes in views — Development work for a particular
variant takes place in one or more views that are configured to
“see” the versions on the dedicated branches.
CVS & Eclipse
59
Rational ClearCase
:: Merging Branches

There is an additional important aspect of the ClearCase
parallel development strategy.
 Work performed on sub-branches should periodically be
reintegrated (merged) into the main branch, the
principal line of development.
 ClearCase includes tools that automate this process.
CVS & Eclipse
60
Version Control System Vendors
:: Version Control System Software







Visual SourceSafe, Microsoft
Perforce
Serena Version Manager — previously Merant
PVCS
TrueChange
BitKeeper (was used in Linux kernel development
December 1999 - April 2005)
Aldon Lifecycle Manager
More on CM Crossroads: www.cmcrossroads.com
CVS & Eclipse
61
Resources
CVS-Concurrent Versions System
The official manual from http://www.cvshome.org
 CVS Eclipse Plug-in FAQ
 CVS Howto - Eclipsepedia
 Eclipse
 Branching with Eclipse and CVS
 CVS--Concurrent Versions System v1.12.12.1
 Version Control Systems, by Lee Reynolds
 Rational ClearCase
 Introduction to ClearCase

CVS & Eclipse
62
Download