man VCP::Patch () - Apply the (almost) unified diffs used in RevML

NAME

VCP::Patch - Apply the (almost) unified diffs used in RevML

SYNOPSIS

    use VCP::Patch ;

    vcp_patch( $source_file_name, $result_file_name, $patch_file_name ) ;

DESCRIPTION

Creates the result file by applying the patch to the source file. Obliterates the result file even if the patch fails.

The patches are in a unified diff format, but without the filename headers (these are passed as other data fields in VCP and the actual filenames are just working files and are not important). Some example patches:

•
For a one line file:

   @@ -1 +1 @@
   -a/deeply/buried/file, revision 1, char 0x01="<char code="0x01" />"
   +a/deeply/buried/file, revision 2, char 0x09="  "
•
For a several line file with multiple changes:

Here are the source and result files side-by-side:

   Source       Result
   ======       ======

   1            1
   2            2
   3            3
   4            4
   5d           5a
   6            6
   7            7
   8            8
   9            9
   10           9a
   11           10
   11d          11
   12           12
   13           13

The patch to transform the source in to the result can be expressed in several ways, depending on the amount of context. VCP requires no context since the result is checked with an MD5 checksum. Context is, however, sometimes used to make the RevML a bit more human readable, though this can vary.

   @@ -5 +5 @@
   -5d
   +5a
   @@ -9,0 +10 @@
   +9a
   @@ -12 +12,0 @@
   -11d
   --- A   Sat Aug 25 00:05:26 2001
   +++ B   Sat Aug 25 00:05:26 2001
   @@ -4,3 +4,3 @@
    4
   -5d
   +5a
    6
   @@ -9,5 +9,5 @@
    9
   +9a
    10
    11
   -11d
    12
   --- A   Sat Aug 25 00:05:26 2001
   +++ B   Sat Aug 25 00:05:26 2001
   @@ -2,13 +2,13 @@
    2
    3
    4
   -5d
   +5a
    6
    7
    8
    9
   +9a
    10
    11
   -11d
    12
    13

Functions

vcp_patch
Takes a patch file name, a source file name, and a result file name and performs the patch. Called from VCP::Source::revml to reconstitute revisions given by delta records. Will die on error, always returns true.

COPYRIGHT

Copyright 2000, Perforce Software, Inc. All Rights Reserved. This module and the VCP package are licensed according to the terms given in the file LICENSE accompanying this distribution, a copy of which is included in vcp.

AUTHOR

Sean McCune <sean@sean-mccune.com>