Beruflich Dokumente
Kultur Dokumente
Topics
Objectives............................................................................................................ 4-2
Adding Files to Source Control.............................................................................. 4-4
Comparing File and Directory Versions ............................................................... 4-11
Moving an Element ............................................................................................ 4-14
Viewing an Element History................................................................................ 4-20
The lost+found Directory................................................................................... 4-21
Finding Checkouts.............................................................................................. 4-23
Canceling a Checkout ........................................................................................ 4-25
Using a Version-Extended Name ........................................................................ 4-28
Removing a View ............................................................................................... 4-29
Objectives
Objectives
Upon completing this module, you should be able to:
Add files to source control
Compare versions of elements
Move, rename, and remove elements and versions
View an element history
Find checkouts
Change an element checkout status
Cancel a checkout
Select versions other than those in your view
Remove a view
Module Topics
Module Topics
Working with Elements
Adding files and directories to source control
Comparing versions of elements
Moving, renaming, and removing elements and versions
Viewing an element history
The lost+found directory
Working with Views
Finding checkouts
Changing a checkout status
Canceling a checkout
Specifying versions using version-extended names
Removing a view
You can add files to source control using the GUI, the CLI, or the clearfsimport utility.
The next few slides discuss the process and procedure for adding files to source control.
To find your view-private files within a directory, refer to the Kind column in ClearCase
Explorer. To search for view-private files across directories in dynamic views, you can
use the lsprivate command.
CLI Procedure
Usage:
lsprivate (dynamic views only)
Example:
<pat_r2_dev_view>% cleartool lsprivate
/vobs/Hardware/src/hello
/vobs/Hardware/src/test.c
/vobs/gui/motif/util.c [checkedout]
/vobs/gui/motif/util.o
You can create new ClearCase elements by adding files or directories to source control.
When you add a file or directory to source control, ClearCase determines the file type
and creates a new element. It automatically creates the /main branch and populates
the version tree with the empty version 0. On UNIX, the default is to leave the newly
added element checkedout.
1
Find the file to
add to source
control.
2
Checkout the
current directory.
3
Add the file to source control.
When you add a file to source control, you create a new element using the cleartool
mkelem command.
Check out the current directory before you execute the mkelem command.
2
Click File > VOB object > Create element
from file.
3
Enter a
comment, and
then click OK.
1
Select the file to add to
source control.
You can also add files to source control through the File Browser.
By default, ClearCase keeps the file checked out once it has been added to source
control. In the Add to Source Control dialog box, clear the Keep checked out box if you
want ClearCase to check in the file.
1
Checkout the current directory.
2
Make the new versioned directory.
When you add a parent directory to source control, ClearCase does not automatically
add all child objects to source control. They remain view-private unless you specifically
add them to source control.
You must be root (UNIX) or the VOB owner to run clearfsimport unless you invoke it
with the -nsetevent option.
10
Symbolic links make a file element or directory accessible from more than one location
in the VOB.
VOB symbolic links are usually set up by a ClearCase administrator and are generally
transparent to uses performing typical checkout/checkin activities.
However, if you want to change the contents of a symbolically linked directory, you
must check out the directory from its actual location and not its symbolic location.
11
You can compare with the previous version or with another version in the tree.
For example, you might want to compare your checked-out version of an element to its
predecessor to see what changes you have made. Or, you might want to compare your
checked-out version to a particular historical version or a version being used by one of
your colleagues.
If the versions are identical, ClearCase asks you if you want to proceed with the
comparison.
The diff algorithm uses the appropriate utilities for the comparisons.
You can also use the ClearCase compare utilities to compare Rational Rose models,
Rational XDE models, XML, and HTML files.
12
When you compare element versions graphically, the Compare tool displays the
contents of the file in side-by-side windows that scroll in unison. It points out
differences between the versions.
The Navigate menu allows you to jump easily from one difference to another.
This window, as you will see, is also the basis for merging. Many of the options will be
the same when we discuss merging in a later module.
CLI Procedure
Usage:
diff [-serial_format | -diff_format | -columns n] [-options pass-through-opts]
[-predecessor] pname ...
Example:
/vobs/Hardware/src% cleartool diff hello.c@@/main/1 hello.c
********************************
<<< file 1: hello.c@@/main/1
>>> file 2: hello.c
********************************
------------[changed 1-3]--------------|------------
[changed to 1-9]-----------
main() { +| #include "hello.h"+
printf("Hello, %s!\n", env_user() +
13
CLI Procedure
Example:
/vobs/Hardware% cleartool diff -pre src
********************************
<<< directory 1: /vobs/Hardware/src@@/main/1
>>> directory 2: src
********************************
--------------|--------[ added ]---------------
| hello.h 03-Sep-2002 alex
--------------|--------[ added ]---------------
| util.c 03-Sep-2002 alex
Moving an Element
Moving an Element
move | mv [-c comment | -cfile pname | -cq | -cqe | -nc]
pname target-pname
1
Check out the to and from directories.
2
Move the file from
the source directory
to ../bin.
3
Checkin the source and destination
directories to complete the move.
14
During a development project, changes to the project may require you to move
elements from one directory to another, or even to another VOB.
Before you move an element, check out both the source and destination directories.
Moving elements affects other project members. Check with the project manager or a
ClearCase administrator before you move elements.
• Use the cleartool mv command to move an element from one VOB directory to
another.
• Use cleartool relocate to move an element between VOBs.
15
Because directories as well as files are under version control, you can remove elements
from a specific version of the directory. This will render the element invisible in the
directory, but does not permanently delete the element from the VOB. Moving or
removing elements creates new versions of the parent directories to record the
modifications.
For example, version 4 of /vobs/Hardware/src contains an element named util.c. If you
remove util.c from the src directory, ClearCase creates version 5 of vobs/Hardware/src,
which does not contain the util.c file element. The element util.c itself remains
unmodified, just not visible in the current (version 5) and future versions of the src
directory.
Removing references to elements affects other project members. Check with the project
manager or ClearCase administrator before you remove references to elements.
1
Check out the directory where
the element resides.
2
Remove the element name.
3
Check in the directory.
16
Renaming an Element
Renaming an Element
1
Select element, and then click
File > VOB object > Rename 2
element or link. Enter the new file name,
and then click Ok
17
Renaming an element creates a new version of the parent directory to catalog the new
element name. The element uses its new name in subsequent versions of its parent
directory, but previous versions of the parent directory refer to the element by its
previous name.
Renaming elements affects other project members. Check with the project manager or
ClearCase administrator before you rename elements.
The cleartool move command can be used to move and rename elements form the
CLI.
CLI Procedure
Usage:
move | mv [-c comment | -cfile pname | -cq | -cqe | -nc] pname target-pname
Example:
/vobs/Hardware/src% cleartool move util.c newutil.c
Moved “util.c" to “newutil.c".
Removing a Version
Removing a Version
Deletes one or more
versions of an element
from the VOB
Removes all metadata
items that were attached
to the deleted version(s)
18
When you remove a version, other versions before and after the removed version(s)
remain accessible.
To remove a version, you must be one of the following:
• Version creator
• Element or VOB owner
• root
When removing versions, remember:
• If removing a non-text file element version, the data container is deleted.
• If removing a text file element version, ClearCase logically removes the version
from the data container. No disk space is recovered.
• The version-ID of a deleted version is never reused.
• You cannot delete a version from which there is currently a checkout.
• Subsequent references to a removed version produce an error.
CLI Procedure
Usage:
rmver [-force] [-version version-selector | -vrange low version high-version]
[-c comment | -cfile comment-file-pname |-cq | -cqe | -nc] pname ...
Example:
/vobs/Hardware/src% cleartool rmver
util.c@@/main/r2_int/pat_r2/2
Removing these versions of "util.c":
/main/r2_int/pat_r2/2
Remove versions? [no] y
Removed versions of "util.c".
Removing an Element
Removing an Element
Removes an element COMPLETELY from the VOB;
there is NO WAY to restore it
19
There may be rare instances when you want to remove an element completely from the
VOB.
CLI Procedure
Usage:
rmelem [-force] [-comment comment | -cfile comment-file-pname | -cquery
| -cqeach | -ncomment] pname ...
Example:
cleartool> rmelem util.c
CAUTION! This will destroy the element, all its branches and
versions, including all data, meta-data and history, and will
remove the element from all directory versions that now
contain it. Once you destroy the element, there will be no
way to restore it to its current state.
If you want to preserve the element, but remove references to
it from future directory versions, use the "rmname" command.
Element “util.c" has 1 branches, 2 versions, and is entered
in 1 directory versions.
Destroy element? [no] y
Removed element “util.c".
20
ClearCase records each operation, for example check in, check out, reserve and
unreserve, as an “event record.”
Events that change the content of elements are considered major, while other events
are considered minor.
CLI Procedure
Usage:
lshistory [-long | -short | -fmt format] [-eventid] [-minor] [-nco] [-since date-time]
[-pname] pname ... | object-selector ...]
Example:
/vobs/Hardware/src% cleartool lshistory hello.c
25-Oct.09:43 pat create version
"hello.c@@/main/r2_int/pat_r2/2"
"Working on changing the text of the STDOUT"
20-May-1993 rick create version "hello.c@@/main/3"
(R1)
"include name, home dir, and time in message”
"hello.c@@/main/1"
"first implementation"
04-May-1993 akp create branch "hello.c@@/main"
04-May-1993 akp create file element "hello.c@@"
"first implementation"
21
Module Topics
Module Topics
Working with Elements
Adding files and directories to source control
Comparing versions of elements
Moving, renaming, and removing elements and versions
Viewing an element history
The lost+found directory
Finding Checkouts
Finding Checkouts
The checkout reporting tool enables you to search for
checkouts based on user-defined criteria.
23
You can query ClearCase to find existing checkouts based on the criteria you designate.
CLI Procedure
The cleartool lsco command displays all checkouts of elements in the current directory
by any view.
Usage:
lscheckout | lsco [-long | -short | -fmt format] [-cview] [-me | -user login-name]
[-recurse | -directory | -all | -avobs ] [pname ...]
Example:
/vobs/Hardware/src% cleartool lsco -all
29-Oct.15:17 alex checkout directory version
"/vobs/Hardware/src" from /main/2 (reserved)
29-Oct.15:14 pat checkout version
"/vobs/Hardware/src/Makefile" from /main/r2_int/pat_r2/1
(reserved)
"updating file to reflect file renaming"
29-Oct.15:14 pat checkout version
"/vobs/Hardware/src/hello.c" from /main/r2_int/pat_r2/2
(reserved)
"Working on fixing typo in source"
29-Oct.15:17 alex checkout version
"/vobs/Hardware/src/hello.h" from /main/1 (reserved)
"updating header"
Finding Checkouts
Finding Checkouts
Based on selection criteria, ClearCase displays a list
of the checked-out files in the checkouts window.
24
Canceling a Checkout
Canceling a Checkout
Cancel a checkout when you do not want to save
changes or want a fresh copy
You can rename and save a view-private version of the
file: filename.keep. If you do not save the file, all
changes are lost
25
When you cancel a checkout, ClearCase asks if you want to save a view-private version
of the file. If you choose not to save a view-private version, any changes you made to
the checked out version are lost and cannot be restored. Be certain you do not need
the data before you decide not to keep a view-private version.
1
Select the checked-
out element.
26
You can cancel a checkout at any time. When you do, your view selects the
predecessor version of the element. Once you undo a checkout, any changes you
made to the file are lost.
When you cancel a checkout, you can save a copy of the file with a .keep extension.
CLI Procedure
Usage:
uncheckout | unco [-keep | -rm] [-cact | -cwork ] pname ...
Example:
/vobs/Hardware/src% cleartool unco util.c
Save private copy of “util.c"? [yes] yes
Private version of “util.c" saved in “util.c.keep".
Checkout cancelled for “util.c".
27
Each version of an element has a unique identifier. From the command line interface,
you can use version-extended pathnames to access versions other than the ones
currently selected by your view.
Version-extended pathnames are useful when:
• Comparing
• Rebuilding objects
• Merging
CLI Procedure
To construct a version-extended pathname:
1. Enter the element name followed by the extended-naming symbol.
2. Add the branch pathname.
3. Add the version selector:
Full version-extended pathname example:
/vobs/Hardware/src/hello.h@@/main/r2_int/1
Where:
• hello.h@@ is the element name followed by the extended-naming symbol.
• /main/r2_int is the branch pathname.
• 1 is the version selector.
Any time a version-extended name is NOT used in place of the file pathname itself,
ClearCase uses the version currently selected by the config spec of the view.
Removing a View
Removing a View
Views are temporary, task-related objects; once a
specific development task or project is complete, remove
the view
Before removing a view, add all important view-private
files to source control or copy them to another location
Removing the view will:
Clean up VOB references to the view
Remove the view storage directory
Remove the view tag and unregister the view
Stop view server processes
Do NOT use UNIX Utilities to remove a view’s storage
directory
29
Module Review
Module Review
What does ClearCase do when you add a file to source
control?
What is the easiest way to add many files and directories to
source control in ClearCase?
What is the lost+found directory? Why is it significant?
How can you find out which VOB elements are checked out?
How do you access versions of elements other than those
selected by your view config spec?
Why would you want to remove a view?
Why should you not use operating system utilities to remove
a view?
30
Module Lab
Module Lab
In this lab, you perform the following tasks:
Add files to source control
Move and rename an element
View an element history
Find checkouts
Access versions not selected by your view
Remove a view
31