®
IBM Software Group
Essentials of Rational ClearCase Module 4: Working with Elements and Views
1
Objectives Upon completing this module, you should be able to:
Add files to source control
Compare versions of elements
Move, rename, and remove elements and versions
View an element history
Find checkouts
Change an element checkout status
Cancel a checkout
Select versions other than those in your view
Remove a view 2
Module Topics Working with Elements Adding files and directories to source control Comparing versions of elements Moving, renaming, and removing elements and versions Viewing an element history The lost+found directory
Working with Views
Finding checkouts Changing a checkout status Canceling a checkout Specifying versions using version-extended names Removing a view 3
Adding Files to Source Control As you work on a project, you may create viewprivate files that you want to add to source control You can add Files Directories
Add files to source control GUI — Add to Source Control Command Line — mkelem Utility — clearfsimport 4
Adding Files to Source Control (cont.) When you add a file to source control, ClearCase: Determines the file type Creates an element Creates the /main branch and an empty version 0 By default, checks in the element and creates version 1
5
Adding Files to Source Control (cont.)
1 Select the items to add to source control, right-click, and then click Add to Source Control.
2 Select to work on elements after you add them to source control; clear to check in elements.
6
Adding Directories to Source Control Add directories to source control the same way you add individual files
When you add a directory to source control, files within the directory remain view-private
7
Adding Many Files or Directories When you must add a number of files or directories to source control use clearfsimport clearfsimport is a command-line utility that converts file system directories and files to ClearCase elements clearfsimport creates new elements or adds new versions to existing elements
8
Working with VOB Symbolic Links A VOB symbolic link makes a file element or directory accessible from more than one location in the VOB VOBs and directories are sometimes symbolically linked for organizational purposes Links are generally created by the ClearCase Administrator 9
Comparing File and Directory Versions ClearCase allows you to compare element and directory versions Can compare a version with predecessor or with any other previous version in the tree In GUI, invokes graphical Compare tool that compares contents of files and directories
10
Comparing File Versions The Compare tool displays a graphical comparison of text files.
11
Comparing Directory Versions The Compare tool enables you to view, side-by-side, the elements appearing in two versions of a directory.
12
Moving an Element From ClearCase Explorer only, drag and drop to move elements within a VOB.
13
Removing References to an Element Remove the name of an element or VOB symbolic link from a directory list The element still exists in the VOB
14
Renaming an Element
Select element, right-click, and then click Rename.
15
Removing a Version Deletes one or more versions of an element from the VOB. Select version, right-click, and then click Delete.
Removes all metadata items that were attached to the deleted version(s).
16
Removing an Element Removes an element COMPLETELY from the VOB; there is NO WAY to restore it Removes all references to it in ALL directory lists You cannot remove elements that have checked-out versions To remove an element, you must be the element owner, VOB owner, or have ClearCase administrative privileges 17
Viewing an Element History An element history is recorded in event records in the VOB A ClearCase operation, such as checkout, causes an event record to be created Event records include: who, what, when, where, and comments associated with the event
Screenshot: Element history example
18
The lost+found Directory Found in every VOB at the highest directory level Contains orphaned elements, which are elements that are no longer cataloged in any version of any directory
19
Module Topics Working with Elements
Adding files and directories to source control Comparing versions of elements Moving, renaming, and removing elements and versions Viewing an element history The lost+found directory
Working with Views Finding checkouts Changing a checkout status Canceling a checkout Specifying versions using version-extended names Removing a view 20
Finding Checkouts The Find Checkout tool enables you to search for checkouts based on user-defined criteria.
21
Finding Checkouts Based on selection criteria, ClearCase displays a list of the checked out files in the Find Checkouts window.
22
Changing the Checkout Status From the Find Checkouts window, you can change the status of a checkout To change the status of a checkout, you must be one of the following: ClearCase group member VOB owner
Element owner Element group member
23
Canceling a Checkout Cancel a checkout when you do not want to save changes or want a fresh copy You can rename and save a view-private version of the file: filename.keep. If you do not save the file, all changes are lost
24
Canceling a Checkout You can cancel a checkout from the Find Checkouts window Once you undo a checkout, your view selects the predecessor version
25
Selecting a Version Other Than Those in Your View Enable you to specify a version that may not be visible in your dynamic view @@ (extended-naming symbol) denotes a path into the version tree of an element Specific integer versions hello.h@@\main\rel2_bugfix\9 User-defined version labels util.c@@\REL3
26
Using a Version-Extended Name Using a standard name, you access the version of the file that your dynamic view selects: Z:\Hardware\src>type hello.c #include "hello.h" printf("Hello, %s!\n", env_user() ); int main() { printf("Your home directory is %s.\n", env_home()
); }
printf("It is now %s.\n", env_time() ); return 0;
To see a version other than the one selected by your dynamic view, use a version-extended pathname: Z:\Hardware\src>type hello.c@@\main\r2_int\1 main() { printf(“Hello there, world!\n); }
27
Removing a View Views are temporary, task-related objects; once a specific development task or project is complete, remove the view Before removing a view, add all important view-private files to source control or copy them to another location Removing the view will: Clean up VOB references to the view Remove the view storage directory Remove the view tag and unregister the view Stop view server processes Do NOT use Windows Utilities to remove a view storage directory 28
Removing a View (cont.) 1
Click Remove View on the Toolbox tab in Shortcut pane. 2 Select the view you want to remove, and then click OK.
29
Module Review What does ClearCase do when you add a file to source control? What is the easiest way to add many files and directories to source control in ClearCase? What is the lost+found directory? Why is it significant? How can you find out which VOB elements are checked out? How do you access versions of elements other than those selected by your view config spec? Why would you want to remove a view? Why should you not use operating system utilities to remove a view? 30
Module Lab In this lab, you perform the following tasks: Add files to source control Move and rename an element View an element history Find checkouts Access versions not selected by your view Remove a view
31
32