p4_unmanaged

Peter Wemm peter at wemm.org
Sat Nov 20 20:38:12 GMT 2004


I've often been hosed by stray files laying around in my src trees.
cvs update will identify them, but p4 doesn't.  Justin Gibbs pointed
me to a windoze version of a script that finds stray files, and I tweaked
it to run under unix.  Here it is, in case anybody is interested.  Just
cd to the top of the tree you're interested in and run it.

#! /usr/local/bin/perl
# ------------------------------------------------------------------------
# p4_unmanaged
# ------------------------------------------------------------------------
# List all the files in the current directory and subdirectories that
# are not checked into perforce, and therefore 'unmanaged'
# ------------------------------------------------------------------------

# Generate arrays of files perforce knows about 'havelist'
# and that exist in the filesystem 'locallist'
@havelist  = `p4 have ...`;
$cwd = `/bin/pwd`;
chomp $cwd;
@locallist = `find $cwd -type f -print`;

# Iterate over the havelist and add to a hash
%havehash = ();
for( @havelist )
{
    # $1=p4name $2=version $3=filename
    /(.*)#(\d+) - (.*)/;
    $havehash{$3} = $3;
}

# Loop through the locallist
for( @locallist )
{
    # $1=filename
    if( /(.*)\n/ )
    {
        # if file is not in havelist then print its name
        if( !exists($havehash{$1}) )
        {
            print "$1" . "\n";
        }
    }
}

-- 
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list