8.4 Working with Global Types

In general, all operations on a global type or a local copy of a global type apply to the global type and all its local copies. ClearCase LT prevents attempts to eclipse global types (that is, it prevents creating an ordinary type with the same name as a global type).

Examples in this section use the cleartool command line. You can also use the Metadata subnode of a VOB node in the ClearCase Administration Console.

Creating a Global Type

The cleartool commands mkattype, mkbrtype, mkeltype, mkhltype, and mklbtype include the -global option, which creates a global type object in the current VOB. Client VOBs linked to this VOB can use the global types.

Local copies of global types are created in client VOBs only when a user creates an instance of the type in the client VOB.

The following command creates a global label type in VOB \admin:

cleartool mklbtype -c "final label for REL6" -global REL6@\admin
Created label type "REL6".

You cannot create a global type if any client VOB contains types with the same name. When you create a new global type, you can check for types with the same name in client VOBs. If the types are identical (except for comments and locks, which can be different), the creation operation converts the existing types to local copies of the global type and changes their comments to match. Use the -acquire option with the mk**type command to check for and acquire identical ordinary types.

For example:

cleartool describe -fmt "%n\t%[type_scope]p\n" lbtype:V3.2@\dev
V3.2 ordinary

cleartool mklbtype -c "Release 3.2" -global -acquire V3.2@\admin
Created label type "V3.2".

cleartool describe -local -fmt "%n\t%[type_scope]p\n" lbtype:V3.2@\dev
V3.2 local copy

If the types are not identical, the operation prints a warning and fails. If a type is locked, it is reported as not acquirable, and the operation continues with other types. To correct this problem, remove the lock and enter a new mk**type command with the -replace -global -acquire options, or use the checkvob -global command.

Use the -replace -global -acquire options either to acquire and replace eclipsing ordinary types that were created after the global type was first created or to convert an ordinary type in an administrative VOB to a global type.

Auto-Make-Type Operations

In general, when you create an instance of a global type in a client VOB, ClearCase LT creates a local copy of the global type in the client VOB. Specifically:

In addition, ClearCase LT sets the permissions and ownership of the local copy to be the same as those of the global type.

EXCEPTION: When you create a trigger type and specify a global type as an argument to a built-in action (the arguments -mklabel, -mkattr, and so on), ClearCase LT does not create a local copy of the global type. This behavior preserves the rule that built-in actions cannot cause cascading triggers. Therefore, if you create the trigger in a client VOB that does not contain a local copy of the global type, the mktrtype command fails.

The following example shows the creation of an instance of a global label type. The output of the command includes the VOB-tag of the administrative VOB.

cleartool mklabel -c "Release 6" REL6 \dev\file.c
Automatically created label type "REL6" from global definition in VOB "\admin".
Created label "REL6" on "\dev\file.c" version "/main/rel6_main/31".

Describing Global Types

By default, the describe command shows the description of the global type for the object selector you specify. You can enter the command in the context of a client VOB even if the client VOB does not contain a local copy of the type. To describe the local copy, use the -local option.

The following command describes a global type:

cleartool describe -long lbtype:REL6@\dev
label type "REL6"
created 28-Jul-99.14:00:26 by Suzanne Gets (smg.user@neon)
"final label for REL6"
owner: smg
group: user
scope: global
constraint: one version per element
Hyperlinks:
GlobalDefinition@47@\dev <- lbtype:REL6@\dev

The following command describes the local copy of a global type:

cleartool describe -local -long lbtype:REL6@\dev
label type "REL6"
created 28-Jul-99.14:23:45 by Suzanne Gets (smg.user@neon)
"Automatically created label type from global definition in VOB "\admin"."
owner: smg
group: user
scope: this VOB (local copy of global type)
constraint: one version per element
Hyperlinks:
GlobalDefinition@47@\dev -> lbtype:REL6@\admin

If you specify -local and no local copy exists, describe prints an error:

cleartool describe -local lbtype:NOLOCAL@\dev
cleartool: Error: Not a vob object: "lbtype:NOLOCAL@\dev".

