Hi folks,

I have written a simple perl subroutine which you can use to see who is 
editing which files without having to do a checkout.

Feel free to use it if you think it is useful for you.

Regards

Colm A

#-------------------------------------------------------------------------------
# Builds a list of who is editing what files.
# Paramaters:
# $_[0]: path to CVSROOT
# $_[1]: set if you want full paths to files.
#-------------------------------------------------------------------------------
sub build_editors {

    my $cvsroot = $_[0];
    my %editors;
    my @filelist = `find $cvsroot -name "fileattr"`;
    chomp @filelist;

    foreach my $filename (@filelist)
    {
       # $dirpath is the path to the directory in the repository.
       $dirpath = $filename;
       $dirpath =~ s/$cvsroot\///;
       $dirpath =~ s/CVS\/fileattr//;

       open (FILE, $filename) or die "Cannot open $filename: $!";
       while (defined(my $line = <FILE>))
       {
          (my $file, my $rest) = split (/\t/,$line);

          # Remove the leading F in the filename.
          # This indicates to CVS that the watched object is a file.
          $file =~ s/^F//;

          # We now add back in the path to the file in the repository.
          $file = $dirpath.$file if ($_[1]);

          my @attrlist = split (/;/,$rest);
          foreach my $attr (@attrlist)
          {
             if ($attr =~ /^_watched/)
             {
    #            print "$file is watched\n";
             }
             elsif ($attr =~ /^_watchers/)
             {
                my $watcherstring = $attr;
                $watcherstring =~ s/_watchers=//;
                my @watcherlist = split (/,/,$watcherstring);
                foreach my $watcher (@watcherlist)
                {
                   (my $watchername, my $editordetails) = split 
(/>/,$watcher);
    #               print "Watcher:$watchername\n";
    #               print "Details:$editordetails\n";
                }
             }
             elsif ($attr =~ /^_editors/)
             {
                my $editorstring = $attr;
                $editorstring =~ s/_editors=//;
                $editors{$file} = $editorstring;

#               @editorlist = split (/,/,$editorstring);
#               foreach $editor (@editorlist)
#               {
#                  ($editorname, $editordetails) = split (/>/,$editor);
#                  print "Editor:$editorname\n";
#                  print "Details:$editordetails\n";
#               }
             }
          }
       }
       close (FILE) or die "Cannot close $filename: $!";
    }
#   foreach $file (sort keys %editors)
#   {
#      print "FILE:$file\n";
#      print "ATTR:$editors{$file}\n";
#   }

return %editors;
}
#-------------------------------------------------------------------------------

_______________________________________________
Info-cvs mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/info-cvs

Reply via email to