#!/usr/bin/env ruby
-file, rev, author, lines, state = nil, nil, nil, nil, :F
mia_authors = ARGV
IO.popen('cvs log') do |io|
- io.each_line do |line|
- line.chomp!
- case line
- when /\A-+\z/
- state = :R
- if rev && author && File.basename(file) != 'ChangeLog' &&
- mia_authors.include?(author)
- prev_rev = rev.sub(/\d+\z/) {|s| (s.to_i - 1).to_s}
- puts("cvs diff -u -r #{prev_rev} -r #{rev} #{File.basename(file)}\t# #{lines}")
- end
+ io.read.split(/^=+\n/).each do |per_file|
+ file = nil
+ per_file.scan(/^RCS file:\s+(.+),v$/) do |match|
+ file = match[0]
+ break
+ end
+ break unless file
+ base = File.basename(file)
+ next if base =~ /\A(ChangeLog|\.cvsignore)\z/
+ per_file.split(/^-+\n/).each do |per_rev|
rev, author, lines = nil, nil, nil
- when /\A=+\z/
- state = :F
- file, rev, author, lines = nil, nil, nil, nil
- when /\ARCS file:\s+(.+),v\z/
- file = $1 if state == :F
- when /\Arevision\s+([0-9.]+)\z/
- rev = $1 if state == :R
- when /\Adate:\s+(?:.+?);\s+author:\s+(.+?);\s+state:\s+(?:.+?);\s+lines:\s+(.+)/
- if state == :R
- author = $1
- lines = $2
+ per_rev.scan(/^revision\s+([0-9.]+)
+date:\s+(?:.+?);\s+\
+author:\s+(.+?);\s+\
+state:\s+(?:.+?);\s+\
+lines:\s+(.+)$/) do |match|
+ rev, author, lines = match
+ if mia_authors.include?(author)
+ prev_rev = rev.sub(/\d+\z/) {|s| (s.to_i - 1).to_s}
+ puts("cvs diff -u -r #{prev_rev} -r #{rev} #{base}\t# #{lines}")
+ end
+ break
end
end
end