Listing Global Types

By default, the lstype command lists global types associated with local copies, even if you specify the client VOB in the -invob option. The output also includes global types from all administrative VOBs above this VOB in the administrative VOB hierarchy, even if the client VOB does not contain local copies of the type. To show client information only, use the -local option.

The following command lists all label types in the client VOB, including all global types from administrative VOBs in the hierarchy:

cleartool lstype -fmt "%n\t%[type_scope]p\n" -kind lbtype -invob \dev
BACKSTOP ordinary
CHECKEDOUT ordinary
LABEL1 global
LATEST ordinary
REL6 global

The following command lists ordinary types and local copies of global types (if the specified VOB is an administrative VOB, global types are also listed):

cleartool lstype -local -fmt "%n\t%[type_scope]p\n" -kind lbtype -invob \dev
BACKSTOP ordinary
CHECKEDOUT ordinary
LATEST ordinary
REL6 local copy

Listing History of a Global Type

By default, the lshistory command lists the history of the global type for the object selector you specify, even if there is no local copy of the type in the client VOB. To list the history of a local copy, use the -local option. Specifying -all or -avobs implicitly specifies -local.

The following command lists the history of a global label type:

cleartool lshistory -minor lbtype:REL6@\dev
28-Jul.14:00 smg make hyperlink "GlobalDefinition" on label type "REL6"
"Attached hyperlink "GlobalDefinition@47@\dev".
Automatically created label type from global definition in VOB "\admin"."
28-Jul.13:57 smg create label type "REL6"

The following command lists the history of a local copy of a global label type:

cleartool lshistory -local -minor lbtype:REL6@\dev
28-Jul.14:00 smg make hyperlink "GlobalDefinition" on label type "REL6"
"Attached hyperlink "GlobalDefinition@47@\dev".
Automatically created label type from global definition in VOB "\admin"."
28-Jul.14:00 smg create label type "REL6"
"Automatically created label type from global definition in VOB "\admin"."

Changing Protection of a Global Type

Changing the protection of a global type or of a local copy of a global type changes the protection of the global type and all its local copies. You must have permission to change the protection of the global type. You can enter the command in the context of a client VOB even if the client VOB does not contain a local copy of the type.

In this example, the owner of the label type LABEL1 is changed to jtg. The describe command shows that the protection change is made to all local copies of the global type.

cleartool protect -chown jtg lbtype:LABEL1@\dev
Changed protection on "LABEL1".

cleartool describe -local lbtype:LABEL1@\re
label type "LABEL1"
...
owner: jtg
group: user
scope: this VOB (local copy of global type)
...

If the protection cannot be changed on one or more of the local copies, the operation fails and the global type's protection is not changed. This failure leaves the global type and its local copies in inconsistent states. You must fix the problem and run the protect command again.

Locking or Unlocking a Global Type

Locking or unlocking a global type or one of its local copies locks or unlocks all local copies. The describe command does not list local copies as locked, but access checking on local copies checks for a lock on the global type.

For example, the following command locks the global label type REL6 and its local copies:

cleartool lock -c "freeze" lbtype:REL6@\dev
Locked label type "REL6".

Attempts to create instances of the label type fail:

cleartool mklabel -c "last version" REL6 \re\tests.txt
cleartool: Error: Lock on label type "REL6" prevents operation "make hyperlink".
cleartool: Error: Unable to create label "REL6" on "\re\tests.txt" version "/main/5".

If you enter a lock command in a client VOB that does not contain a local copy of the specified type, ClearCase LT searches for the global type in the administrative VOB hierarchy.

By default, lslock lists the lock state of the global type. To list the lock state of the local copy, use the -local option.

Changing the Type of an Element or Branch

You can use the chtype command to change the type of an element (convert the element from one type to another) or a branch (rename the branch). If the new type is a global type and a local copy does not exist in the client VOB, the chtype command creates the local copy.

For more information on changing a type, see the chtype reference page.

Copying a Global Type

When you copy a global type to the same name (in a different VOB), the cptype command preserves the global type associations of the copied global type when either of these conditions is true:

