SOURCES: cvsspam-branch.diff - updated
glen
glen at pld-linux.org
Thu Apr 23 19:12:51 CEST 2009
Author: glen Date: Thu Apr 23 17:12:51 2009 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- updated
---- Files affected:
SOURCES:
cvsspam-branch.diff (1.5 -> 1.6)
---- Diffs:
================================================================
Index: SOURCES/cvsspam-branch.diff
diff -u SOURCES/cvsspam-branch.diff:1.5 SOURCES/cvsspam-branch.diff:1.6
--- SOURCES/cvsspam-branch.diff:1.5 Thu Mar 5 18:32:03 2009
+++ SOURCES/cvsspam-branch.diff Thu Apr 23 19:12:46 2009
@@ -1,7 +1,7 @@
Index: cvsspam.conf
===================================================================
---- cvsspam.conf (.../tags/RELEASE-0_2_12) (revision 269)
-+++ cvsspam.conf (.../trunk) (revision 269)
+--- cvsspam.conf (.../tags/RELEASE-0_2_12) (revision 274)
++++ cvsspam.conf (.../trunk) (revision 274)
@@ -34,11 +34,19 @@
#
# When $jiraURL is given, text of the form 'project-1234' will be linked
@@ -30,7 +30,14 @@
# Additional SMTP Headers (Optional)
-@@ -125,6 +134,15 @@
+@@ -119,12 +128,21 @@
+ # cvsdiff keyword ignoring (Default: show changes in keywords)
+ #
+ # Changes in CVS keywords can be distracting. For instance, the
+-# $Revision$ keyword will change on each commit. Set this value to true
++# $Revision$ keyword will change on each commit. Set this value to true
+ # to exclude changes in keyword fields (adds the -kk option to cvs diff).
+
#$diff_ignore_keywords = true
@@ -98,11 +105,14 @@
___________________________________________________________________
Deleted: svn:executable
- *
+Modified: svn:keywords
+ - Author Date Id Revision
+ + Author Date Id
Index: collect_diffs.rb
===================================================================
---- collect_diffs.rb (.../tags/RELEASE-0_2_12) (revision 269)
-+++ collect_diffs.rb (.../trunk) (revision 269)
+--- collect_diffs.rb (.../tags/RELEASE-0_2_12) (revision 274)
++++ collect_diffs.rb (.../trunk) (revision 274)
@@ -27,6 +27,13 @@
$dirtemplate = "#cvsspam.#{Process.getpgrp}.#{Process.uid}"
@@ -178,8 +188,8 @@
blah("CVSROOT is #{ENV['CVSROOT']}")
Index: record_lastdir.rb
===================================================================
---- record_lastdir.rb (.../tags/RELEASE-0_2_12) (revision 269)
-+++ record_lastdir.rb (.../trunk) (revision 269)
+--- record_lastdir.rb (.../tags/RELEASE-0_2_12) (revision 274)
++++ record_lastdir.rb (.../trunk) (revision 274)
@@ -4,7 +4,6 @@
# http://www.badgers-in-foil.co.uk/projects/cvsspam/
# Copyright (c) David Holroyd
@@ -233,6 +243,428 @@
Index: project.xml
===================================================================
+Index: svn_post_commit_hook.rb
+===================================================================
+--- svn_post_commit_hook.rb (.../tags/RELEASE-0_2_12) (revision 0)
++++ svn_post_commit_hook.rb (.../trunk) (revision 274)
+@@ -0,0 +1,410 @@
++#!/usr/bin/ruby -w
++
++$svnlook_exe = "svnlook" # default assumes the program is in $PATH
++
++def usage(msg)
++ $stderr.puts(msg)
++ exit(1)
++end
++
++def blah(msg)
++ if $debug
++ $stderr.puts "svn_post_commit_hook.rb: #{msg}"
++ end
++end
++
++$debug = false
++$tmpdir = ENV["TMPDIR"] || "/tmp"
++$dirtemplate = "#svnspam.#{Process.getpgrp}.#{Process.uid}"
++# arguments to pass though to 'cvsspam.rb'
++$passthrough_args = []
++
++def make_data_dir
++ dir = "#{$tmpdir}/#{$dirtemplate}-#{rand(99999999)}"
++ Dir.mkdir(dir, 0700)
++ dir
++end
++
++def init
++ $datadir = make_data_dir
++
++ # set PWD so that svnlook can create its .svnlook directory
++ Dir.chdir($datadir)
++end
++
++def cleanup
++ unless $debug
++ File.unlink("#{$datadir}/logfile")
++ Dir.rmdir($datadir)
++ end
++end
++
++def send_email
++ cmd = File.dirname($0) + "/cvsspam.rb"
++ unless system(cmd,"--svn","#{$datadir}/logfile", *$passthrough_args)
++ fail "problem running '#{cmd}'"
++ end
++end
++
++# Like IO.popen, but accepts multiple arguments like Kernel.exec
++# (So no need to escape shell metacharacters)
++def safer_popen(*args)
++ IO.popen("-") do |pipe|
++ if pipe==nil
++ exec(*args)
++ else
++ yield pipe
++ end
++ end
++end
++
++
++# Process the command-line arguments in the given list
++def process_args
++ require 'getoptlong'
++
++ opts = GetoptLong.new(
++ [ "--to", "-t", GetoptLong::REQUIRED_ARGUMENT ],
++ [ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
++ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
++ [ "--from", "-u", GetoptLong::REQUIRED_ARGUMENT ],
++ [ "--charset", GetoptLong::REQUIRED_ARGUMENT ]
++ )
++
++ opts.each do |opt, arg|
++ if ["--to", "--config", "--from", "--charset"].include?(opt)
++ $passthrough_args << opt << arg
++ end
++ if ["--debug"].include?(opt)
++ $passthrough_args << opt
++ end
++ $config = arg if opt=="--config"
++ $debug = true if opt == "--debug"
++ end
++
++ $repository = ARGV[0]
++ $revision = ARGV[1]
++
++ unless $revision =~ /^\d+$/
++ usage("revision must be an integer: #{revision.inspect}")
++ end
++ $revision = $revision.to_i
++
++ unless FileTest.directory?($repository)
++ usage("no such directory: #{$repository.inspect}")
++ end
++end
++
++# runs the given svnlook subcommand
++def svnlook(cmd, revision, *args)
++ rev = revision.to_s
++ safer_popen($svnlook_exe, cmd, $repository, "-r", rev, *args) do |io|
++ yield io
++ end
++end
++
++class Change
++ def initialize(filechange, propchange, path)
++ @filechange = filechange
++ @propchange = propchange
++ @path = path
++ end
++
++ attr_accessor :filechange, :propchange, :path
++
++ def property_change?
++ @propchange != " "
++ end
++
++ def file_change?
++ @filechange != "_"
++ end
++
++ def addition?
++ @filechange == "A"
++ end
++
++ def deletion?
++ @filechange == "D"
++ end
++end
++
++
++
++# Line-oriented access to an underlying IO object. Remembers 'current' line
++# for lookahead during parsing.
++class LineReader
++ def initialize(io)
++ @io = io
++ end
++
++ def current
++ @line
++ end
++
++ def next_line
++ (@line = @io.gets) != nil
++ end
++
++ def assert_current(re)
++ raise "unexpected #{current.inspect}" unless @line =~ re
++ $~
++ end
++
++ def assert_next(re=nil)
++ raise "unexpected end of text" unless next_line
++ unless re.nil?
++ raise "unexpected #{current.inspect}" unless @line =~ re
++ end
++ $~
++ end
++end
++
++
++def read_modified_diff(out, lines, path)
++ lines.assert_next(/^=+$/)
++ lines.assert_next
++ if lines.current =~ /\(Binary files differ\)/
++ process_modified_binary_diff(out, lines, path)
++ else
++ process_modified_text_diff(out, lines, path)
++ end
++end
++
++
++def process_modified_binary_diff(out, lines, path)
++ prev_rev= $revision-1
++ next_rev= $revision
++ out.puts "#V #{prev_rev},#{next_rev}"
++ out.puts "#M #{path}"
++ out.puts "#U diff x x"
++ out.puts "#U Binary files x and y differ"
++end
++
++
++def process_modified_text_diff(out, lines, path)
++ m = lines.assert_current(/^---.*\(rev (\d+)\)$/)
++ prev_rev = m[1].to_i
++ diff1 = lines.current
++ m = lines.assert_next(/^\+\+\+.*\(rev (\d+)\)$/)
++ next_rev = m[1].to_i
++ diff2 = lines.current
++ out.puts "#V #{prev_rev},#{next_rev}"
++ out.puts "#M #{path}"
++ out.puts "#U #{diff1}"
++ out.puts "#U #{diff2}"
++ while lines.next_line && lines.current =~ /^[-\+ @\\]/
++ out.puts "#U #{lines.current}"
++ end
++end
++
++def read_added_diff(out, lines, path)
++ lines.assert_next(/^=+$/)
++ lines.assert_next
++ if lines.current =~ /\(Binary files differ\)/
++ process_added_binary_diff(out, lines, path)
++ else
++ process_added_text_diff(out, lines, path)
++ end
++end
++
++def process_added_binary_diff(out, lines, path)
++ next_rev= $revision
++ out.puts "#V NONE,#{next_rev}"
++ out.puts "#A #{path}"
++ out.puts "#U diff x x"
++ out.puts "#U Binary file x added"
++end
++
++def process_added_text_diff(out, lines, path)
++ m = lines.assert_current(/^---.*\(rev (\d+)\)$/)
++ prev_rev = m[1].to_i
++ diff1 = lines.current
++ m = lines.assert_next(/^\+\+\+.*\(rev (\d+)\)$/)
++ next_rev = m[1].to_i
++ diff2 = lines.current
++ out.puts "#V NONE,#{next_rev}"
++ out.puts "#A #{path}"
++ out.puts "#U #{diff1}"
++ out.puts "#U #{diff2}"
++ while lines.next_line && lines.current =~ /^[-\+ @\\]/
++ out.puts "#U #{lines.current}"
++ end
++end
++
++def read_deleted_diff(out, lines, path)
++ lines.assert_next(/^=+$/)
++ m = lines.assert_next(/^---.*\(rev (\d+)\)$/)
++ prev_rev = m[1].to_i
++ diff1 = lines.current
++ m = lines.assert_next(/^\+\+\+.*\(rev (\d+)\)$/)
++ next_rev = m[1].to_i
++ diff2 = lines.current
++ out.puts "#V #{prev_rev},NONE"
++ out.puts "#R #{path}"
++ out.puts "#U #{diff1}"
++ out.puts "#U #{diff2}"
++ while lines.next_line && lines.current =~ /^[-\+ @\\]/
++ out.puts "#U #{lines.current}"
++ end
++end
++
++def read_property_lines(path, prop_name, revision)
++ lines = []
++ svnlook("propget", revision, prop_name, path) do |io|
++ io.each_line do |line|
++ lines << line.chomp
++ end
++ end
++ lines
++end
++
++def assert_prop_match(a, b)
++ if !b.nil? && a != b
++ raise "property mismatch: #{a.inspect}!=#{b.inspect}"
++ end
++end
++
++# We need to read the property change from the output of svnlook, but have
++# a difficulty in that there's no unambiguous delimiter marking the end of
++# a potentially multi-line property value. Therefore, we do a seperate
++# svn propget on the given file to get the value of the property on its own,
++# and then use that value as a guide as to how much data to read from the
++# svnlook output.
++def munch_prop_text(path, prop_name, revision, lines, line0)
++ prop = read_property_lines(path, prop_name, revision)
++ if prop.empty?
++ assert_prop_match(line0, "")
++ return
++ end
++ assert_prop_match(line0, prop.shift)
++ prop.each do |prop_line|
++ lines.assert_next
++ assert_prop_match(lines.current.chomp, prop_line)
++ end
++end
++
++def read_properties_changed(out, lines, path)
++ prev_rev= $revision-1
++ next_rev= $revision
++ lines.assert_next(/^_+$/)
++ return unless lines.next_line
++ out.puts "#V #{prev_rev},#{next_rev}"
++ out.puts "#P #{path}"
++# The first three get consumed and not highlighted
++ out.puts "#U "
++ out.puts "#U Property changes:"
++ out.puts "#U "
++
++ while true
++ break unless lines.current =~ /^(?:Name|Added|Deleted): (.+)$/
++
++ prop_name = $1
++ m = lines.assert_next(/^ ([-+]) (.*)/)
++ op = m[1]
++ line0 = m[2]
++ if op == "-"
++ munch_prop_text(path, prop_name, $revision-1, lines, line0)
++ if lines.next_line && lines.current =~ /^ \+ (.*)/
++ munch_prop_text(path, prop_name, $revision, lines, $1)
++ lines.next_line
++ end
++ else # op == "+"
++ munch_prop_text(path, prop_name, $revision, lines, line0)
++ lines.next_line
++ end
++ out.puts "#U #{m[1]} #{prop_name}:#{m[2]}"
++ end
++ out.puts "#U "
++end
++
++def handle_copy(out, lines, path, from_ref, from_file)
++ prev_rev= $revision-1
++ next_rev= $revision
++ out.puts "#V #{from_file}:#{prev_rev},#{next_rev}"
++ out.puts "#C #{path}"
++ if lines.next_line && lines.current =~ /^=+$/
++ m = lines.assert_next(/^---.*\(rev (\d+)\)$/)
++ prev_rev = m[1].to_i
++ diff1 = lines.current
++ m = lines.assert_next(/^\+\+\+.*\(rev (\d+)\)$/)
++ next_rev = m[1].to_i
++ diff2 = lines.current
++ out.puts "#U #{diff1}"
++ out.puts "#U #{diff2}"
++ while lines.next_line && lines.current =~ /^[-\+ @\\]/
++ out.puts "#U #{lines.current}"
++ end
++ else
++ out.puts "#U "
++ out.puts "#U Copied from #{from_file}:#{from_ref}"
++ out.puts "#U "
++ end
++end
++
++def svnlook_author
++ svnlook("author", $revision) do |io|
++ return io.readline.chomp
++ end
++ nil
++end
++
++def find_author
++ return if $passthrough_args.include?("--from")
++ author = svnlook_author
++ if author
++ blah("Author from svnlook: '#{author}'")
++ $passthrough_args << "--from" << author
++ end
++end
++
++def process_svnlook_log(file)
++ svnlook("log", $revision) do |io|
++ io.each_line do |line|
++ file.puts("#> #{line}")
++ end
++ end
++end
++
++def process_svnlook_diff(file)
++ svnlook("diff", $revision) do |io|
++ lines = LineReader.new(io)
++ while lines.next_line
++ if lines.current =~ /^Modified:\s+(.*)/
++ read_modified_diff(file, lines, $1)
++ elsif lines.current =~ /^Added:\s+(.*)/
++ read_added_diff(file, lines, $1)
++ elsif lines.current =~ /^Copied:\s+(.*) \(from rev (\d+), (.*)\)$/
++ handle_copy(file, lines, $1, $2, $3)
++ elsif lines.current =~ /^Deleted:\s+(.*)/
++ read_deleted_diff(file, lines, $1)
++ elsif lines.current =~ /^Property changes on:\s+(.*)/
++ read_properties_changed(file, lines, $1)
++ elsif lines.current == "\n"
++ # ignore
++ else
++ raise "unable to parse line '#{lines.current.inspect}'"
++ end
++ end
++ end
++end
++
++def process_commit()
++ File.open("#{$datadir}/logfile", File::WRONLY|File::CREAT) do |file|
++ process_svnlook_log(file)
++ process_svnlook_diff(file)
++ end
++end
++
++
++def main
++ init()
++ process_args()
++ find_author()
++ process_commit()
++ send_email()
++ cleanup()
++end
++
++
++main
+
+Property changes on: svn_post_commit_hook.rb
+___________________________________________________________________
+Added: svn:mergeinfo
+Added: svn:executable
+ + *
+
Property changes on: COPYING
___________________________________________________________________
@@ -241,8 +673,8 @@
Index: CREDITS
===================================================================
---- CREDITS (.../tags/RELEASE-0_2_12) (revision 269)
-+++ CREDITS (.../trunk) (revision 269)
+--- CREDITS (.../tags/RELEASE-0_2_12) (revision 274)
++++ CREDITS (.../trunk) (revision 274)
@@ -29,3 +29,10 @@
Elan Ruusamäe
Steve Fox
@@ -256,8 +688,8 @@
+ Charles Duffy
Index: cvsspam-doc.xml
===================================================================
---- cvsspam-doc.xml (.../tags/RELEASE-0_2_12) (revision 269)
-+++ cvsspam-doc.xml (.../trunk) (revision 269)
+--- cvsspam-doc.xml (.../tags/RELEASE-0_2_12) (revision 274)
++++ cvsspam-doc.xml (.../trunk) (revision 274)
@@ -452,6 +452,23 @@
</screen></informalexample>
</para>
@@ -290,8 +722,8 @@
Index: cvsspam.rb
===================================================================
---- cvsspam.rb (.../tags/RELEASE-0_2_12) (revision 269)
-+++ cvsspam.rb (.../trunk) (revision 269)
+--- cvsspam.rb (.../tags/RELEASE-0_2_12) (revision 274)
++++ cvsspam.rb (.../trunk) (revision 274)
@@ -20,6 +20,7 @@
$version = "0.2.12"
@@ -360,7 +792,46 @@
@lineAdditions = @lineRemovals = 0
@repository = Repository.get(path)
@repository.merge_common_prefix(basedir())
-@@ -533,6 +534,14 @@
+@@ -397,7 +398,7 @@
+
+ # the full path and filename within the repository
+ attr_accessor :path
+- # the type of change committed 'M'=modified, 'A'=added, 'R'=removed
++ # the type of change committed 'M'=modified, 'A'=added, 'R'=removed, 'P'=properties, 'C'=copied
+ attr_accessor :type
+ # records number of 'addition' lines in diff output, once counted
+ attr_accessor :lineAdditions
+@@ -452,17 +453,28 @@
+ def removal?
+ @type == "R"
+ end
+-
++
+ # was this file added during the commit?
+ def addition?
+ @type == "A"
+ end
+
++ # was this file copied during the commit?
++ def copied?
++ @type == "C"
++ end
++
+ # was this file simply modified during the commit?
+ def modification?
+ @type == "M"
+ end
++
++ # was this file simply modified during the commit?
++ def modifiedprops?
++ @type == "P"
++ end
+
++
+ # passing true, this object remembers that a diff will appear in the email,
+ # passing false, this object remembers that no diff will appear in the email.
+ # Once the value is set, it will not be changed
+@@ -533,6 +545,14 @@
# TODO: consolidate these into a nicer framework,
mailSub = proc { |match| "<a href=\"mailto:#{match}\">#{match}</a>" }
urlSub = proc { |match| "<a href=\"#{match}\">#{match}</a>" }
@@ -375,7 +846,7 @@
bugzillaSub = proc { |match|
match =~ /([0-9]+)/
"<a href=\"#{$bugzillaURL.sub(/%s/, $1)}\">#{match}</a>"
-@@ -544,11 +553,27 @@
+@@ -544,11 +564,27 @@
match =~ /([0-9]+)/
"<a href=\"#{$ticketURL.sub(/%s/, $1)}\">#{match}</a>"
}
@@ -404,7 +875,7 @@
commentSubstitutions = {
'(?:mailto:)?[\w\.\-\+\=]+\@[\w\-]+(?:\.[\w\-]+)+\b' => mailSub,
'\b(?:http|https|ftp):[^ \t\n<>"]+[\w/]' => urlSub
-@@ -670,6 +695,12 @@
+@@ -670,6 +706,12 @@
def diff(file)
'->'
end
@@ -417,7 +888,7 @@
end
# Superclass for objects that can link to CVS frontends on the web (ViewCVS,
-@@ -710,6 +741,14 @@
+@@ -710,6 +752,14 @@
"<a href=\"#{diff_url(file)}\">#{super(file)}</a>"
end
@@ -432,7 +903,7 @@
<<Diff was trimmed, longer than 597 lines>>
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/cvsspam-branch.diff?r1=1.5&r2=1.6&f=u
More information about the pld-cvs-commit
mailing list