config root man

Current Path : /usr/src/tools/tools/commitsdb/

FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64
Upload File :
Current File : //usr/src/tools/tools/commitsdb/make_commit_db

#!/usr/bin/perl -w

# $FreeBSD: release/9.1.0/tools/tools/commitsdb/make_commit_db 105334 2002-10-17 16:29:26Z joe $

# This script walks the tree from the current directory
# and spits out a database generated by md5'ing the cvs log
# messages of each revision of every file in the tree.

use strict;
use Digest::MD5 qw(md5_hex);

my $dbname = "commitsdb";
open DB, "> $dbname" or die "$!\n";

# Extract all the logs for the current directory.
my @dirs = ".";
while (@dirs) {
	my $dir = shift @dirs;
	my %logs;

	opendir DIR, $dir or die $!;
	foreach my $f (grep { /[^\.]/ } readdir DIR) {
		my $filename = "$dir/$f";
		if (-f $filename) {
			my %loghash = parse_log_message($filename);
			next unless %loghash;

			$logs{$filename} = {%loghash};
		} elsif (-d $filename) {
			next if $filename =~ /\/CVS$/;
			push @dirs, $filename;
		}
	}
	close DIR;

	# Produce a database of the commits
	foreach my $f (keys %logs) {
		my $file = $logs{$f};
		foreach my $rev (keys %$file) {
			my $hash = $$file{$rev};

			print DB "$f $rev $hash\n";
		}
	}

	print "\r" . " " x 30 . "\r$dir";
}
print "\n";

close DB;



##################################################
# Run a cvs log on a file and return a parse entry.
##################################################
sub parse_log_message {
	my $file = shift;

	# Get a log of the file.
	open LOG, "cvs -R log $file 2>/dev/null |" or die $!;
	my @log = <LOG>;
	my $log = join "", @log;
	close LOG;

	# Split the log into revisions.
	my @entries = split /----------------------------\n/, $log;

	# Throw away the first entry.
	shift @entries;

	# Record the hash of the message against the revision.
	my %loghash = ();
	foreach my $e (@entries) {
		# Get the revision number
		$e =~ s/^revision\s*(\S*)\n//s;
		my $rev = $1;

		# Strip off any other headers.
		my $user;
		while ($e =~ s/^(date|branches):([^\n]*)\n//sg) {
			my $sub = $2;
			$user = $1 if $sub =~ /author: (.*?);/;
		};

		my $hash = string_to_hash($e);
		$loghash{$rev} = "$user:$hash";
	}

	return %loghash;
}


##################################################
# Convert a log message into an md5 checksum.
##################################################
sub string_to_hash {
	my $logmsg = shift;

	return md5_hex($logmsg);
}



#end

Man Man