Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  PATCHREADER (3)

.ds Aq ’


PatchReader - Utilities to read and manipulate patches and CVS



  # 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 = filename.patch;

  # Create the reader that parses the patch and the object that
  # extracts info from the readers datastream
  my $reader = new PatchReader::Raw();
  my $patch_info_grabber = new PatchReader::PatchInfoGrabber();

  # Iterate over the file

  # Print the output
  my $patch_info = $patch_info_grabber->patch_info();
  print "Summary of Changed Files:\n";
  while (my ($file, $info) = each %{$patch_info->{files}}) {
    print "$file: +$info->{plus_lines} -$info->{minus_lines}\n";


This perl library allows you to manipulate patches programmatically by chaining together a variety of objects that read, manipulate, and output patch information:
PatchReader::Raw Parse a patch in any format known to this author (unified, normal, cvs diff, among others)
PatchReader::PatchInfoGrabber Grab summary info for sections of a patch in a nice hash
PatchReader::AddCVSContext Add context to the patch by grabbing the original files from CVS
PatchReader::NarrowPatch Narrow a patch down to only apply to a specific set of files
PatchReader::DiffPrinter::raw Output the parsed patch in raw unified diff format
PatchReader::DiffPrinter::template Output the parsed patch to Template::Toolkit templates (can be used to make HTML output or anything else you please)
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.
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 PATCHREADER (3) 2016-03-17

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.