Evil Twin Finder
Andrew DeFaria <Andrew@ClearSCM.com>
Fri Apr 23 09:40:31 PDT 2010
Modifed 2011/01/09 01:00:28
Usage: eft.pl [-u|sage] [-ve|rbose] [-d|ebug] [-di|rectory <dir>] Where: -u|sage: Displays usage -ve|rbose: Be verbose -d|ebug: Output debug messages -dir Directory to process
This script will search for existing evil twins in a Clearcase vob. It is intended to be used in the context of a base Clearcase view with a default config spec.
An evil twin is defined as two or more Clearcase elements that share the same path, and same name, but have different OIDs thus having different version histories. This can occur when a user creates an element in a directory that used to exist in this same directory on another branch or on a previous version of the same branch. By default Clearcase will create an element with a new OID. This new, evil twin will then develop it's own version history. This then becomes a problem when you attempt to merge branches - which twin (OID) should Clearcase keep track of?
Most Clearcase users implement an evil twin trigger to prevent the creation of evil twins but sometimes evil twins have already been created. This script helps identify these already existing evil twins.
Note: Evil twins can also happen if you only apply your evil twin trigger to the mkelem Clearcase action. It should be applied to the lnname action as elements come into creation by things like the cleartool ln, mv and mkdir commands. These all eventually do an lnname so that's where you should put your evil twin trigger.
TODO: Is cleartool find really needed? I mean since we are going through the extended version namespace don't we by default find all subdirectories?
This script will use cleartool find to process all directory elements from $startingDir (Default '.'). For each version of the directory a hash will be built up containing all of the element names in that directory version. Elements are always added and never deleted in this hash as we are looking for all elements that have ever existed in the directory at any point in time.
This script then dives into the view extended namespace for directory elements examining the internal Clearcase structures. If we find a branch we recurse or numbered directory version we recurse looking for file elements (TODO: What about directory evil twins?). Note that we skip version 0 as version 0 is never interesting - it is always a duplicate of what it branched from and empty.
Directory versions that are not numbered are labels or baselines that point to numbered directory versions so we don't need to look at them again.
For each file element we find we use the cleartool dump command to get the OID of this particiular versioned element and build up an array of hashes of all the elements in the directory. For each element version we maintain a hash keyed by the OID. The structure also contains a count of the number of times the OID was found. An evil twin therefore will have multiple OIDs for the same element version name.
After the directory is processed we look though the array of hashes for elements that have multiple OIDs and report them. Then we proceed to the next directory.
Report any evil twins found in %directoryInfo
Structure representing the OIDs of element in a direcotry
Build up a data structure for $dirName looking for evil twins
Directory to examine
Directory info hash keyed by element name whose value is an array of oidInfo hashes containing a unique OID and a count of how many occurences of that OID exist for that element.
Process all directories under $startingDir
Directory to start processing
Total number of evil twins found
CONFIGURATION AND ENVIRONMENT
DEBUG: If set then $debug is set to this level.
VERBOSE: If set then $verbose is set to this level.
TRACE: If set then $trace is set to this level.
ClearSCM Perl Modules
BUGS AND LIMITATIONS
There are no known bugs in this script
Please report problems to Andrew DeFaria <Andrew@ClearSCM.com>.
LICENSE AND COPYRIGHT
Copyright (c) 2010, ClearSCM, Inc. All rights reserved.