In all other cases, the type is created as an ordinary (that is, nonglobal) type.

Renaming a Global Type

Renaming a global type renames all its local copies. Also, renaming a local copy of the global type renames the specified local copy, all other local copies, and the global type itself. If you enter a rename command in a client VOB that does not contain a local copy of the specified type, ClearCase LT searches for the global type in the administrative VOB hierarchy.

All local copies are renamed first; then the global type is renamed. If any of the local copies cannot be renamed, the command fails and the global type is not renamed. This failure leaves the global type and its local copies in inconsistent states. You must correct the problem and enter the rename command again.

For more information on renaming types, see the rename reference page.

Changing the Scope of a Type

To convert an existing ordinary type to a global type, enter a mkattype, mkbrtype, mkeltype, mkhltype, or mklbtype command with the options -replace -global -acquire. These commands convert the type and convert any identical types in client VOBs to local copies of the type. For example:

  1. An administrative VOB and one of its client VOBs contain identical ordinary label types named IDENT:

  2. cleartool describe lbtype:IDENT@\admin
    label type "IDENT"
    created 02-Aug-99.15:32:52 by Suzanne Gets (smg.user@neon)
    owner: smg
    group: user
    scope: this VOB (ordinary type)
    constraint: one version per element

    cleartool describe lbtype:IDENT@\dev
    label type "IDENT"
    created 01-Aug-99.15:33:00 by Suzanne Gets (smg.user@neon)
    owner: smg
    group: user
    scope: this VOB (ordinary type)
    constraint: one version per element

  3. Convert the label type in the administrative VOB to be a global type:

  4. cleartool mklbtype -replace -global -acquire IDENT@\admin
    Replaced definition of label type "IDENT".

  5. The output of the describe command shows that the label type in the administrative VOB is now global, and the label type in the client VOB is now a local copy of the global type:

  6. cleartool describe -local lbtype:IDENT@\admin lbtype:IDENT@\dev
    label type "IDENT"
    created 02-Aug-99.15:32:52 by Suzanne Gets (smg.user@neon)
    owner: smg
    group: user
    scope: global
    constraint: one version per element
    Hyperlinks:
    GlobalDefinition <- lbtype:IDENT@\dev
    label type "IDENT"
    created 02-Aug-99.15:32:52 by Suzanne Gets (smg.user@neon)
    owner: smg
    group: user
    scope: this VOB (local copy of global type)
    constraint: one version per element
    Hyperlinks:
    GlobalDefinition <- lbtype:IDENT@\dev

To convert an existing global type to an ordinary type, enter a mkattype, mkbrtype, mkeltype, mkhltype, or mklbtype command with the options -replace -ordinary. These commands convert the type and all its local copies to ordinary types. You must specify the global type in the command; you cannot specify a local copy of the type. For example, to convert the global element type doc_file to an ordinary type, and the administrative VOB is \admin, enter the following command:

cleartool mkeltype -replace -ordinary -nc eltype:doc_file@\admin

You can also use the -replace option to change the constraints of a type if the normal ClearCase LT restrictions allow the change.

Removing a Global Type

Removing a global type removes all the local copies. Also, removing a local copy removes the specified copy, all other local copies, and the global type itself. The rmtype command lists the client VOBs that have local copies of the global type, then prompts for confirmation of the removal. You must use the -rmall option with the rmtype command.

For example:

cleartool rmtype -nc lbtype:LABEL1@\dev
cleartool: Error: There are labels of type "LABEL1".
cleartool: Error: Unable to remove label type "LABEL1".

cleartool rmtype -nc -rmall lbtype:LABEL1@\dev
There are 1 instance(s) of label type "LABEL1" in \re.
There are 1 instance(s) of label type "LABEL1" in \dev.
Remove all instances of label type "LABEL1"? [no] yes
Removed label type "LABEL1".

Notes on removing global types:

For more information on removing types, see the rmtype reference page.

Cleaning Up Global Types

Use checkvob -global to check and fix global types that are in an inconsistent state. For more information, see Chapter 13, Using checkvob.