#!/bin/bash # (C) 2004 Thomas Bleher under the GNU GPL v2 # clean up a patch between a cvs tree and an arch tree with taglines # just pipe your patch through this... # # this small script can be used to synchronize an arch-archive with a # cvs repository. assuming the codebase is identical except taglines # Usage: diff -urN arch/ cvs/ | cleanup-patch | patch -d arch/ -p1 # the above line merges all changes from cvs into arch # first filter out all control files filterdiff -x '*/CVS/*' -x '*/.arch-i*' -x '*/{arch}/*' -x '*/,,*' -x '*/++log*' | filterdiff | \ perl -0 -w -ne '# slurp the whole patch in and mangle it for my $file (split(/(?=\n--- )/)) { # split into files for (split(/\n(?=@@ )/m, $file)) { # split into chunks (starting with @@) if (not /^@/) { # the header, just pass it through $data = $_; } else { # the cvs version doesnt have arch-tags; filter them from the diff if (s/\n-\n-(# arch-tag: [-a-z0-9]+)(.*)/$2\n \n $1/s # arch-tag with preceding blank line || s/\n-(# arch-tag: [-a-z0-9]+)(.*)/$2\n+\n $1/s) { # single line arch-tag s/^(@@ -\d+,\d+ \+\d+,)(\d+)( @@\n)/$1.($2 + 2).$3/me; # adjust line count in patch } s/^@@.*?@@(\n[ \\].*)+$//g; # delete hunks that are now empty if (not /^$/) { $data .= "\n".$_; } } } print $data unless ($data =~ /^\n---.*\n\+\+\+.*$/); } ' | \ filterdiff | interdiff -U 3 /dev/null /proc/self/fd/0 | filterdiff # some final cleanup