Mon Jan 28 04:30:15 2013 UTC ()
Apply the latest bugfixes to the CVS backend from my git repo:

* `6753235d`: Return bounded output from `rcs_diff()` when asked, as
  the API states.
* `e45175d5`: Always explicitly set CVS keyword substitution behavior.
  Fixes behavior when a text file is added under a name formerly
  used for a binary file.
* `b30cacdf`: If the previous working directory no longer exists after
  a CVS operation, don't try to `chdir()` back to it afterward.

Bump PKGREVISION.


(schmonz)
diff -r1.102 -r1.103 pkgsrc/www/ikiwiki/Makefile
diff -r1.84 -r1.85 pkgsrc/www/ikiwiki/distinfo
diff -r0 -r1.1 pkgsrc/www/ikiwiki/patches/patch-IkiWiki_Plugin_cvs.pm

cvs diff -r1.102 -r1.103 pkgsrc/www/ikiwiki/Makefile (expand / switch to unified diff)

--- pkgsrc/www/ikiwiki/Makefile 2013/01/15 23:10:57 1.102
+++ pkgsrc/www/ikiwiki/Makefile 2013/01/28 04:30:14 1.103
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1# $NetBSD: Makefile,v 1.102 2013/01/15 23:10:57 schmonz Exp $ 1# $NetBSD: Makefile,v 1.103 2013/01/28 04:30:14 schmonz Exp $
2# 2#
3 3
4DISTNAME= ikiwiki_3.20121212 4DISTNAME= ikiwiki_3.20121212
5PKGNAME= ${DISTNAME:S/_/-/} 5PKGNAME= ${DISTNAME:S/_/-/}
6PKGREVISION= 1 6PKGREVISION= 2
7CATEGORIES= www textproc 7CATEGORIES= www textproc
8MASTER_SITES= ${MASTER_SITE_DEBIAN:=pool/main/i/ikiwiki/} 8MASTER_SITES= ${MASTER_SITE_DEBIAN:=pool/main/i/ikiwiki/}
9 9
10MAINTAINER= schmonz@NetBSD.org 10MAINTAINER= schmonz@NetBSD.org
11HOMEPAGE= http://ikiwiki.info/ 11HOMEPAGE= http://ikiwiki.info/
12COMMENT= Wiki compiler 12COMMENT= Wiki compiler
13LICENSE= gnu-gpl-v2 13LICENSE= gnu-gpl-v2
14 14
15DEPENDS+= p5-Text-Markdown-Discount-[0-9]*:../../textproc/p5-Text-Markdown-Discount 15DEPENDS+= p5-Text-Markdown-Discount-[0-9]*:../../textproc/p5-Text-Markdown-Discount
16DEPENDS+= p5-URI-[0-9]*:../../www/p5-URI 16DEPENDS+= p5-URI-[0-9]*:../../www/p5-URI
17DEPENDS+= p5-HTML-Parser-[0-9]*:../../www/p5-HTML-Parser 17DEPENDS+= p5-HTML-Parser-[0-9]*:../../www/p5-HTML-Parser
18DEPENDS+= p5-HTML-Template-[0-9]*:../../www/p5-HTML-Template 18DEPENDS+= p5-HTML-Template-[0-9]*:../../www/p5-HTML-Template
19DEPENDS+= p5-HTML-Tree-[0-9]*:../../www/p5-HTML-Tree 19DEPENDS+= p5-HTML-Tree-[0-9]*:../../www/p5-HTML-Tree

cvs diff -r1.84 -r1.85 pkgsrc/www/ikiwiki/distinfo (expand / switch to unified diff)

--- pkgsrc/www/ikiwiki/distinfo 2013/01/15 23:10:57 1.84
+++ pkgsrc/www/ikiwiki/distinfo 2013/01/28 04:30:14 1.85
@@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
1$NetBSD: distinfo,v 1.84 2013/01/15 23:10:57 schmonz Exp $ 1$NetBSD: distinfo,v 1.85 2013/01/28 04:30:14 schmonz Exp $
2 2
3SHA1 (ikiwiki_3.20121212.tar.gz) = 1c9815502e90a25c5bd7b5cdf198034e6833c3ff 3SHA1 (ikiwiki_3.20121212.tar.gz) = 1c9815502e90a25c5bd7b5cdf198034e6833c3ff
4RMD160 (ikiwiki_3.20121212.tar.gz) = a5439279166dc0d6ed1f4f5f7a71a680b08465cc 4RMD160 (ikiwiki_3.20121212.tar.gz) = a5439279166dc0d6ed1f4f5f7a71a680b08465cc
5Size (ikiwiki_3.20121212.tar.gz) = 2917372 bytes 5Size (ikiwiki_3.20121212.tar.gz) = 2917372 bytes
 6SHA1 (patch-IkiWiki_Plugin_cvs.pm) = affca7fbdbd08c7b56faaf1583ad36ddba6a89f2
