From 0b6b585a31f76dca698e2a5d7ebd16abaa9a64b1 Mon Sep 17 00:00:00 2001 From: Josef Karthauser Date: Mon, 1 Apr 2002 16:17:12 +0000 Subject: [PATCH] Take an option flag to specify that we'd like a patch generated too. --- tools/tools/commitsdb/query_commit_db | 32 +++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tools/tools/commitsdb/query_commit_db b/tools/tools/commitsdb/query_commit_db index f753f327b898..003d45fef47a 100644 --- a/tools/tools/commitsdb/query_commit_db +++ b/tools/tools/commitsdb/query_commit_db @@ -13,7 +13,8 @@ use Digest::MD5 qw(md5_hex); my $dbname = "commitsdb"; # Take the filename and revision number from the command line. -my ($file, $revision) = (shift, shift); +# Also take a flag to say whether to generate a patch or not. +my ($file, $revision, $genpatch) = (shift, shift, shift); # Find the checksum of the named revision. my %possible_files; @@ -56,6 +57,33 @@ while () { } close DB; -print map { "$_\n" } sort @results; +foreach my $r (sort @results) { + print "$r\n"; + next unless $genpatch; + + my ($name, $rev) = split /\s/, $r, 2; + my $prevrev = previous_revision($rev); + print `cvs diff -u -r$prevrev -r$rev $name`; + print "\n\n"; +} + +# +# Return the previous revision number. +# +sub previous_revision { + my $rev = shift; + + $rev =~ /(?:(.*)\.)?([^\.]+)\.([^\.]+)$/; + my ($base, $r1, $r2) = ($1, $2, $3); + + my $prevrev = ""; + if ($r2 == 1) { + $prevrev = $base; + } else { + $prevrev = "$base." if $base; + $prevrev .= "$r1." . ($r2 - 1); + } + return $prevrev; +} #end