#!/usr/bin/perl -w # -*- perl -*- use P4CGI ; use strict ; # ################################################################# # CONFIGURATION INFORMATION # All config info should be in P4CGI.pm # ################################################################# # # Update datafiles for depot tree browser p4dtree # ################################################################# &P4CGI::makedir(P4CGI::DTB_FILEDIR()) ; print "Update data files for dtb \n" ; if(P4CGI::valid_lockfile(P4CGI::DTB_LOCKFILE())) { print "Update already in progress\n" ; exit 0 ; } &P4CGI::create_lockfile(P4CGI::DTB_LOCKFILE()) or die("Can't create lockfile!") ; # Get all files indepot local *P4 ; my %data ; my $filecnt = 0 ; $| = 1 ; print "Read file information..." ; &P4CGI::p4call(*P4,"files //...") ; while(<P4>) { $filecnt++ ; ($filecnt % 1000) == 0 and do { print "." ; } ; chomp ; # Remove leading // s/^\/\/// ; # Remove file part s/\/[^\/]+$// ; my $subdir ="" ; while($_) { unless(defined $data{$_}) { my %tmp ; $data{$_} = \%tmp ; } if($subdir) { last if defined $data{$_}{$subdir} ; $data{$_}{$subdir} = "" ; } ; s/.([^\/]*)$// ; $subdir=$1 ; } } close P4 ; print " $filecnt files\nCreate data files.." ; my $lastsuff = P4CGI::DTB_FILESPLIT() -1 ; my @fileSuffixes = (0..$lastsuff) ; my $fileSuffix ; foreach $fileSuffix (@fileSuffixes) { my $filename = P4CGI::DTB_DATAFILE() . "$fileSuffix.tmp" ; print "." ; open(D,">$filename") or die "Can not open data file for write" ; print D P4CGI::CURRENT_CHANGE_LEVEL() . "\n$filecnt\n" ; my $cnt = 0 ; my $dir ; foreach $dir (sort keys %data) { if((length($dir) % P4CGI::DTB_FILESPLIT()) == $fileSuffix) { print D "$dir" ; foreach (sort keys %{$data{$dir}}) { print D ";$_" ; } print D "\n" ; $cnt++ ; } } print "($cnt)" ; close D ; } print "\nmv files!\n" ; foreach $fileSuffix (@fileSuffixes) { my $filename = P4CGI::DTB_DATAFILE() . "$fileSuffix" ; system("mv $filename.tmp $filename") ; } unlink(P4CGI::DTB_LOCKFILE()) ;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 1985 | Sean Nolan | my initial branch | ||
//guest/perforce_software/utils/p4db/P4DB_0/dtb_update.pl | |||||
#1 | 1885 | rmg |
For posterity: Make the old version appear in a "P4DB_0" subdirectory. (I'd have called it 0.99, but I'm not sure it really *is* 0.99!) |
||
//guest/perforce_software/utils/p4db/dtb_update.pl | |||||
#2 | 12 | Perforce maintenance |
P4DB now browses all depot root paths, not just "//depot/...". (Note: This breaks the "Browse depot tree" function on the main form -- will fix later.) |
||
#1 | 11 | Perforce maintenance | Add Fredric Fredricson's depot browser, P4DB. |