.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "PatchReader 3" .TH PatchReader 3 "2020-07-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" PatchReader \- Utilities to read and manipulate patches and CVS .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& # Script that reads in a patch (in any known format), and prints \& # out some information about it. Other common operations are \& # outputting the patch in a raw unified diff format, outputting \& # the patch information to Template::Toolkit templates, adding \& # context to a patch from CVS, and narrowing the patch down to \& # apply only to a single file or set of files. \& \& use PatchReader::Raw; \& use PatchReader::PatchInfoGrabber; \& my $filename = \*(Aqfilename.patch\*(Aq; \& \& # Create the reader that parses the patch and the object that \& # extracts info from the reader\*(Aqs datastream \& my $reader = new PatchReader::Raw(); \& my $patch_info_grabber = new PatchReader::PatchInfoGrabber(); \& $reader\->sends_data_to($patch_info_grabber); \& \& # Iterate over the file \& $reader\->iterate_file($filename); \& \& # Print the output \& my $patch_info = $patch_info_grabber\->patch_info(); \& print "Summary of Changed Files:\en"; \& while (my ($file, $info) = each %{$patch_info\->{files}}) { \& print "$file: +$info\->{plus_lines} \-$info\->{minus_lines}\en"; \& } .Ve .SH "ABSTRACT" .IX Header "ABSTRACT" This perl library allows you to manipulate patches programmatically by chaining together a variety of objects that read, manipulate, and output patch information: .IP "PatchReader::Raw" 4 .IX Item "PatchReader::Raw" Parse a patch in any format known to this author (unified, normal, cvs diff, among others) .IP "PatchReader::PatchInfoGrabber" 4 .IX Item "PatchReader::PatchInfoGrabber" Grab summary info for sections of a patch in a nice hash .IP "PatchReader::AddCVSContext" 4 .IX Item "PatchReader::AddCVSContext" Add context to the patch by grabbing the original files from \s-1CVS\s0 .IP "PatchReader::NarrowPatch" 4 .IX Item "PatchReader::NarrowPatch" Narrow a patch down to only apply to a specific set of files .IP "PatchReader::DiffPrinter::raw" 4 .IX Item "PatchReader::DiffPrinter::raw" Output the parsed patch in raw unified diff format .IP "PatchReader::DiffPrinter::template" 4 .IX Item "PatchReader::DiffPrinter::template" Output the parsed patch to Template::Toolkit templates (can be used to make \&\s-1HTML\s0 output or anything else you please) .PP Additionally, it is designed so that you can plug in your own objects that read the parsed data while it is being parsed (no need for the performance or memory problems that can come from reading in the entire patch all at once). You can do this by mimicking one of the existing readers (such as PatchInfoGrabber) and overriding the methods start_patch, start_file, section, end_file and end_patch.