Profile.pm - site-wide customizations for ct wrapper
1.17
This perl module functions as a wrapper for cleartool, allowing the command-line interface of cleartool to be extended or modified. It allows defaults to be changed, new flags to be added to existing cleartool commands, or entirely new cleartool commands to be synthesized.
Unfortunately, there's no equivalent mechanism for wrapping GUI access to clearcase.
Here's a quick overview of the extensions available via ct which may be of interest to users:
Many cleartool commands have been enhanced to simulate the standard flags -dir, -rec, -all, and -avobs which cause the command to operate on (respectively) all eligible elements in the current dir, the current dir recursively, the current vob, and all vobs. The enhanced commands include checkin/ci, unco, diff, mkelem, and lsprivate. Thus you could check in all checkouts in the current view with ct ci -avobs or see the view-private files in and under the current dir with ct lsprivate -rec. You can convert a tree of view-private data into elements with ct mkelem -rec -ci.
The ct checkin command is also enhanced to take a -diff flag which prints your changes to the screen before prompting for a comment.
A new command ct edit is added. This is the same as ct checkout but execs your favorite editor after checking out. It also takes a -ci flag which will check the file in afterwards.
All commands which take a -tag view-tag option are enhanced to recognize the -me flag. This modifies the effect of -tag by prepending your username to the view name. E.g. -tag foo -me is a shorthand for -tag <username>_foo. Similarly, ct lsview -me will show only views whose names match the pattern <username>_*.
The ct mkview command is enhanced to default the view-storage location to a standard place using a standard naming convention. See SiteProfile.pm.sample for how this is set up. Also, mkview recognizes the -me flag as described above. This means that making a new view can/should be done as ct mkview -tag foo -me.
New pseudo-commands ct edattr and ct edcmnt are added. These make it easy to edit the attributes and comments, respectively, of a particular version.
A new command ct rmpriv is added, which behaves like
rm -i `ct lsprivate -rec`
, though -dir or -all may be
substituted for -rec and -f may be passed to override -i.
Detailed descriptions of all the above may be found below. Summaries are available via the standard -h flag.
##:Start: dir
is present
then the value of dir is printed. Otherwise no output is produced.
Extended to allow symbolic links to be ``checked in'' (by simply checking in the target of the link instead).
Extended to implement a -diff flag, which runs a ct diff -pred command before each checkin so the user can look at his/her changes before typing the comment.
Also, automatically supplies -nc
to checkins if the element list
consists of only directories (directories get a default comment).
Implements a new -revert flag. This causes identical (unchanged) elements to be unchecked-out instead of being checked in.
Also extended to implement a -iff flag. This reduces the supplied list
of elements to those truly checked out. E.g. ct ct -iff *.c
will check
in only the elements which match *.c and are checked out, without
producing a lot of errors for the others.
Automatically defaults checkouts to use -nc. This could be done with clearcase_profile as well, of course, but is more centralized here.
Also, ct edit -dir will not check anything out but will exec the editor on all currently checked-out files.
Extended to handle the -dir/-rec/-all flags. Also adds a -c flag to generate a context diff (by simply using the real diff program).
ct review -all
.
-dir/-rec
flags. If the -ci flag is present,
any directories automatically checked out are checked back in too.
Extended to accept (and ignore) the -nc flag for consistency with other cleartool cmds.
Extended to handle the -dir/-rec/-all flags.
Also completely implements the setview command on Windows where it's
not native. This is done by mapping a drive letter, cd-ing to that
drive, and starting a subshell. A -persistent
flag is supported
which causes the drive to stay mapped when done as well as -drive
allowing you to specify a drive letter.
Working on a profile is actually quite easy if you remember that within
it $_ is set to the command name, @ARGV is the complete command
line and @_ is a copy of it, $0 is the path to the wrapper, and
$CT is the path to the real cleartool program. Also, the
hash %Vgra is a reverse lookup such that $ARGV[$Vgra{xyz}] eq "xyz"
.
With most perl modules, the .pm
code itself (the part that gets
found via @INC
) is static - it's not generally modified except via
updates of the module. Meanwhile, users write code to use the module
and that code is fluid; they change it as they please. This module is
backwards from that since the ct program is policy-free and thus
shouldn't need to be changed significantly. Meanwhile, the
Profile.pm is intended to be a reflection of the local policies and
preferences; the provided Profile.pm is simply a sample of what
can be done.
The Profile.pm does not establish a separate namespace; it operates
within main::
. There did not seem to be any good reason to do so,
since the whole point is to operate directly on the namespace provided
by the client program ct.
The ct program is normally expected to be used under that name,
which means that users running cleartool lsco, for instance, will go
around the wrapper. However, it's also designed to allow for complete
wrapping if desired. To do so, move $ATRIAHOME/bin/cleartool
to
$ATRIAHOME/bin/wrapped/cleartool
and install ct as
$ATRIAHOME/bin/cleartool
. You can continue to install/link the wrapper
as ct as well - it won't invoke the wrapper twice because it
contains code to detect the presence of the moved-aside binary and run
it.
As a safety mechanism, the require
-ing of the profile is handled
within an eval
block, so a syntax error or config problem in the
profile won't cause it to fail. It will simply print a warning and
continue.
David Boyce, dsb@world.std.com
cleartool(1), perl(1).