6SHA1 (patch-IkiWiki_Plugin_git.pm) = e854ea61afd3968a9dd06f1c70ab2cea993d6a1f 7SHA1 (patch-IkiWiki_Plugin_git.pm) = e854ea61afd3968a9dd06f1c70ab2cea993d6a1f

File Added: pkgsrc/www/ikiwiki/patches/Attic/patch-IkiWiki_Plugin_cvs.pm
$NetBSD: patch-IkiWiki_Plugin_cvs.pm,v 1.1 2013/01/28 04:30:15 schmonz Exp $

Bugfixes in `schmonz/cvs` I'd like to see merged:

* `6753235d`: Return bounded output from `rcs_diff()` when asked, as
  the API states.
* `e45175d5`: Always explicitly set CVS keyword substitution behavior.
  Fixes behavior when a text file is added under a name formerly
  used for a binary file.
* `b30cacdf`: If the previous working directory no longer exists after
  a CVS operation, don't try to `chdir()` back to it afterward.

--- IkiWiki/Plugin/cvs.pm.orig	2012-08-25 15:12:13.000000000 +0000
+++ IkiWiki/Plugin/cvs.pm
@@ -216,14 +216,12 @@ sub rcs_add ($) {
 
 	while ($file = pop @files_to_add) {
 		if (@files_to_add == 0) {
-			# file
 			cvs_runcvs('add', cvs_keyword_subst_args($file)) ||
-				warn("cvs add $file failed\n");
+				warn("cvs add file $file failed\n");
 		}
 		else {
-			# directory
 			cvs_runcvs('add', $file) ||
-				warn("cvs add $file failed\n");
+				warn("cvs add dir $file failed\n");
 		}
 	}
 }
@@ -396,11 +394,15 @@ sub rcs_diff ($;$) {
 	my @cvsps = `env TZ=UTC cvsps -q --cvs-direct -z 30 -g -s $rev`;
 	my $blank_lines_seen = 0;
 
+	# skip log, get to the diff
 	while (my $line = shift @cvsps) {
 		$blank_lines_seen++ if ($line =~ /^$/);
 		last if $blank_lines_seen == 2;
 	}
 
+	@cvsps = @cvsps[0..$maxlines-1]
+		if defined $maxlines && @cvsps > $maxlines;
+
 	if (wantarray) {
 		return @cvsps;
 	}
@@ -491,24 +493,53 @@ sub cvs_keyword_subst_args ($) {
 	my $filemime = File::MimeInfo::default($file);
 	# if (-T $file) {
 
-	if (defined($filemime) && $filemime eq 'text/plain') {
-		return ($file);
-	}
-	else {
-		return ('-kb', $file);
-	}
+	defined($filemime) && $filemime eq 'text/plain'
+		? return ('-kkv', $file)
+		: return ('-kb', $file);
 }
 
 sub cvs_runcvs(@) {
 	my @cmd = @_;
 	unshift @cmd, 'cvs', '-Q';
 
-	local $CWD = $config{srcdir};
+	# CVS can't operate outside a srcdir, so we're always setting $CWD.
+	# "local $CWD" restores the previous value when we go out of scope.
+	# Usually that's correct. But if we're removing the last file from
+	# a directory, the post-commit hook will exec in a working directory
+	# that's about to not exist (CVS will prune it).
+	#
+	# chdir() manually here, so we can selectively not chdir() back.
+
+	my $oldcwd = $CWD;
+	chdir($config{srcdir});
+
+	eval q{
+		use IPC::Open3;
+		use Symbol qw(gensym);
+		use IO::File;
+	};
+	error($@) if $@;
+
+	my $cvsout = '';
+	my $cvserr = '';
+	local *CATCHERR = IO::File->new_tmpfile;
+	my $pid = open3(gensym(), \*CATCHOUT, ">&CATCHERR", @cmd);
+	while (my $l = <CATCHOUT>) {
+		$cvsout .= $l
+			unless 1;
+	}
+	waitpid($pid, 0);
+	my $ret = $? >> 8;
+	seek CATCHERR, 0, 0;
+	while (my $l = <CATCHERR>) {
+		$cvserr .= $l
+			unless $l =~ /^cvs commit: changing keyword expansion /;
+	}
+
+	print STDOUT $cvsout;
+	print STDERR $cvserr;
 
-	open(my $savedout, ">&STDOUT");
-	open(STDOUT, ">", "/dev/null");
-	my $ret = system(@cmd);
-	open(STDOUT, ">&", $savedout);
+	chdir($oldcwd) if -d $oldcwd;
 
 	return ($ret == 0) ? 1 : 0;
 }