From: Akinori MUSHA Date: 2001-01-16T01:46:18+09:00 Subject: [ruby-talk:9339] Re: cvs commit log mailing list At Mon, 15 Jan 2001 18:10:03 +0900, Shugo Maeda wrote: > ruby-cvs@ruby-lang.org is set up to distribute cvs commit logs. I prepared a ruby script named "cm2diff" as attached, which reads a commit mail and show diffs. It would be useful to use in a procmail recipe, or from within a mail agent to get diffs on the fly. > subscribe Your-Last-Name Your-First-Name > e.g. > subscribe Shugo Maeda Which is the first name for a Japanese, family or given? Confusing. ;) (I first sent a mail with my name GIVEN FAMILY, but later I reconsidered and sent another with FAMILY GIVEN) -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "We're only at home when we're on the run, on the wing, on the fly" #!/usr/bin/env ruby # # Placed into the public domain by M. Warner Losh. 1997. Enjoy. # Rewrote to be ruby by Brian Feldman. 2000. Enjoy more :) # Modified by Akinori MUSHA 2000. Well, Ruby rules :) # # > 1.94 +72 -34 src/sys/i386/scsi/aic7xxx.c # # Turns into a lot of diffs # # $Idaemons: /home/cvs/cm2diff/cm2diff,v 1.3 2001/01/15 07:51:05 knu Exp $ # def do_diff(root, file, rev, args) /^(.*\.)(\d+)$/ =~ rev or return revold = $1 last = $2.to_i next if /^(?:1\.1\.)*1\.1$/ =~ rev if last == 1 && rev.split('.').length & 1 == 0 # a branch, EVILNESS revold.sub! /\.(\d+)\.$/, '' else revold += (last - 1).to_s end cmd = nil if /:/ =~ root cmd = "cvs -d #{root} rdiff #{args.join ' '} -r#{revold} -r#{rev} #{file}" else cmd = "rcsdiff -u #{args.join ' '} -r#{revold} -r#{rev} #{root}/#{file},v" end if cmd puts cmd system cmd end end def main(args) root = '' STDIN.each_line do |line| case line when /^X-Ruby-CVS-Root: *(\S+)/ root = ':pserver:anonymous@cvs.ruby-lang.org:' + $1 #root = '/home/cvs/ruby' + $1 when /^X-FreeBSD-CVS-Branch:/ root = ':pserver:anoncvs@anoncvs.FreeBSD.org:/home/ncvs' #root = '/home/ncvs' when /^ *((?:\d+\.)+\d+) +\+\d+ +-\d+ +(\S+)/ do_diff(root, $2, $1, args) end end end if $0 == __FILE__ main ARGV end