Escolar Documentos
Profissional Documentos
Cultura Documentos
Contents
2. Setting Up a View............................................................................................................... 11
2.1 Choosing a Snapshot View or a Dynamic View .......................................... 11
2.2 Choosing a Location and Name..................................................................... 12
Snapshot View: Choosing a Directory .......................................................... 12
Under the Hood: A Snapshot View Storage Directory........................13
Locations for Snapshot View Storage Directories ................................13
Choosing a View Name................................................................................... 14
Using the View-Tag .................................................................................. 14
Contents iii
3. Working in a View...............................................................................................................27
3.1 Accessing Files ..................................................................................................27
In a Snapshot View...........................................................................................27
Accessing Someone Else’s Snapshot View ............................................28
In a Dynamic View ...........................................................................................28
To Set a Dynamic View.............................................................................28
iv Developing Software
Contents v
vi Developing Software
Contents vii
Contents ix
Figures xi
1
Rational ClearCase provides a flexible set of tools that your organization uses to implement its
development policies. To use these tools, you need to understand the following concepts:
➤ ClearCase views
➤ Versions, elements, and VOBs
➤ Parallel development
hyperhelp cc_main.hlp
The sections titled Under the Hood provide detailed information and suggest ways to become an
advanced ClearCase user.
1 - ClearCase Concepts 1
1.2 ClearCase Views
To access files under ClearCase control, you set up and work in a view, which shows a directory
tree of specific versions of source files.
➤ Snapshot views, which copy files from data repositories called VOBs (versioned object bases) to
your computer.
➤ Dynamic views, which use the ClearCase multiversion file system (MVFS) to provide
immediate, transparent access to the data in VOBs. (Dynamic views may not be available on
all platforms. For more information, see ClearCase online help.)
2 Developing Software
Figure 1 A VOB Contains All Versions of an Element
VOB
0 0 0 0
Version 2 2 2 2
Depending on the size and complexity of your software development environment, ClearCase
elements may be distributed across more than one VOB. For example, the elements used by the
documentation group are stored in one VOB, while the elements contributing to software builds
are stored in a different VOB.
A set of rules called a configuration specification, or config spec, determines which files are in a
view.
1 - ClearCase Concepts 3
Config Specs for Snapshot Views
Config specs for snapshot views contain two kinds of rules: load rules and version-selection rules.
Figure 2 illustrates how the rules in a config spec determine which files are in a view. In its
examples, this manual describes views created by a user named Pat, who is working on release
1.4 of a product called Cropcircle. For purposes of clarity, Pat’s snapshot view names end in _sv.
VOB
% Is -I ~/pat_v1.4_cropcircle_sv/guivob
-r--r--r-- 1 pat user 56320 Dec 15 10:30 prog.c Loaded file
drwxrwxr-x 1 pat user 9 Mar 25 9:19 tmp
View
4 Developing Software
Config Specs for Dynamic Views
Dynamic views use version-selection rules only (and ignore any load rules). A dynamic view
selects all elements in all mounted VOBs, and then uses the version-selection rules to select a
single version of each element. Instead of copying the version to your computer as a standard
file, the view uses the MVFS (multiversion file system) to arrange the data selected in the VOB
into a directory tree.
The rules in the config spec constitute a powerful and flexible language for determining which
versions are in your view. For example, version-selection rules can specify the following criteria:
A label is a text annotation that you can attach to a specific version of an element. Usually,
your project manager attaches a label to a set of versions that contributed to a specific build.
A typical config spec rule uses version labels to select versions:
element * BASELINE_1
For example, if your project manager attaches version label BASELINE_1 to a version of
element prog.c, any view configured with this rule selects the labeled version (unless some
rule earlier in the config spec matches another version of prog.c).For more information about
labels, see Managing Software Projects.
➤ A version identified by a time rule, that is, a version created before or after a specific time.
The version-selection rules are prioritized. For example, the view can try to select a version
identified by a label first, and if no such version exists, the view can select a version based on a
time rule.
In addition to affecting the way the element appears in views, labeling a version of an element
also provides a way to access the version with a version-extended pathname. Labeling a version
effectively adds a new hard link to the version in the extended namespace. If you attach version
label R4.1A to version /main/rls4/12 of element lib.c, these pathnames are equivalent:
lib.c@@/main/rls4/12
lib.c@@/main/rls4/R4.1A
1 - ClearCase Concepts 5
In addition, a third pathname is usually equivalent:
lib.c@@/R4.1A
This version-extended pathname is valid if it is unambiguous, that is, if no other version of lib.c
is currently labeled R4.1A. (This is usually the case because, by default, label types are restricted
to being used once per element. See the description of the –pbranch option in the mklbtype
reference page in the Command Reference.)
Usually only one or two members of your software team learn the syntax for these rules and
create config specs for everyone on the project to use. For more information, see Managing
Software Projects and the config_spec reference page in the Command Reference.
View-Private Objects
In addition to versions of source files, a view also contains file-system objects that are not under
ClearCase source control, such as temporary files that you create while developing your source
files. These non-ClearCase file system objects are called view-private objects.
6 Developing Software
1.5 Extended Namespace for Elements, Branches, and Versions
An element’s version tree has the same form as a standard directory tree (Figure 3), which
compares components of the version tree to components of a directory tree in extended
namespace.
As a component of the version tree, the element is the root of the directory tree in the extended
namespace. The element itself appears to be a directory, which contains a single subdirectory,
corresponding to the main branch. (It can also contain some version labels.)
A branch in the version tree appears as a subdirectory in the extended namespace. As a directory,
each branch can contain files (individual versions and version labels), directories (subbranches),
and links (version labels).
A version in the version tree is a leaf name of the directory tree in the extended namespace. Each
version of an element is a leaf of the directory tree. For a file element, the leaf contains text lines
or binary data. For a directory element, the leaf contains a directory structure.
main
branch1
branch2
main
branch1 branch2
1 - ClearCase Concepts 7
Accordingly, any location within an element’s version tree can be identified by a pathname in
this extended namespace:
sort.c@@ (specifies an element)
sort.c@@/main (specifies a branch)
sort.c@@/main/branch1 (specifies a branch)
sort.c@@/main/branch1/2 (specifies a version)
doctn/.@@/main/3 (special case: extra component is required in VOB’s
top-level directory)
ClearQuest stores data in two databases: a schema repository and a user database. A schema
defines the types of records in the database and other attributes of the database. ClearQuest
stores all schemas in a schema repository. The user database stores your change-request data.
The ClearQuest schema package provides additional information in your ClearQuest records to
track associations with ClearCase versioned objects. To support associations between base
ClearCase and ClearQuest record types, the schema repository needs to have the schema
package applied to its record types and the user database used with the integration must be
updated to add the new fields provided by the package.
Your ClearQuest user database may include different record types for different purposes. The
record type used by the SAMPL database supplied with the base ClearCase-ClearQuest
integration is called a defect, but with the ClearCase schema package installed, any record type
can be used.
8 Developing Software
ClearCase Triggers and ClearQuest Change Requests
The base ClearCase-ClearQuest integration consists of ClearCase triggers that fire when you
check out an element, cancel a checkout, or check in an element. Your ClearCase administrator
installs the integration triggers into each target VOB. The integration associates one or more
ClearQuest change requests with one or more ClearCase versions stored in one of the target
VOBs.
➤ A single change request may be associated with more than one version. The set of versions
that implement the requested change is called the change set for that request.
➤ A single version may be associated with more than one change request. These change
requests are called the request set for that version.
The integration provides a text-based user interface for users of the cleartool command-line
interface and a clearprompt pop-up window interface for users of the ClearCase GUIs such as
ClearCase Explorer and Windows Explorer (on Windows computers) and ClearCase File
Browser (on UNIX workstations).
The base ClearCase-ClearQuest integration has triggers on checkin, checkout, and cancel
checkout operations. As a ClearCase user, you can do the following:
➤ Associate a version with one or more change requests when you check out or check in the
element.
➤ List the request sets that are associated with a project over a period of time, list the change
requests associated with a specific version, and see the related hyperlinks.
➤ Install the related triggers in a VOB and set a policy for each VOB that determines the
conditions under which you are prompted to associate versions with change requests.
1 - ClearCase Concepts 9
➤ Specify that you are prompted on checking out a version, checking in a version, or both.
➤ Specify that prompting occurs only for some VOBs, branch types, or element types.
Associations of checked-in versions with change requests can be either optional or required.
A ClearQuest administrator adds the ClearCase schema package to a ClearQuest schema. The
administrator sets a policy for one or more VOBs that specifies the conditions under which you
are prompted to associate versions with change requests.
10 Developing Software
2 Setting Up a View
2
Usually you set up a separate view for each development project to which you contribute. Setting
up a view involves the following tasks:
➤ You want to work with source files under ClearCase control when you are disconnected
from the network that hosts the VOBs.
➤ You want to simplify accessing a view from a workstation that is not a ClearCase host.
2 - Setting Up a View 11
➤ Your development project doesn’t use the ClearCase build auditing and build avoidance
features.
➤ You want to access elements in VOBs without copying them to your workstation.
➤ You want the view to reflect changes made by other team members at all times (without
requiring an update operation).
For more information, see the Administrator’s Guide for Rational ClearCase.
When creating a snapshot view, you must specify a directory into which ClearCase loads (copies)
files and directories. When choosing a directory for the view, consider these constraints:
➤ The view’s root directory must be located on a disk with enough space for the files loaded
into the view and any view-private files you add.
➤ Your organization may restrict where you can create a view. For example, you may be
required to use a disk that is part of a data-backup scheme.
➤ If you want to access the view from other workstations, it must be located in a directory that
is accessible to the other workstations; that is, choose a disk partition that is exported.
12 Developing Software
Under the Hood: A Snapshot View Storage Directory
Every snapshot view has a view storage directory in addition to the directory tree of source files
that it loads from VOBs. ClearCase uses the snapshot view storage directory to keep track of such
information as which files are loaded into your view and which versions are checked out to it.
The view storage directory is for ClearCase administrative purposes only. Do not modify
anything in it.
For every 1,000 elements loaded into the view, ClearCase uses about 400 KB of disk space for the
view storage directory.
If your ClearCase administrator does not set up storage locations, by default, ClearCase software
locates the view storage directory under the root directory of the snapshot view.
You can override these defaults. If your administrator sets up multiple storage locations, you can
select one explicitly. You can place the view storage directory under the root directory of the
snapshot view.
If you place the view storage directory under the root directory of the view, be aware of the
following recommendations:
➤ Do not choose this configuration if you use the view when disconnected from the network.
You can corrupt the data in the view storage directory if you disconnect it from the network
while the view’s view_server process is running.
➤ Make sure that the view storage directory is accessible to any data backup schemes your
organization institutes.
NOTE: If you plan to work while disconnected from the network, your administrator must set up
storage locations.
2 - Setting Up a View 13
Choosing a View Name
Each view must have a descriptive name (called a view-tag) that is unique within a network
region. Choose a view name that helps you determine the owner and purpose of the view. Names
like myview or work do not describe the view’s owner or contents; if you work with more than
one view, such generic names can lead to confusion. Here are some suggested names:
pat_v1.4_cropcircle Personal view for a user named Pat to develop source files for
release 1.4 of the Cropcircle product
1.3_fix Shared view for use in a particular bug-fixing task
A view’s name must be a simple name; that is, it must follow the format of a single file or
directory name with no special characters or spaces.
The way you use the view-tag is different for each type of view:
➤ ClearCase provides a default view-tag for snapshot views based on the following
convention:
user-ID_leaf-of-view-pathname
You do not refer to the view-tag when performing most ClearCase operations. Instead you
usually refer to the view’s pathname.
The root directory of the snapshot view contains a file, .view.dat, which provides
information that ClearCase uses to perform operations on the files in the view. When
ClearCase finds the view’s .view.dat file, it can determine the view’s view-tag. (If you delete
the .view.dat file inadvertently, see Regenerating a Snapshot View’s .view.dat File on page 89.)
➤ For dynamic views, the view-tag is the only name you use when performing most
ClearCase operations. After setting (activating) a dynamic view, you use the view-tag to
refer to the root directory of the view’s directory tree. For more information, see Accessing
Files on page 27 and the pathnames_ccase reference page in the Command Reference.
When creating a dynamic view, you must choose a location for its view storage directory. ClearCase
uses this directory to keep track of which versions are checked out to your view and to store
14 Developing Software
view-private objects. The view storage directory is for ClearCase administrative purposes only.
Do not modify anything in it.
The size of the view storage directory depends on the following factors:
➤ Whether you use the clearmake build auditing and build avoidance features
➤ The size and number of view-private files
For more information, see the Administrator’s Guide for Rational ClearCase and the clearmake
reference page in the Command Reference.
Consider the following restrictions when choosing a dynamic view storage directory location:
➤ To maintain data integrity, the view storage directory must remain connected to the
network. For example, do not locate the view storage directory on a removable storage
device.
➤ If you locate the view storage directory on a laptop and then disconnect the laptop from the
network, all of the following restrictions apply:
➣ Team members who try to start your view from their hosts will receive error messages
from ClearCase.
➣ Any clearmake process that attempts to wink in a derived object from your view will
spend some amount of time trying to contact your view. If it cannot contact your view,
it will not consider derived objects in your view as winkin candidates for 60 minutes.
(You can change the amount of time by setting the CCASE_DNVW_RETRY environmental
variable.) For more information, see the clearmake reference page.
➤ If you use the view on several hosts, make sure that the location can be accessed by all those
hosts; that is, choose a disk partition that is exported.
2 - Setting Up a View 15
We recommend that you make the view storage directory accessible to any data backup schemes
your organization institutes.
➤ A umask of 002 is appropriate for a view that you share with other users in the same group.
Members of your group can create and modify view-private data; those outside your group
can read view-private data, but cannot modify it. To completely exclude nongroup
members, set your umask to 007.
➤ A umask of 022 produces a view in which only you can write data, but anyone can read
data.
➤ A umask of 077 is appropriate for a completely private view. No other user can read or
write view-private data.
Change your umask in the standard way. For example, enter this command from a shell:
umask 022
You can also use the CCASE_BLD_UMASK environment variable (EV) to set the umask(1) value for
files created from a clearmake build script. It may be advisable to have this EV be more
permissive than your standard umask—for example, CCASE_BLD_UMASK = 2, where umask is 22.
For more information on ClearCase EVs, see the env_ccase reference page in the Command
Reference.
16 Developing Software
2.4 Creating the View with cleartool mkview
After gathering information on names and locations, open a shell and enter the cleartool
mkview command as described in the following sections.
Remember the pathname you enter; ClearCase creates your directory tree of source files at this
pathname.
For a complete list of mkview options, see the mkview reference page in the Command Reference.
For example, to create the pat_v1.4_cropcircle_sv view located under Pat’s home directory, enter
the following command:
When you create a snapshot view, ClearCase creates or modifies the file .ccase_svreg in your
home directory. Do not remove or relocate this file; some ClearCase operations require it.
If you inadvertently delete or corrupt this file, see Regenerating .ccase_svreg on page 90.
2 - Setting Up a View 17
For a complete list of mkview options, see the mkview reference page in the Command Reference.
For example, create pat_v1.4_cropcircle as a dynamic view with the following command:
cleartool is the main command-line interface (CLI) to interact with ClearCase. It has a large set
of subcommands, which create, modify, and manage the information in VOBs and views.
You can use cleartool in either single-command mode or interactive mode. To use a single
cleartool subcommand from a shell, use this syntax:
When entering a series of subcommands, you may find it more convenient to type cleartool
without any arguments. This places you at the interactive-mode prompt:
cleartool>
You can then issue any number of commands, ending with quit to return to the original shell.
cleartool commands can be continued onto additional lines with backslash (\), as with UNIX
shells.
Command options may appear in any order, but all options must precede any nonoption
arguments (typically, names of files, versions, branches, and so on).
For more information, see the cleartool reference page in the Command Reference. For information
about input and output for cleartool commands, see pathnames_ccase and fmt_ccase in the
Command Reference.
18 Developing Software
them from a config spec available over the network. For information on creating
version-selection rules, see Managing Software Projects.
You can use the following procedure whenever you need to add, remove, or otherwise modify
your view’s version-selection rules.
➣ If you’re working in a snapshot view, change to the root directory of the view.
cleartool edcs
ClearCase opens the view’s config spec in your default text editor. For information about
changing the default editor, see the env_ccase reference page in the Command Reference.
➣ Copy or insert the project’s rules into the config spec. The rules may be available in a text
file accessible over the network, or even through e-mail. Verify with the author of the
shared config spec whether you need to include any rules other than the ones you paste.
➣ Type on its own line include path-to-shared-config-spec. Verify with the author of the
shared config spec whether you need to include any rules other than the include rule.
NOTE: Rather than create your own config spec with an include rule, you can use
cleartool setcs to use some other config spec directly. For more information, see the setcs
reference page in the Command Reference.
4. If you’re working in a snapshot view, create or modify load rules. (See Snapshot View: Adding
or Modifying Load Rules for more information.) If you’re working in a dynamic view, do the
following:
b. In your shell, answer Yes at the ClearCase prompt for setting the config spec.
2 - Setting Up a View 19
2.6 Snapshot View: Adding or Modifying Load Rules
Load rules determine which elements are copied into the snapshot view. Any projectwide config
spec that you include in your view’s config spec may already contain a set of default load rules.
You can modify those rules or add your own by doing the following:
To create load rules, you must know the names of the elements in the VOB namespace. Because
ClearCase loads directory elements recursively, you need to know only the names of parent
directory elements.
VOB Namespace
In its general sense, a namespace is a set of unique names. The namespace of a file system usually
consists of a hierarchical arrangement of files and directories. Each file and directory has a
unique name.
In a VOB, a simple file name is not sufficient to select a single, unique object. For example, prog.c
is ambiguous: does it refer to version 1 of prog.c or version 42 of prog.c?
A VOB namespace is the set of file and directory versions your config spec selects. For example,
the view pat_v1.4_cropcircle_sv sees a VOB namespace of the files and directories that
contribute to release 1.4 of a software product; the view pat_v1.3_cropcircle_sv sees a VOB
namespace of the files and directories that contribute to release 1.3 of the same product. Because
ClearCase tracks versions of directories, the VOB namespace varies depending on the versions
of directories you select.
1. From a snapshot view, enter cleartool lsvob to see the list of VOBs at your site. For example:
20 Developing Software
2. To see the namespace in a VOB, enter the following command:
To see further down a directory tree in the namespace, use cleartool ls recursively. For
example:
cleartool ls /guivob
drwxrwxrw- 1 pat user 9 Dec 15 10:30 batch
drwxrwxrw- 1 pat user 3 Dec 8 8:10 soup
cleartool ls /guivob/batch
-r--r--r-- 1 pat user 56320 Mar 25 9:15 prog.c
-r--r--r-- 1 pat user 45056 Mar 23 11:57 lib.c
You can add or modify load rules in any of the following ways:
➤ When editing the config spec. Any time you edit and modify a snapshot view’s config spec,
ClearCase updates the entire view. This is appropriate when you first create a view, or when
you modify a view’s version-selection rules, but it may be cumbersome if you only want to
add a few elements to the view.
➤ By using update –add_loadrules. The –add_loadrules option of cleartool update adds load
rules to your view’s config spec but updates only the portion of the view that is affected by
the new load rules.
1. Open the view’s config spec for editing by doing the following:
cleartool edcs
ClearCase opens the view’s config spec in your default text editor.
2 - Setting Up a View 21
2. In your text editor, use the following syntax to create load rules:
For example, the rule load /guivob loads all files and directories in the VOB named /guivob.
The rule load /guivob/batch loads only the batch directory recursively.
4. In your shell, answer Yes at the ClearCase prompt for setting the config spec.
You can also use a relative pathname for the element-pathname argument. For example, these
commands load all elements in guivob:
cd ~/pat_v1.4_cropcircle_sv
cleartool update –add_loadrules guivob
cd ~/pat_v1.4_cropcircle_sv
cleartool update –add_loadrules guivob/batch
ClearCase loads all directory elements recursively. To exclude some elements from loading, you
can use an element rule in the config spec that selects an element’s initial version. For all ClearCase
elements, the initial version contains no data.
22 Developing Software
To Exclude Elements
cleartool edcs
2. In the text editor, create an element rule that specifies the initial version of the element you
want to exclude by using the following syntax:
For example, the element rule element /guivob/interface /main/0 loads the empty version of
the interface directory in /guivob, preventing any of its child elements from loading.
4. In your shell, answer Yes at the ClearCase prompt for setting the config spec.
A VOB link makes a file element or directory element accessible from more than one location in
the VOB namespace. There are two kinds of VOB links: symbolic links, which are available for file
and directory elements, and hard links, which are available for file elements only. We recommend
that you use VOB symbolic links instead of VOB hard links whenever possible.
You use the cleartool ln command to create VOB links. For more information, see the ln reference
page in the Command Reference.
In dynamic views (which use the MVFS, or multiversion file system), VOB links behave similarly
to symbolic links or hard links in a UNIX file system: symbolic links point to a file or directory
element in a different location, and hard links are alternate names for a single file element.
You cannot check out a VOB symbolic link; you must check out the symbolic link target.
When you check out a hard-linked element from a given pathname, ClearCase considers other
pathnames for the element as “checked out but removed.” That is, to prevent you from
2 - Setting Up a View 23
modifying the element from multiple pathnames, ClearCase executes standard checkout
behavior at only one pathname (the one from which you entered the checkout command), but
does not create view-private files at other pathnames. For information about standard checkout
behavior, see the checkout reference page in the Command Reference.
Snapshot views created from a UNIX host maintain standard symbolic link behavior.
NOTE: When you create a snapshot view from a UNIX host, ClearCase assumes that the file
system that contains the view supports symbolic links. If your file system does not support
symbolic links, ClearCase reports errors if it encounters VOB links during the update operation.
If a load rule selects a symbolic link, ClearCase copies the link as well as the link target into the
snapshot view (regardless of whether a load rule selects the link target). As with dynamic views,
you cannot check out a symbolic link; you must check out the symbolic link target.
Instead of creating hard links in a snapshot view, each time a load rule selects a hard link,
ClearCase loads the element into the view as a standard file.
If you load multiple instances of a hard-linked element into a snapshot view, you must be careful
to check out, modify, and check in only one instance of the file.When you check in a hard-linked
file, ClearCase updates all other instances in your view, which could result in loss of data if you
modified multiple copies of the same file. (Note that, when updating instances of files because of
a checkin, ClearCase renames any hijacked file to filename.keep before updating it.)
For example, the following sequence of events will lead to lost data:
2. ClearCase removes the read-only permission from util.h in the src directory only (which is
the location from which you issued the checkout command).
4. Later, you lose track of which file you checked out. You then remove the read-only
permission and modify util.h in the temp directory.
24 Developing Software
5. You check in temp/util.h. Even though you checked out and modified src/util.h, ClearCase
does not prevent you from checking in temp/util.h; with a VOB hard link, temp/util.h is just
another name for src/util.h.
6. Any changes you made to src/util.h are lost upon checkin because ClearCase updates all
copies of duplicated files when you check in an element. Note that ClearCase does not
consider any copy of util.h to be hijacked (even if you change permissions), because you
checked out the element in the VOB.
2 - Setting Up a View 25
26 Developing Software
3 Working in a View
3
This chapter guides you through the everyday tasks of managing source files from Rational
ClearCase:
➤ Accessing files
➤ Checking out elements
➤ Working with checkouts
➤ Canceling checkouts
➤ Checking in elements
In a Snapshot View
Recall that when you create the view, ClearCase copies one version of each element specified by
a load rule into your view. To access the files loaded into a snapshot view, open a shell and change
to the root directory of the view.
3 - Working in a View 27
For example, if you use this command to create the view
You can access someone else’s snapshot view as you would access any other directory on another
workstation. Assuming that you can access the other workstation and that the directory’s owner
has set up the proper permissions, use the cd command to access the view.
In a Dynamic View
➤ Setting a view
➤ Mounting VOBs
For more information about setting a view, see the setview reference page in the Command
Reference.
To Mount VOBs
Usually, ClearCase mounts VOBs that were created with a public VOB-tag when you start or
reboot your workstation. If public VOBs do not mount, type cleartool mount –all to mount them.
VOBs remain mounted until you reboot your workstation or unmount them with the cleartool
umount command. For more information about mounting VOBs, see the mount reference page
in the Command Reference.
28 Developing Software
Accessing Someone Else’s Dynamic View
Team members can access any dynamic view by starting it on their computers. If you are unable
to start or set a dynamic view that is on another host, check with your administrator to make sure
that you can access the view’s view storage directory. For more information, see the
Administrator’s Guide for Rational ClearCase.
3. To finish entering comments, press RETURN, and type a period or press CTRL+D on a blank
line.
You can cancel the checkout operation by entering a standard interrupt signal such as
CTRL+C before typing a period or pressing CTRL+D.
cleartool checkout includes several options. These are most commonly used:
–query
Detects potential problems in the checkout process caused by inappropriate config specs
or out-of-date snapshot views and prompts for action.
–nc
Prevents ClearCase from prompting for a comment.
3 - Working in a View 29
–cq
Prompts for and applies a comment to all elements in the list.
–unreserved
Makes the checkouts for the listed elements unreserved. For more information, see
Reserved and Unreserved Checkouts on page 30.
For a complete description of all checkout options, see the checkout reference page in the
Command Reference.
In some version-control systems, only one user at a time can reserve the right to create a new
version. In other systems, many users can compete to create the same new version. ClearCase
supports both models by allowing two kinds of checkouts: reserved and unreserved.
The view with a reserved checkout has the exclusive right to check in a new version for a given
development project. Many views can have unreserved checkouts. An unreserved checkout does
not guarantee the right to create the successor version. If several views have unreserved
checkouts, the first view to check in the element creates the successor; developers working in
other views must merge the checked-in changes into their own work before they can check in.
Your organization’s development policy may determine whether to check out reserved or
unreserved.
Figure 4 illustrates checked-out versions created by reserved and unreserved checkouts, and the
effects of subsequent checkins.
30 Developing Software
Figure 4 Resolution of Reserved and Unreserved Checkouts
3 3
Reserved Unreserved Unreserved
checkout checkout checkout
3 3
4 4
Checking in Checking in
the version the version
This checked-out version
cannot be checked in as
version 5 until it is merged
with contents of version 4
Another kind of checkout is an unreserved, nonmastered checkout, which can be used only in a
replicated VOB (created with Rational ClearCase MultiSite). For more information about this
kind of checkout, see Sharing Control of a Branch with Developers at Other Sites on page 71.
For information on changing the status for checkouts in other views, and for more information
about these commands, see the reserve or unreserve reference pages in the Command Reference.
3 - Working in a View 31
Under the Hood: What Happens When You Check Out a File or Directory
Because a snapshot view contains copies of files and directories, and a dynamic view provides
access to data in VOBs, ClearCase follows different procedures for checking out from the
different view types.
When you check out a file or directory from a snapshot view, the ClearCase software handles the
request as follows:
2. If the version in your view is not the latest in the VOB, ClearCase notifies you. If you use the
–query option when checking out a file, ClearCase asks you to specify which version to
check out. If you use the –query option when checking out a directory, ClearCase notifies
you, but requires you to check out the version of the directory currently loaded in your view.
The version in your view will not be the latest in the VOB if either of these conditions exist:
➣ Someone else has checked in a new version since you last updated your view.
➣ Your view’s config spec selects versions based on a label or a time rule, and the latest
version in the VOB falls outside those parameters (Figure 5).
3. If you check out a version other than the one currently loaded in your view, ClearCase loads
the checked-out version into your view.
4. ClearCase notifies the VOB which version of the element you checked out.
5. For files, ClearCase makes them writable. For directories, it allows you to use the mkelem
command to add new elements to source control.
For information on checking out VOB links in a snapshot view, see Under the Hood: VOB Links on
page 23.
32 Developing Software
Figure 5 Selecting the Non-Latest Version of an Element
prog.c
/main
Labeled version
2 BL3
your view selects
When you check out a file from a dynamic view, ClearCase handles the request as follows:
1. If your view’s version-selection rules do not select the latest version in the VOB and you use
the –query option with the checkout command, ClearCase prompts you to choose a version
to check out.
Your view may not select the latest version in the VOB if, for example, your config spec
selects versions based on labels or time rules (Figure 5).
If you do not use the –query option, ClearCase checks out the latest version without
notifying you. Use the –ver option of the checkout command to check out the version that
your view selects, even if it is not the latest in the VOB.
See Merging with the Latest Version on page 43 for information about checking in a nonlatest
version.
2. ClearCase notifies the VOB which version of the element you checked out.
3. For files, ClearCase creates in the view an editable view-private file, which is a copy of the
checked-out version. For directories, it allows you to use the mkelem command to add new
elements to source control.
3 - Working in a View 33
Checking Out Elements in a VOB Enabled for ClearQuest
If the VOB in which you access versions is set up for the base ClearCase-ClearQuest integration,
you may have to associate the version on which you are working with a ClearQuest change
request record. For more information, see The Base ClearCase-ClearQuest Integration on page 8.
The first time that you attempt to check out an element from or check in an element to a VOB
enabled for the base ClearCase-ClearQuest integration, you are prompted to log in to
ClearQuest. Specify a ClearQuest user ID, password, and database name. ClearQuest keeps its
own database of user IDs and passwords. Make sure that your ClearQuest administrator has
added a user ID and password to the ClearQuest user database for you.
After you log in to ClearQuest, you can use the integration to complete your checkout and
checkin operations (see Using the Base ClearCase-ClearQuest Integration Interface). The integration
stores the user ID and an encoded version of the password in a file named .cqparams, which it
creates in platform-specific areas. On Windows computers:
<windows>\Profiles\<login>\Application Data\Rational\Cqcc\
Thereafter, the integration uses the user ID and password in .cqparams instead of prompting you
for them. If you change your password or connect to a different database, the next time you check
out or check in a version from that VOB, the integration displays an error message and prompts
you to reenter the user ID and password. The integration updates the .cqparams file with the
new information.
If you are logged in to a ClearQuest user database (see Logging on to a ClearQuest User Database
on page 34) and check out or check in an element, you see a different interface. You have the
options shown in Table 1.
34 Developing Software
Table 1 Base ClearCase-ClearQuest Integration Options
Option Description
CANCEL Exit without making any changes and cancel the related
ClearCase operation.
QUERY - Select from Displays the contents of a query that your local
ClearQuest Query administrator defines to show defects that are appropriate.
Depending on your local policy, you select one or multiple
items.
TYPEIN - Enter Associations Allows you to enter one or more change-request IDs
from Keyboard directly.
RECORD TYPE Shows the current record type with which you are
working; for example, a defect. Allows you to change to a
different record type if multiple entities are supported by
the current database.
PATHNAME Shows the full path for the version that you are checking
in or checking out. Select this item to see more
information.
If you use a cleartool command line interface (CLI), you see a numbered menu of the options
shown in Table 1. To select an option, type the number of the entry and press RETURN. Some
menus allow multiple choices, to which you can enter one or more number separated by a space
or a comma. To dismiss the menu without making a choice, simply press RETURN.
If you use File Browser, you see the ClearQuest Associations Menu provided by ClearPrompt.
The dialog box opens when you check out or check in a version of an element in a VOB enabled
for ClearQuest. In the dialog box, select an option from those shown in Table 1 and click Yes to
3 - Working in a View 35
continue. If multiple choices are allowed, click multiple items. Clicking the same choice a second
time clears it as a choice. To close the dialog box without making a change, click Yes or Abort.
Both the CLI and GUI interfaces use the same text for the choices to associate a ClearCase version
with one or more ClearQuest change requests and to remove a version’s existing associations
with change requests.
If you are required to associate versions with change requests, use the options from Table 1 to
enter change-request IDs as follows:
➤ Use the QUERY option to see a list of all open change-request IDs currently assigned to you
and select one or more items from the list to make associations.
➤ Use the TYPEIN option to enter one or more change-request IDs with which to associate the
version that you are checking out.
➤ Use the REVIEW option to list and possibly delete current associations.
➤ If the association is optional and you do not want to specify a change request, enter the OK
option and click Yes (clearprompt) or press RETURN (text menu).
➤ To cancel the checkout operation, use the CANCEL option or click Abort.
After you specify your options, use the OK option to create or update the associations your
specified and complete the checkout operation.
36 Developing Software
Some cleartool commands include a –graphical option, which starts a tool for completing the
task. This chapter presents the –graphical option whenever it is available.
You can use this command from a snapshot view whether or not the element specified by
pathname is loaded into the view.
As you modify source files, you may want to compare versions to answer such questions as
these:
➤ How does my checked-out version differ from a particular historical version or from the
version being used by one of my team members?
3 - Working in a View 37
2. In the Version Tree Browser, select a version.
4. In the Enter other versions dialog box, select other versions and click OK.
2. Use the cleartool diff command with version-extended naming. For example, to compare the
current version of prog.c with version 4:
You can use the lsvtree and diff commands from a snapshot view whether or not the element
specified by pathname is loaded into the view. For more information, see the diff and
pathnames_ccase reference pages in the Command Reference.
NOTE: To use this procedure, your workstation must support dynamic views.
1. Use cleartool startview to start a dynamic view. For example, to compare a version in your
view with a version in a dynamic view named joe_v1.4_cropcircle, enter the following
command:
2. Use cleartool diff (or any other diff command) with view-extended naming. For example,
to compare /guivob/prog.c in your view with /guivob/prog.c in joe_v1.4_cropcircle, enter
the following command:
Sometimes, the same element appears at different pathnames in different views. ClearCase can
track directory-level changes, from simple renamings to wholesale reorganizations. In such
situations, a team member may direct your attention to a particular element, using a pathname
that is not valid in your view. You can pass this pathname to a describe –cview command to
determine its pathname in your own view. For example:
38 Developing Software
cleartool describe –cview /view/joe_v1.4_cropcircle/project/include/lib.c@@
file element "/guivob/lib.c@@"
created 20-May-93.14:46:00 by rick.devt@saturn
.
.
You can then compare your version of the element with your team member’s version as follows:
Depending on how you work, you may forget exactly how many and which files are checked out.
To list all the files and directories you currently have checked out to your view, access the view
and use the lscheckout command with the following options:
For more information, see the lscheckout reference page in the Command Reference or type
cleartool man lscheckout in a shell.
Prototype Builds
Typically, when you’re developing source files for a project, you want to perform prototype
builds to test your modifications. If your organization uses clearmake, you can use this
ClearCase build tool for your prototype builds; however, the build auditing and build avoidance
features are available only from dynamic views.
For more information, see Building Software and the clearmake reference page in the Command
Reference.
3 - Working in a View 39
1. In the view from which you checked out a file, enter this command:
ClearCase prompts you to save your modifications in a view-private file with a .keep
extension.
2. To save the modifications in a view-private file, press RETURN. Otherwise, type no.
To avoid being prompted about saving modifications, use one of the following options with the
uncheckout command:
–keep
Saves modifications
–rm
Does not save modifications. Any changes you made to the checked-out version are lost.
When you cancel the checkout of a file element, ClearCase handles the request as follows:
2. It notifies the VOB that you no longer have the version checked out in your view.
3. In a snapshot view, it copies from the VOB the version that was in your view when you
performed the checkout operation.
In a dynamic view, it uses the config spec’s version-selection rules to select a version.
If you work in an environment with the base ClearCase-ClearQuest integration, any associations
with ClearQuest change requests you may have made at checkout (see Checking Out Elements in
a VOB Enabled for ClearQuest on page 34) are canceled if you cancel the checkout.
When you cancel a directory checkout, ClearCase notifies the VOB that you no longer have the
version of the directory checked out to your view. ClearCase does not prompt you to rename a
canceled directory checkout to directory-name.keep.
40 Developing Software
If you cancel a directory checkout after changing its contents, any changes you made with
cleartool rmname, mv, and ln are lost. Any new elements you created (with mkelem or mkdir)
become orphaned. ClearCase moves orphaned elements (and any data that exists in the view at
the pathname of the new element) to the VOB’s lost+found directory under names of this form:
element-name.UUID
In a snapshot view, ClearCase does not remove view-private objects or start the update operation
for the directory in the view. To return the directory in your view to its state before you checked
it out, you must start the Update Tool. For information on starting the Update Tool, see ClearCase
online help.
In a dynamic view, ClearCase does not remove view-private objects, but it does revert the view
to its previous state.
To move an element from the lost+found directory to another directory within the VOB, use the
cleartool mv command. To move an element from the lost+found directory to another VOB, use
the relocate command. For more information about moving elements to another VOB, see the
relocate reference page in the Command Reference.
To permanently delete an element in the lost+found directory, take note of the orphaned
element’s name and use this command:
cd ~/pat_v1.4_cropcircle_sv
cleartool rmelem guivob/lost+found/prog.c.5f6815a0a2ce11cca54708006906af65
3 - Working in a View 41
NOTE: In a snapshot view, ClearCase treats the lost+found directory, which is located
immediately below the root directory of a VOB, as any other directory. To load the directory in
your view, you must use a load rule that specifies either the element’s parent directory or the
directory itself. However, as with any other directory in a snapshot view, you do not need to load
the lost+found directory to issue ClearCase commands for elements in the directory.
Ideally, your organization’s development strategy isolates your checked-in work from official
builds and requires you to merge your work to official project versions at specified intervals.
To Check In Files
1. In a view, enter the following command:
2. Type any additional comments, press RETURN, and type a period or press CTRL+D on a
blank line.
You may cancel the checkin operation by entering a standard interrupt signal such as
CTRL+C before typing a period or pressing CTRL+D.
cleartool checkin includes several options. Here is a description of the most commonly used
ones:
–nc
Prevents ClearCase from prompting for a comment.
–cq
Prompts for and appends a single additional comment to all elements in the list.
42 Developing Software
For a complete description of all checkout options, see the checkin reference page in the
Command Reference.
If the version you checked out is not the latest version in the VOB and you try to check in your
modifications, ClearCase requires you to merge the changes in the latest version into the version
checked out in your view (Figure 6).
prog.c
/main
In Figure 6, version 2 of prog.c is the one that you checked out. Before you check in your
modifications, someone else checks in version 3 of prog.c. When you check in your
modifications, ClearCase tells you that the version you checked out is not LATEST on the branch.
(The section Under the Hood: What Happens When You Check Out a File or Directory on page 32
describes the situations in which you may have to merge before checking in.) Note that the
reserve status of the checkout is not relevant to whether your modifications can be checked in.
You need to merge the latest version in the VOB (prog.c@@/main/LATEST) to the version in your
view before you can check in your modifications. This merge creates a version that reconciles
modifications made in the latest version with your modifications. Then, when you check in the
merge results, the system sees the merge arrow from version 3 to your checked-out version
containing the merge results. The checkin creates a version 3 successor, version 4 of prog.c.
3 - Working in a View 43
To Merge with the Latest Version
To merge the latest version in the VOB to the version in your view, enter the following command:
For example:
Using the –graphical option starts the Diff Merge tool. For information on using the Diff Merge
tool, see ClearCase online help. After merging, save the results and check in the version by
entering the cleartool checkin command from the view.
The steps ClearCase follows when you issue the checkin command vary depending on the kind
of view you use.
When you issue a checkin command from a snapshot view, ClearCase handles the request as
follows:
The version you check in remains in the view, regardless of the view’s config spec.
For any other instance of a hard-linked file loaded into a snapshot view, ClearCase copies the
new version from the VOB into your view. (If your load rules specify a hard-linked element that
appears in more than one VOB location, the element is copied into each of the appropriate
locations in your view’s directory tree.)
44 Developing Software
From a Dynamic View
When you issue the checkin command from a dynamic view, ClearCase handles the request as
follows:
2. It uses the config spec’s version-selection rules to select a version from the VOB. If the config
spec selects a version other than the one you checked in, ClearCase displays a message.
ClearCase may select another version if, for example, your view selects versions based on
labels or time rules.
3. It removes the view-private file and provides transparent access to the version checked in to
the VOB.
If you use the base ClearCase-ClearQuest integration (see Checking Out Elements in a VOB Enabled
for ClearQuest on page 34), the version you are checking in must be associated with at least one
change request; otherwise, the checkin cannot proceed. When you check in the version, the base
ClearCase-ClearQuest integration displays those change-request IDs whose associations you
made during checkout. Using the options in Table 1, you can do the following:
Use the QUERY option to see a list of all open change-request IDs currently assigned to you.
Use the REVIEW option to list and possibly delete current associations.
Use the TYPEIN option to enter one or more change-request IDs with which to associate the
version that you are checking in.
If the associations are correct, use the OK option to continue the checkin.
The base ClearCase-ClearQuest integration creates associations for new change-request IDs that
you add, removes associations for change-request IDs that you delete, and updates information
on existing ones.
3 - Working in a View 45
View the Versions for a Change Request from ClearQuest
2. In the query result set, select a change request to display its Record form.
The ClearCase tab shows the last known names of the versions of ClearCase elements associated
with the change request.
46 Developing Software
4 Updating a Snapshot View
4
The rules in your view’s config spec are usually designed to select a discrete set of versions from
the VOB. For example, your view is usually intended to contain a set of versions that build
successfully. However, when other developers check in new versions from their views, a
snapshot view may become out of date or inconsistent with the versions in the VOB. To make
sure that your view contains the set of versions the config spec selects, you must update it.
An update operation copies versions of elements from a VOB to your view. Only the checkin
operation copies changes from your view back to a VOB.
Update the entire view periodically to make sure you have the correct version of all loaded files
and directories.
To update the view, use cleartool update with any of the following options:
The snapshot-view-pathname argument is optional if you enter the update command from the root
directory of the view.
Use these command options as follows. (For a description of all available command options, see
the update reference page in the Command Reference.)
–print
Produces a preview of the update operation: instead of copying or removing files,
update prints a report to standard output of the actions it would take for each specified
element.
–cti⋅me
Sets the time stamp of a file element to the current time, that is, the time at which the
version is copied into the view. –ctime has no effect on directories (directories always use
the current time). The initial default for the time stamp is set by the mkview command.
Thereafter, the most recently used time scheme is retained as part of the view’s state and
is used as the default behavior for the next update.
–pti⋅me
Sets the time stamp of a file element to the time at which the version was checked in to
the VOB. –ptime has no effect on directories. (Directories always use the current time.)
For example:
NOTE: You can use the Update Tool to update the view instead of the command line. To start the
update GUI, enter the following command:
48 Developing Software
Updating Files and Directory Trees
To save time, you can update individual files or directories. (Rational ClearCase updates
directories recursively.) Updating only specific parts of your view may eventually cause the view
to contain an inconsistent set of versions.
For information on these command options, see Updating the View on page 48. For a description
of all available command options, see the update reference page in the Command Reference.
NOTE: You cannot update a checked-out file. To undo changes to a checked-out file and start over
with the version in the VOB, cancel the checkout. See Canceling Checkouts on page 39.
4.2 Under the Hood: What Happens When You Update a View
When you start an update operation, ClearCase compares the version of the elements loaded in
the view with the version the config spec selects in the VOB. If the config spec selects a version
in the VOB that is different from the version loaded in your view, ClearCase copies the version
from the VOB into your view (Figure 7). ClearCase does not make this comparison or otherwise
modify versions currently checked out to the view.
The update operation takes into account the fact that changes may be occurring in the VOB
during the update. As ClearCase updates your view, other developers may check in new
versions of elements your view’s load rules select. To avoid loading an inconsistent set of
versions, the update operation ignores versions in the VOB that meet both of the following
conditions:
➤ The version was checked in after the moment the update began.
➤ The version is now selected by a config spec rule that involves the LATEST version label.
The update operation adjusts for the possibility that the system clocks on different hosts in a
network may be out of sync (clock skew).
VOB
prog.c
/main
% Is -I ~/pat_v1.4_cropcircle_sv/guivob
-r--r--r-- 1 pat user 56320 Dec 15 10:30 lib.c
-r--r--r-- 1 pat user 45056 Mar 23 13:22 msg.cat
-r--r--r-- 1 pat user 39936 Dec 5 11:57 prog.c
drwxrwxr-x 1 pat user 9 Mar 25 9:19 tmp
-r--r--r-- 1 pat user 56320 Dec 8 8:10 util.h
View
50 Developing Software
4.3 Unloading Elements
If a view’s config spec no longer selects an element, ClearCase removes, or unloads, it from the
view. Unloading does not affect view-private files or view-private directories.
Updating can cause an element to be unloaded from a view in the following situations:
➤ You remove the load rule that specifies the element (or that specifies a directory element
somewhere above it). For information on removing load rules, see Adding or Modifying Load
Rules on page 21.
➤ The version-selection rules no longer select any version of the element. This can happen
when your config spec selects a version of the parent directory that no longer contains a
version of the file element.
Unloading Files
The action that ClearCase takes to unload a file depends on the file’s current state:
➤ For a file that is not checked out, ClearCase deletes the file from the view.
➤ For a hijacked file, ClearCase appends .unloaded to the file name, unless you use update
–overwrite to delete hijacked files.
➤ For a checked-out file, ClearCase appends .unloaded to the file name. The version remains
checked out to your view.
Unloading Directories
ClearCase unloads directories recursively. To unload a directory element, ClearCase unloads the
files in the directory. If any view-private objects, hijacked files, or checked-out files are in the
directory, or if the directory is currently in use (for example, if your current working directory is
in or below the directory) ClearCase appends .unloaded to the name of the directory. For
example, if the directory src contains view-private files, ClearCase renames the directory to
src.unloaded.
5
The development cycle presented so far is a fairly simple one in which everyone in an
organization contributes to the same development project. But a software development cycle
often involves several concurrent development projects. For example:
➤ You may want to experiment with some changes to the GUI as a result of feedback from
usability testing, but are not yet sure whether to include your changes in official builds.
➤ Another team may try to optimize the database schema without upsetting the current one.
➤ Another group may need to get a head start on a feature for the next release of the product.
This chapter describes the functions that Rational ClearCase provides to support parallel
development, a style of working in which teams use the same set of source files for different,
concurrent development projects:
➤ Version trees
➤ Working on branches
➤ Merging
➤ Sharing control of a branch in an environment using Rational ClearCase MultiSite
(You do not need to read the section about sharing control of a branch with developers at other
sites unless your project manager or MultiSite administrator directs you.)
5 - Working On a Team 53
5.1 The Version Tree
Each time you revise and check in an element, ClearCase creates a new version of the element in
the VOB. Throughout this part of the book, this linear progression has been illustrated with a
graphic similar to Figure 8.
ClearCase can organize the different versions of an element in a VOB into a version tree. Like any
tree, a version tree has branches. Each branch represents an independent line of development.
Changes on one branch do not affect other branches until you merge. In Figure 9, main,
pat_usability, and db_optimize are branches being used to develop different releases of the file
element prog.c concurrently.
54 Developing Software
Figure 9 Version Tree of a File Element
prog.c
/main
1 REL1.3
/pat_usability
2
0
3
/db_optimize 1
4
0
merge 2
5 REL1.4
1
When you create a subbranch for an element, which is any branch below the main branch, the
initial version contains the same data as the version from which you start the branch (Figure 10).
(The initial version on the main branch contains no data. For more information, see Excluding
Elements from Loading on page 22.)
5 - Working On a Team 55
Figure 10 The Initial Version on a Subbranch
prog.c
/main
1 REL1.3
/pat_usability
2 The initial version
0
subbranch
➤ The versions to select in the development project’s specific branch. As Figure 11 illustrates,
some or all source files for the project have at least one version on the specified branch. If an
element does not have a version on the specified branch, other rules in the config spec select
a version of the element. In Figure 11, because lib.c does not have a version on the
pat_usability branch, the view selects the version on the main branch.
➤ A special make branch rule. When this view checks out a version, the make-branch rule
creates the development project’s branch (if it doesn’t already exist).
For example, each member of the project team that is optimizing the database schema uses a
view that selects versions on the db_optimize branch and creates new versions on that branch.
56 Developing Software
Figure 11 Elements Have Common Branches
load /guivob/prog.c
Load rules load /guivob/util.h
load /guivob/msg.cat
load /guivob/lib.c
Version-selection element * /main/pat_usability/LATEST
rules element * /main/LATEST -mkbranch pat_usability
VOB
0 0 0 0
1 1 1 1
/pat_usability
2 2 2
0
/pat_usability
3 3 3
1 0
/pat_usability
4
0 2 1
1 3 2
% Is -I ~/pat_v1.4_cropcircle_sv/guivob
-r--r--r-- 1 pat user 56320 Dec 15 10:30 prog.c
-r--r--r-- 1 pat user 45056 Mar 23 13:22 util.h
-r--r--r-- 1 pat user 39936 Dec 5 11:57 msg.cat
drwxrwxr-x 1 pat user 9 Mar 25 9:19 tmp
-r--r--r-- 1 pat user 56320 Dec 8 8:10 lib.c
View
5 - Working On a Team 57
For more information about branches, see Managing Software Projects and the mkbranch
reference page in the Command Reference.
util.h
main
r1_bugs
3
0
4
1
bug404
2
0
3
Version-extended pathname
1 util.h@@/main/r1_bugs/bug404/1 (UNIX)
util.h@@\main\r1_bugs\bug404\1 (Windows)
From a command-line interface, you can use version-extended pathnames to access versions
other than the ones currently selected by your view. To view the contents of a version that is not
58 Developing Software
currently in a snapshot view, you must use the cleartool get command in addition to
version-extended pathnames.
For a full description of the syntax for version-extended pathnames, see the pathnames_ccase
reference page in the Command Reference.
5.3 Merging
In a parallel development environment, the opposite of branching is merging. In the simplest
scenario, merging incorporates changes on a subbranch into the main branch. However, you can
merge work from any branch to any other branch. ClearCase includes automated merge facilities
for handling almost any scenario.
One of the most powerful of ClearCase features is versioning of directories. Each version of a
directory element catalogs a set of file elements, directory elements, and VOB symbolic links. In
a parallel development environment, directory-level changes may occur as frequently as
file-level changes. All the merge scenarios discussed in this chapter apply to both directory and
file elements.
➤ Merging all changes made on a single subbranch (see Scenario: Merging All Changes Made on
a Subbranch on page 65)
➤ Merging selectively from a single subbranch (see Scenario: Selective Merge from a Subbranch on
page 67)
➤ Removing the contributions of some versions on a single subbranch (see Scenario: Removing
the Contributions of Some Versions on page 69)
➤ Recording merges that occur outside ClearCase (see Recording Merges That Occur Outside
ClearCase on page 71)
ClearCase also supports merging work from many branches to a single branch; this is typically
a project manager’s or integrator’s task (see Managing Software Projects).
A merge combines the contents of two or more files or directories into a new file or directory. The
ClearCase merge algorithm uses the following files during a merge (Figure 13):
5 - Working On a Team 59
Figure 13 Versions Involved in a Typical Merge
element: opt.c
/main
Base contributor 4
5 /r1_fix
0
6
Merge output 1
7 file
2
Target contributor 8
merge 4
6 Contributor
➤ Contributors, which are typically one version from each branch you are merging. (You can
merge up to 15 contributors.) You specify which versions are contributors.
➤ The base contributor, which is typically the closest common ancestor of the contributors.
(For selective merges, subtractive merges, and merges in an environment with complex
branch structures, the base contributor may not be the closest common ancestor.) If all the
contributors are versions of the same element, ClearCase determines which contributor is
the base contributor (but you can specify a different one). For more information about
determining a base contributor, see Determination of the Base Contributor on page 62.
➤ The target contributor, which is typically the latest version on the branch that will contain
the results of the merge. You determine which contributor is the target contributor.
60 Developing Software
➤ The merge output file, which contains the results of the merge and is usually checked in as a
successor to the target contributor. By default, the merge output file is the checked-out
version of the target contributor, but you can choose a different file to contain the merge
output.
3. It copies any line that is unchanged between the base contributor and any other contributor
to the merge output file.
4. For any line that has changed between the base contributor and one other contributor,
ClearCase accepts the change in the contributor; depending on how you started the merge
operation, ClearCase may copy the change to the merge output file. However, you can
disable the automated merge capability for any given merge operation. If you disable this
capability, you must approve each change to the merge output file.
5. For any line that has changed between the base contributor and more than one other
contributor, ClearCase requires that you resolve the conflicting difference.
Base
B contributor
▲ (b, c1) ▲ (b, c2)
Source
C1 C2 contributors
➤ Sections in which there are no differences among the contributors are copied to the output
file.
5 - Working On a Team 61
➤ When one contributor differs from the base contributor, Diff Merge accepts the change and
copies the contributor’s modified section to the output file:
------------[changed 3-4]----|--------[changed to 3-4 file 2]---
now is the thyme | now is the time
for all good men | for all good people
-|-
*** Automatic: Applying CHANGE from file 2 [lines 3-4]
============
➤ When two or more contributors differ from the base contributor, Diff Merge detects the
conflict, and prompts you to resolve it. It displays all contributor differences and allows you
to accept or reject each one.
[changed 10] | [changed to 10 file 2]---
cent | sent
-|-
[changed 10] | [changed to 10 file 3]---
cent | scent
|-
Do you want the CHANGE made in file 2? [yes] no
Do you want the CHANGE made in file 3? [yes] yes
Applying CHANGE from file 3 [line 10]
============
Be sure to verify that the changes you accept produce consistent merged output. For
example, after performing a merge involving file util.h, you can compare files util.h.contrib
(which contains its previous contents) and the new util.h (which contains the merge output).
If all the contributors are versions of the same element, Diff Merge determines the base
contributor automatically. It examines the element’s version tree, which includes all the merge
arrows created by previous merge operations. This examination reveals the relationships among
versions from the standpoint of their contents (which versions contributed their data to this
version?), rather than their creation order (which versions were created before this version?). Diff
Merge selects as the base contributor the closest common ancestor in this enhanced version tree.
Figure 15 illustrates common cases of merging. If no merges have been performed in the element,
the actual common ancestor (A) of the contributors (C) in the version tree is selected to be the
base contributor.
62 Developing Software
Figure 15 Determination of the Base Contributor for a Merge
. .
. .
. .
bugfix test
A
windows
A
C
merge
C
C C
. .
. .
. ports .
bugfix bugfix
A
merge
merge A
merge
C
C C C
If the contributors are not all versions of the same element, there is no common ancestor (or other
base contributor). In this case, ClearCase turns off automated merging, and you must resolve all
discrepancies among the contributors.
Under the following conditions, the merge is recorded by creating one or more merge arrows
(hyperlinks of type Merge):
➤ One of the contributors must be a checked-out version, and you must specify this version as
the target to be overwritten with the merge output (the –to option in the merge command).
(Alternatively, you can optionally create merge arrows without performing a merge; in this
case, you do not need to check out any of the contributors.)
➤ You must not perform the merge but suppress creation of merge arrows.
5 - Working On a Team 63
➤ You must not use any of these options: selective merge, subtractive merge, or base
contributor specification (the –insert, –delete, and –base options in the merge command).
Diff Merge draws an arrow from each contributor version (except the base contributor) to the
target version. You can see merge arrows with the Version Tree Browser.
The find and lsvtree –merge commands can locate versions with Merge hyperlinks. The
describe command lists all of a version’s hyperlinks, including merge arrows:
Each version of a ClearCase directory element contains the names of certain file elements,
directory elements, and VOB symbolic links.Diff Merge can process two or more versions of the
same directory element, producing a directory version that reflects the contents of all
contributors. The algorithm is similar to that for a file merge. Diff Merge prompts for user
interaction only when two or more of the contributors are in conflict.
One of the directory versions—the merge target—must be checked out. (Typically, it is the
version in your view.) Diff Merge updates the checked-out directory by adding, removing, and
changing names of elements and links.
NOTE: A directory merge does not leave behind a .contrib file, with the pre-merge contents of the
target version.
Merging Directories
1. Ensure that all contributor versions of the directory are checked in.
64 Developing Software
3. Perform the directory merge immediately, without making any other changes to the
checked-out version.
If you follow this procedure, it easier to determine exactly what the merge accomplished. Enter
a diff –predecessor command on the checked-out version, which has just been updated by
merge.
ClearCase implements directory merges using VOB hard links. You can use the ln and rmname
commands to perform full or partial merges manually. See the ln and rmname reference pages
in the Command Reference.
Merging all changes made on a subbranch is the simplest and most common scenario (Figure 16).
Bug fixes for an element named opt.c are being made on branch r1_fix, which was created at the
baseline version RLS1.0 (/main/4). Now, all the changes made on the subbranch are to be
incorporated into main, where a few new versions have been created in the meantime.
Task Overview
Merging the changes from the r1_fix branch involves the following tasks:
1. Set a dynamic view or change directories to a snapshot view. The view must select the target
version, which in Figure 16 is opt.c@@/main/8.
2. If the target version is checked out to your view for other revisions, create a pre-merge
checkpoint by checking it in. To make it easier to find this checkpoint, consider labeling the
version.
3. Use the Merge Manager or cleartool findmerge –merge –gmerge to find elements with
versions on a specific subbranch and automatically merge any nonconflicting differences.
For example, in Figure 16, you find elements with versions on the r1_fix subbranch. To start
the Merge Manager, enter the following command:
clearmrgman
In your project, several elements might have versions on the r1_fix branch. With the Merge
Manager, you can choose for which elements you merge changes from one branch to another.
5 - Working On a Team 65
Figure 16 Merging All Changes from a Subbranch
element: opt.c
/main
RLS1.0 4
5 /r1_fix
0
6
1
7
2
8
4. Use Diff Merge to resolve any conflicting differences between merge contributors.
5. Test the merge results in the view you set in Step #1. Then check in the target version (which
contains the results of the merge).
For detailed information about completing this task, see the findmerge reference page in the
Command Reference or ClearCase online help:
66 Developing Software
Scenario: Selective Merge from a Subbranch
In the selective merge scenario, the project manager wants to incorporate into new development
several lines of code that were added in version /main/r1_fix/4 (Figure 17).
element: opt.c
/main
5 /r1_fix
0
6
1
7
Exclude changes
2 in these versions
8 from merge
merge 3
Include changes
QA_APPROVED 4
in this version only
5
Exclude changes
in these versions
from merge
6
It’s critical that you merge only the lines of code as written in this version: it was used and
verified to fix a specific bug that prevents further development on the new project.
Selective merges can be tricky: versions you exclude as contributors to the merge may contain
needed revisions. For example, if the function you added in /main/r1_fix/4 relies on a variable
definition that was added in /main/r1_fix/2, you must include version 2 in the merge.
5 - Working On a Team 67
Merging a Range of Versions
You can also specify a single range of consecutive versions to contribute to the merge. For
example, if you need the variable definitions added in /main/r1_fix/2 as well as the code added
in /main/r1_fix/4, you can include versions 2 through 4 in the merge.
Task Overview
Merging selective versions from the r1_fix branch involves the following tasks:
1. Set a dynamic view or change directories to a snapshot view. The view must select the target
version, which in Figure 17 is opt.c@@/main/8.
2. If the target version is checked out to your view for other revisions, create a pre-merge
checkpoint by checking it in.
3. To determine which versions contain changes that you want to merge to the target version,
use the Version Tree Browser and the History Browser. In a snapshot view, use the cleartool
get command to see the contents of versions not loaded into your view.
4. To start the merge, check out the target version, and then issue the cleartool merge command
with the –insert –graphical arguments. (You cannot start a selective merge from Diff Merge.)
For example, the following commands merge only the changes in version 4 on the r1_fix
branch:
These commands merge only the changes in versions 2 through 4 on the r1_fix branch:
5. In Diff Merge, complete the merge. Then save the results and exit. For information on using
Diff Merge, refer to the online help.
6. Test the merge results in the view you set in Step #1. Then check in the target version.
NOTE: In a selective merge, ClearCase does not create a merge arrow. A merge arrow indicates
that all of a version’s data has been merged, not parts of it.
68 Developing Software
Getting More Information
For detailed information about completing this task, see the merge and version_selector
reference pages in the Command Reference or ClearCase online help:
The project manager has decided that a new feature, implemented in versions 14 through 16 on
the main branch, will not be included in the product. You must perform a subtractive merge to
remove the changes made in those versions (Figure 18).
element: opt.c
/main
13
14
These versions
15 contributions to
be removed
16
17
18
5 - Working On a Team 69
Task Overview
A subtractive merge is the opposite of a selective merge: it removes from the checked-out version
the changes made in one or more of its predecessors. Performing a subtractive merge involves
the following tasks:
1. Set a dynamic view or change directories to a snapshot view. The view must select the branch
from which you want to remove revisions.
2. If the target version is checked out to your view for other revisions, create a pre-merge
checkpoint by checking it in. In Figure 18, the target version is opt.c@@/main/18.
3. To determine which versions contain changes you want to remove, use the Version Tree
Browser and the History Browser. From a snapshot view, use the cleartool get command to
see the contents of versions not loaded into your view.
4. To perform the merge, check out the target version, and then use the cleartool merge
command with the –delete –graphical arguments. (You cannot start a subtractive merge
from Diff Merge.)
For example, the following commands remove revisions to versions 14 through 16 on the
main branch:
5. In Diff Merge, complete the merge. Then save the results and exit. For information on using
Diff Merge, refer to online help.
6. Test the merge results in your view. Then check in the target version (which contains the
results of the merge).
NOTE: In a subtractive merge, ClearCase does not create a merge arrow. A merge arrow indicates
that data has been merged, not removed.
For detailed information about completing this task, see the merge and version_selector
reference pages in the Command Reference or ClearCase online help:
70 Developing Software
Recording Merges That Occur Outside ClearCase
You can merge versions of an element manually or with any available analysis and editing tools.
To update an element’s version tree with a merge that occurs outside ClearCase, check out the
target version, perform the merge with your own tools, and check it back in. Then record the
merge by drawing a merge arrow from the contributors to the new version that contains the
result of the merge. After you’ve drawn the merge arrow, your merge is indistinguishable from
one performed with ClearCase tools.
For example, use the following commands to merge a version of nextwhat.c on the enhance
branch to the branch currently selected by your view:
The –ndata option suppresses the merge but creates merge arrows as if ClearCase had merged
the versions.
For detailed information about completing this task, see the merge and version_selector
reference pages in the Command Reference or ClearCase online help:
5 - Working On a Team 71
If your company uses MultiSite to distribute development among multiple geographical sites,
you may share source files with developers at other sites. Each site has its own replica of the VOB,
and developers work in their site-specific replica (known as the current replica). Each replica
controls (masters) a particular branch of an element, and only developers at that replica’s site can
work on that branch. In this scenario, MultiSite branch mastership does not affect you, and you
can do your work as usual.
However, sometimes elements cannot have multiple branches. For example, some file types
cannot be merged, so development must occur on a single branch. In this scenario, all developers
must work on a single branch (usually, the main branch). MultiSite allows only one replica to
master a branch at any given time. Therefore, if a developer at another site needs to work on the
element, she must request mastership of the branch.
NOTE: The developer can also request mastership of branch types. For more information, see the
Administrator’s Guide for Rational ClearCase MultiSite.
For example, the file doc_info.doc cannot be merged because it is a file type for which you do
not have a type manager, but developers at different sites need to make changes to it. If the branch
is mastered by your current replica, you can check out the file. If the branch is mastered by
another replica, you cannot check out the file. If you try to check out the file, ClearCase presents
an error message:
For you to check out the file reserved or to check in the file after a nonmastered checkout, your
current replica must master the branch. You can request mastership with a cleartool command.
If you have permission to request mastership from the master replica of the branch, if mastership
requests are enabled, and if there are no blocking conditions, then the mastership change is made
at the master replica, and a MultiSite update packet that contains the change is sent to your
current replica. When your current replica imports the packet, it receives mastership of the
branch and you can check out the file.
When you use mastership requests to transfer control of a branch, you can use either of two
methods to do your work:
72 Developing Software
➤ Request mastership of the branch and wait for mastership to be transferred to your current
replica; then perform a reserved checkout. You must use this method if you cannot or do
not want to merge versions of the element.
➤ Request mastership of the branch and check out the branch immediately, using a
nonmastered checkout. You may have to perform a merge before you can check in your
work.
2. Wait for mastership to be transferred to your current replica. To list the master replica of a
branch, use describe:
In this example, your current replica is lexington in the VOB family /doc. The output of the
describe command shows that lexington is the master replica of the branch, which means
that you can check out the branch as reserved.
3. Perform a reserved checkout, edit the file, and check in your work.
5 - Working On a Team 73
To Check Out the Branch Before Mastership Is Transferred
If you can merge versions of the element you need to check out, you can work on the file while
you wait for mastership to be transferred to your replica.
1. Enter a reqmaster command for the branch you need to check out.
4. Wait for mastership to be transferred to your current replica. To list the master replica of a
branch, use describe:
If the checkin fails because you have to perform a merge, proceed to Step #6:
74 Developing Software
6. Merge from the latest version on the branch to your checked-out version.
Troubleshooting
If the request for mastership fails because there are checkouts on the branch at the master replica,
try your request again later or ask the other developer to check in the file or directory and then
try again. If you receive other errors, contact your project manager or MultiSite administrator.
5 - Working On a Team 75
76 Developing Software
6 Other Tasks
6
Chapter 3, Working in a View, describes tasks you perform daily or weekly. You may need to
perform some of these tasks less often:
To add view-private files and directories to source control, or to make placeholders for
nonexistent files and directories:
Your view’s version-selection rules determine the element’s branch on which the first version
is created. Make sure your view creates versions on an appropriate branch.
6 - Other Tasks 77
2. Change to the parent directory under which you want to add files and directories to source
control.
For snapshot views, the path from which you add to source control does not need to be
loaded. However, it must match the VOB namespace.
3. Check out the parent directory element by entering cleartool checkout –nc directory-name.
We suggest using the –nc option because ClearCase appends appropriate comments when
you modify directory elements.
By default, when you add an element, it remains checked out. When you finish modifying the
new elements, check them in. Elements you add to a directory element are visible only in your
view until you check in the directory.
For more information about the mkelem command, see Under the Hood: What Happens When You
Add a File or Directory to Source Control and the mkelem reference page in the Command Reference.
Under the Hood: What Happens When You Add a File or Directory to Source
Control
The mkelem command always creates an element and initializes its version tree by creating a
single branch (named main) and a single, empty version (version 0) on that branch. The
following arguments for the mkelem command determine optional ClearCase behavior:
➤ Using mkelem with no arguments checks out the element. Any view-private data that
corresponds to the element pathname remains in your view only and is added to version 1
in the VOB when you check in (Figure 19).
78 Developing Software
➤ Using mkelem –ci checks in the element, using any existing view-private data that
corresponds to the element pathname as the content for version 1. Your view’s config spec
determines the branch on which ClearCase creates version 1.
➤ Using mkelem –nco suppresses automatic checkout; mkelem creates the new element,
along with the main branch and version/main/0, but does not check it out. If
element-pathname exists, it is moved aside to a .keep file.
➤ (Replicated VOBs only) Using mkelem –master assigns to your current replica mastership of
all branches created during element creation. You will be able to create new versions on the
branches.
Using mkelem without the –master option assigns mastership of a new branch to the VOB
replica that masters the associated branch type. If this replica is not your current replica, you
cannot create new versions on the branch.
Other views do not see the element until you check in the element’s parent directories and check
in the file or directory.
prog.c
/main
Each element is an instance of an element type. You can specify an element type with the –eltype
option. (The lstype –kind eltype command lists a VOB’s element types.) The element type must
already exist in the VOB in which you are creating the new element, or must exist in the Admin
VOB hierarchy associated with the VOB in which you are creating the new element. A mkelem
–eltype directory command is equivalent to a mkdir command.
If you do not specify an element type on the command line, mkelem determines one by using
the magic files to perform file-typing. This involves matching patterns in the new element’s
name (and examining the existing view-private file with that name, if one exists; see Conversion
6 - Other Tasks 79
of View-Private Files to Elements on page 80). If file-typing fails, an error occurs and no element is
created:
For more information about file-typing, see cc.magic in the Command Reference.
Access Mode
Because file elements are read-only, the mode to which your umask is applied is 444 (not 666)
for a file element. When you convert a view-private file to an element (see Conversion of
View-Private Files to Elements on page 80), its read and execute rights become those of the new
element.
You can use the mkelem command to convert a view-private file to a file element with the same
name. There are several cases:
➤ By default, mkelem creates an empty version 0 of the new element, then checks out the new
element to your view. The view-private file becomes the checked-out version of the new
element.
➤ If you use the –ci option (check in), mkelem does all of the above, then proceeds to check in
version 1 of the new element. Thus, version 1 has the contents of the view-private file. With
–ptime, mkelem preserves the modification time of the file being checked in.
➤ If you use the –nco option (no check out), mkelem creates an empty version 0 of the new
element.
During the element-creation process, the view-private is renamed to prevent a name collision
that would affect other ClearCase tools (for example, triggers on the mkelem operation). If this
renaming fails, a warning message appears. There are two renaming procedures:
➤ If a new element is checked out, mkelem temporarily renames the view-private file, using a
.mkelem (or possibly, .mkelem.n) suffix. After the new element is created and checked out,
80 Developing Software
mkelem restores the original name. This action produces the intended effect: the data
formerly in a view-private file is now accessible through an element with the same name.
➤ If no checkout is performed on the new element, mkelem alerts you that the view-private
file has been renamed, using a .keep (or possibly, .keep.n) extension. Note that the
view-private file is not converted to an element; it is moved out of the way to allow creation
of an element in its place.
NOTE:If mkelem does not complete correctly, your view-private file may be left under the
.mkelem file name.
mkelem does not perform any special processing for a nonshareable DO. The process is the same
as for a shareable DO, as described in Conversion of View-Private Files to Elements on page 80.
However, when you check in version 1 of the new element, the checkin converts the
nonshareable DO to a shareable DO, then checks it in.
NOTE: When a nonshareable DO is converted to a shareable DO, its DO-ID changes. For more
information, see Derived Objects and Configuration Records in Building Software.
If you create a new directory element, you cannot use the same name as an existing view-private
file or directory, and you cannot use mkelem to convert an existing view-private directory
structure into directory and file elements. To accomplish this task, use the clearfsimport and
clearimport utilities.
If your config spec has a /main/LATEST rule with a –mkbranch clause, mkelem checks out a
subbranch instead of the main branch. For example, suppose your view has this config spec:
element * CHECKEDOUT
element * .../gopher_port/LATEST
element * V1.0.1 -mkbranch gopher_port
element * /main/LATEST -mkbranch gopher_port
In this case, a gopher_port branch is created for the new element, and this branch is checked out
instead of main:
6 - Other Tasks 81
Created element "base.h" (type "text_file").
Created branch "gopher_port" from "base.h" version "\main\0".
Checked out "base.h" from version "\main\gopher_port\0".
The auto-make-branch facility is not invoked if you use the –nco option to suppress checkout of
the new element. For more about this facility, see the checkout and config_spec reference pages
in the Command Reference.
By default, when you create an element in a replicated VOB, mkelem assigns mastership of the
element’s main branch to the VOB replica that masters the branch type main. If this replica is not
your current replica, you cannot create versions on the main branch. (You can create versions on
other branches if they are mastered by the current replica.)
To assign mastership of a new element’s main branch to the current replica, use the –master
option. The –master option also allows auto-make-branch during element creation, even if the
branch type specified in your config spec is not mastered by the current replica. In this case,
mkelem assigns mastership of newly created branches to the current replica. For example,
suppose your view has the following config spec:
element * CHECKEDOUT
element * .../gms_dev/LATEST
element * /main/LATEST -mkbranch gms_dev
When you create a new element with mkelem –master and do not use the –nco option, mkelem
creates the branches main and gms_dev and assigns their mastership to the current replica.
NOTE: If you use the –nco option with –master, only the main branch is mastered by the current
replica, because it is the only branch created by mkelem.
You sometimes need to distinguish an element itself from the particular version of the element
that is selected by your view. In general:
➤ Appending the extended naming symbol (by default, @@) to an element’s name references
the element itself.
➤ A simple name (no extended naming symbol) is a reference to the version in the view.
For example, msg.c@@ references an element, whereas msg.c refers to a version of that element.
In many contexts (for example, checkin and lsvtree), you can ignore the distinction. But there are
82 Developing Software
ambiguous contexts in which you need to be careful. For example, you can attach attributes and
hyperlinks either to version objects or to element objects. Thus, these two commands are
different:
The first command operates on the version of the element selected in your view, but the second
command operates on the element itself.
CAUTION: Do not create elements whose names end with the extended-naming symbol.
ClearCase software cannot handle such elements.
Storage Pools
Physical storage for an element’s versions (data containers) is allocated in the storage pools that
mkelem assigns. You can change pool assignments with the chpool command.
Each VOB has a group list. If your principal group is on this list, you can create an element in that
VOB. For more information about group lists, see the protectvob reference page in the Command
Reference. Your principal group is the first group listed when you enter the id(1) command.
Importing Files
If you’re adding a large number of files and directories to source control, use the clearfsimport
command (or clearexport commands) and clearimport command. For more information, see the
clearfsimport and clearimport reference pages in the Command Reference.
6 - Other Tasks 83
6.2 Moving, Removing, and Renaming Elements
This section explains how to move, remove, and rename elements.
Because directories as well as files are under ClearCase control, you can move or remove
elements from specific versions of directories without affecting the element itself. Moving or
removing elements creates new versions of the parent directories to record the modifications.
For example, version 4 of /gui_vob/design contains an element named prog.c. If you remove
prog.c from the design directory, ClearCase creates version 5 of /gui_vob/design, which does not
contain the prog.c file element. The element prog.c itself is not modified.
cd pat_v1.4_cropcircle/gui_vob
cleartool ls design@@/main/4
prog.c@@/main/2
lib.c@@/main/10
cleartool checkout –nc design
Checked out “design” version “/main/4”
cleartool rmname prog.c
Removed “prog.c”
cleartool checkin –nc design
Checked in “design” version “/main/5”
cleartool ls design@@/main/5
lib.c@@/main/10
cleartool ls design@@/main/4
prog.c@@/main/2
lib.c@@/main/10
Before you move or remove an element name from a directory, verify with your project manager
that your changes will not adversely affect other team members or break project builds.
84 Developing Software
3. Check in the new parent directory and the source directory.
WARNING: The relocate command makes irreversible changes to at least two VOBs and their
event histories. We recommend that you not use it for minor adjustments. Furthermore, we
recommend that you stop VOB update activity before and during a relocate operation. Check
with your project manager and ClearCase administrator before using the relocate command.
Removing an element from its parent directory does not affect the element itself, but two other
types of a removal operation do irrevocably affect an element, and we recommend that you be
very conservative in using these operations:
➤ Removing a version from an element’s version tree. For more information, see the rmver
reference page in the Command Reference.
➤ Removing an element from a VOB. For more information, see the rmelem reference page in
the Command Reference.
Renaming Elements
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.
6 - Other Tasks 85
cd pat_v1.4_cropcircle/gui_vob
cleartool ls design@@/main/4
prog.c@@/main/2
lib.c@@/main/10
cleartool checkout –nc design
Checked out “design” version “/main/4”
cleartool mv prog.c msg.cat
Moved “prog.c” to “msg.cat”
cleartool checkin design
Default:
Added file element "msg.cat".
Removed file element "prog.c".
Checkin comments for ".": ("." to accept default)
.
Checked in “design” version “/main/5”
cleartool ls design@@/main/5
msg.cat@@/main/2
lib.c@@/main/10
cleartool ls design@@/main/4
prog.c@@/main/2
lib.c@@/main/10
Before you move or remove an element name from a directory, verify with your project manager
that your changes will not adversely affect other team members or break project builds.
To Rename an Element
86 Developing Software
Listing All Elements in the VOB Namespace
You can use the cleartool ls command to see all elements in the VOB namespace, even if they are
not loaded into your snapshot view. This command lists the names of elements cataloged in the
VOB namespace that your view’s config spec selects. The output of cleartool ls includes this
information:
cleartool ls pathname...
For more information, see the ls reference page in the Command Reference.
To access a version of a file not loaded into your view, use the cleartool get command, which
copies the version you specify into your view.You can view nonloaded files or copy them into
your view for build purposes, but you cannot check them out. Only file elements that are loaded
into the view can be checked out.
To copy a nonloaded version of a file element into your view, type a command in this format:
For example:
This command copies prog.c@@/main/v3.1_fix/10 into your view under the name of
prog.c.previous.version.
6 - Other Tasks 87
6.4 Moving Views
This section discusses the following tasks:
For information about changing a view-tag, see the mktag reference page in the Command
Reference.
If the snapshot view storage directory is in a storage location, you can use the standard mv
command to move the snapshot view’s directory tree of loaded elements and view-private files.
You can move the view to a different workstation, but the workstation must run a UNIX
operating system.
CAUTION: If the view storage directory is located below the root directory of the view, do not use
the standard mv command to move the snapshot view. Instead, see Moving a View Storage
Directory on page 89.
The Global Path field displays the pathname for the view storage directory.
After moving a snapshot view, you must use cleartool update (or cleartool update –print) to
modify .ccase_svreg in your home directory. Some ClearCase operations use information from
this file and will not succeed until you use update to modify it.
88 Developing Software
Moving a View Storage Directory
Each dynamic view and snapshot view includes a view storage directory, which ClearCase uses
to maintain the view. Do not use the standard mv command to move a view storage directory
for the following reasons:
➤ The view storage directory includes a database. Moving the database without first shutting
down the view’s view_server process can corrupt the database.
➤ ClearCase stores the location of view storage directories in its own set of registries. The
information in these registries must be correct for you to perform ClearCase operations in
your views. In a dynamic view, the location in ClearCase registries must be correct for you
to access any file or directory in the view.
We suggest that you ask your ClearCase administrator to move view storage directories because
it may affect other, potentially many other, ClearCase users at your site. For more information
about the procedure for moving view storage directories, see the Administrator’s Guide for
Rational ClearCase.
CAUTION: You will lose data (including view-private files in a dynamic view) if you move a view
storage directory without following the procedure described in the Administrator’s Guide for
Rational ClearCase.
6 - Other Tasks 89
2. Type this command:
Perl ccase-home-dir/etc/utils/regen_view_dot_dat.pl \
[ –tag snapshot-view-tag ] snapshot-view-pathname
For example:
If the view storage directory is under the root directory of the view, you do not need to use
the –tag snapshot-view-tag argument.
If you inadvertently delete or corrupt this file, you must regenerate information in .ccase_svreg
for each snapshot view that you use. To do so, update the view with either of the following
commands:
➤ cleartool update
➤ cleartool update –print
90 Developing Software
Creating Views Across Platforms of Different Types
Your administrator can set up storage locations on Windows and UNIX server hosts. Any
snapshot view that you create can use one of these storage locations, regardless of the platform
type of the server host. For more information about storage locations, see the mkstgloc reference
page in the Command Reference.
For a dynamic view, the view storage directory must be located on a host of the same platform
type as the host from which you create the view. If you create a dynamic view from a UNIX host,
you must locate the view storage directory on a ClearCase host on UNIX; if you create a dynamic
view from a Windows host, you must locate the view storage directory on a Windows NT host
that is set up to store view storage directories. We recommend that you locate dynamic view
storage directories on the host from which you most often use the view.
For snapshot views, the operating system type from which you create the view determines view
characteristics; the operating system type that hosts the files and processes related to a snapshot
view do not affect the view’s behavior.
For example, it is possible to create a snapshot view from a Windows host and locate the view
directory tree and the view storage directory on a ClearCase host on UNIX (assuming that you
use third-party software to access UNIX file systems from Windows computers). Even though all
files related to the view are on a UNIX workstation, because you created the view from a
Windows host, the view behaves as if its files are located on a Windows computer: it does not
create symbolic links if the load rules encounter a VOB symbolic link, and you can issue
ClearCase commands for the view only from Windows hosts. (ClearCase hosts on UNIX do not
recognize the directory tree as a snapshot view.)
This section describes support for accessing a view residing on a platform that differs from the
platform from which it is being accessed.
ClearCase supports a set of third-party products for accessing UNIX file systems from Windows
computers. If your organization uses one of these products, you can access UNIX snapshot views
6 - Other Tasks 91
from Windows Explorer (or a command prompt) just as you would access any other directory
tree on a UNIX workstation.
You can access snapshot views across platforms, but you cannot issue ClearCase commands
across platforms. For example, you cannot check out files in UNIX snapshot views from
Windows hosts nor can you create shortcuts to UNIX snapshot views from ClearCase Explorer.
If, from a Windows host, you hijack a file in a UNIX snapshot view, ClearCase detects the hijack
when you update the view from a ClearCase host on UNIX.
ClearCase does not support accessing Windows file systems from UNIX workstations.
ClearCase supports a set of third-party products for accessing UNIX file systems from Windows
computers. If your organization uses one of these products, you can complete the following tasks
to access UNIX dynamic views from Windows computers:
1. Create the UNIX view with the proper text mode. For more information, see Developing
Software Across Platforms of Different Types on page 93.
2. Import the UNIX view’s view-tag into your Windows network region.
ClearCase does not support products for accessing Windows file systems from UNIX
workstations. You cannot access Windows views from UNIX hosts.
Your administrator sets up VOBs on Windows or UNIX hosts and creates VOB-tags in each
ClearCase network region that needs to access the VOBs. (For information about registering
UNIX VOB-tags in a Windows network region, see the Administrator’s Guide for Rational
ClearCase.) Then, from any ClearCase host on Windows or UNIX systems, you can create
snapshot views to load elements from VOBs that have tags in your network region.
92 Developing Software
From a ClearCase host on Windows that supports dynamic views, you can access VOBs on
Windows and UNIX from dynamic views as well as snapshot views. To access VOBs on UNIX
from Windows dynamic views, you must use third-party software that provides access to UNIX
file systems from Windows computers. From a ClearCase host on UNIX, you cannot access VOBs
on Windows from dynamic views. Table 2 summarizes your options for accessing VOBs across
platform types.
Platform of your ClearCase Platform on which VOB is View from which you can
host located access source files
If developers check in source files from views created on both Windows and UNIX hosts,
consider creating your views in interop (MS-DOS) text mode. The text modes change how a view
manages line terminator sequences. For more information about view text modes, see the
Administrator’s Guide for Rational ClearCase or ClearCase online help.
6 - Other Tasks 93
94 Developing Software
A Working in a Snapshot View While
Disconnected from the Network
A
If you need to work with your source files from a computer that is disconnected from the
network of Rational ClearCase hosts and servers, you can set up a snapshot view for
disconnected use.
NOTE: While disconnected from the network, you cannot access ClearCase information about the
files in your view or issue most ClearCase commands. If you want to work from a remote
location and continue to access ClearCase information and issue ClearCase commands, consider
using the ClearCase Web interface. Ask your ClearCase administrator whether the ClearCase
Web interface has been configured at your site and what URL you need to supply to your Web
browser to access it. For information about using the Web interface, see the Web interface online
help.
➤ Creating and using the view on a laptop computer that periodically connects to the network
(Figure 20).
ClearCase host
View
➤ Creating and using the view on a removable storage device such as an external hard drive
or some other device (such as a Jaz drive) that provides satisfactory read/write
performance (Figure 21).
Removable
storage device
96 Developing Software
➤ Copying the view from a ClearCase host to a temporary, removable storage device such as a
diskette or a tape drive, which usually does not provide satisfactory read/write
performance, and then copying the view from the storage device to a computer that is
disconnected from the network (Figure 22).
View View
Copy View Copy
In all the configurations recommended for disconnected use, the snapshot view storage directory
is in a server storage location. We recommend this configuration because a view’s view_server
process runs on the host that contains the view storage directory. A view_server is a long-lived
process that manages activity for a specific view. If the view storage directory is in the root
directory of the snapshot view and you disconnect the view from the network while the
view_server process is writing to the storage directory, you can corrupt the data ClearCase uses
to maintain your view.
➤ Update the view to establish a checkpoint. (For information on updating the view, see
Updating the View on page 103.)
When you are no longer connected to the network, you cannot use most ClearCase commands.
At this point, the disconnected computer does not distinguish a snapshot view directory from
any other directory in the file system.
If you do not have a storage device with satisfactory read/write performance, use a standard
UNIX copy command to copy files from your view to the storage media and from the storage
media to the remote computer. To prevent ClearCase from identifying copied files as hijacked, use
copy command options to preserve file times. For example:
cp –Rp
Hijacking a File
If you need to modify a loaded file element that you have not checked out, you can hijack the file.
ClearCase considers a file hijacked when you modify it without checking it out. For more
information, see Under the Hood: How ClearCase Determines Whether a File is Hijacked on page 103.
When you reconnect to the network, you use the Update Tool to find the files you hijacked. You
can do the following with a hijacked file:
98 Developing Software
➤ Check out the file. You can then continue to modify it and, when you’re ready, check in your
changes.
➤ Undo the hijack. For more information, see To Undo a Hijack on page 103.
To Hijack a File
Use chmod to add the write permission and then modify the file. For example:
chmod +w prog.c
To find all files that have been modified within a specified number of days, use the following
command:
For example, to find all files modified within the last two days, enter this command:
If you copied the view onto removable media, use a standard UNIX copy command to copy files
back to the original location on the network computer.
2. In the Update dialog box, click Preview only. Then click OK.
3. If any hijacked files are in your view, the ClearCase Snapshot View Update window displays
a folder in the left pane titled Hijacked (Figure 23). Select No for the option asking whether
you want to check out the hijacked files now.
Hijacked folder
You can use the Diff Merge tool to see how the hijacked file differs from the checked-in version
of the file:
1. In the right pane of the ClearCase Snapshot View Update window, click a hijacked file.
2. Click Tools > Compare with old. For information on using the Diff Merge tool, see the online
help.
1. In the right pane of the ClearCase Snapshot View Update window, click a hijacked file.
If you’re working with a shared set of versions and someone has checked in a newer version of
the file while it was hijacked in your view (Figure 24), ClearCase prevents you from checking in
the file.
prog.c
/main
You have to merge the latest version in the VOB with the checked-out file before ClearCase
allows the checkin.
To merge the latest version in the VOB to the checked-out version in your view, enter the
following command:
For example:
Using the –graphical option starts the Diff Merge tool. For information about using the Diff
Merge tool, see the ClearCase online help. After merging, save the results and check in the
version by entering the cleartool checkin command from the view.
If, for specific hijacked files, you want to discard your changes and get a fresh copy of the version
from the VOB, you can undo the hijack.
1. In the right pane of the ClearCase Snapshot View Update window, select one or more
hijacked files.
2. Click the selected files, and click Tools > Undo hijacked file.
ClearCase overwrites the hijacked file with the version that was loaded in the view. If you want
to overwrite hijacked files with the versions the config spec selects in the VOB, see Step #2 in
Updating the View on page 103.
To keep track of file modifications in a snapshot view, ClearCase stores a loaded file’s size and
last-modified time stamp (as reported by the UNIX file system). ClearCase updates these values
each time you check out a file, check in a file, or load a new version into the view.
To determine whether a file is hijacked, ClearCase compares the current size and last-modified
time stamp of a non-checked-out file with the size and time stamp recorded in the view database.
If either value is different from the value in the view database, ClearCase considers the file
hijacked.
Changing a non-checked-out file’s read-only permission alone does not necessarily mean
ClearCase considers the file hijacked.
While updating the view, you can handle hijacked files in any of the following ways:
2. To configure the Update Tool for handling hijacked files, in the Update dialog box click the
Advanced tab and select a method for handling the remaining hijacked files. You have these
choices:
Index 105
Index 107
W
working from a remote location
about 95
hardware configurations 96
removable storage devices 96
updating view 97