tasks/ext/PatchTask.php

Show: inherited
Table of Contents

Patches a file by applying a 'diff' file to it

Requires "patch" to be on the execution path.

Based on Apache Ant PatchTask:

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

\PatchTask

Package: phing\tasks\ext

Patches a file by applying a 'diff' file to it

Requires "patch" to be on the execution path.

Parent(s)
\Task < \ProjectComponent

Constants

Constantstring  CMD = 'patch --batch --silent '

Base command to be executed (must end with a space character!)

string

Properties

Propertyprivatearray  $cmdArgs= 'array()'

Command line arguments for patch binary

Default valuearray()Details
Type
array
Propertyprivatebool  $haltOnFailure= 'false'

Halt on error return value from patch invocation.

Default valuefalseDetails
Type
bool
Propertyprivatestring  $originalFile= ''

File to be patched

Details
Type
string
Propertyprivatestring  $patchFile= ''

Patch file

Details
Type
string
Propertyprivateint  $strip= ''

Value for a "-p" option

Details
Type
int

Methods

methodpublicgetDescription( ) : void

methodpublicgetLocation( ) : void

methodpublicgetOwningTarget( ) : void

methodpublicgetProject( ) : void

methodprotectedgetRegisterSlot( ) : void

methodpublicgetRuntimeConfigurableWrapper( ) : void

methodpublicgetTaskName( ) : void

methodpublicgetTaskType( ) : void

methodpublicinit( ) : void

methodpubliclog( ) : void

methodpublicmain( ) : void

Main task method

Throws
Exception Description
\BuildException when it all goes a bit pear shaped
methodpublicmaybeConfigure( ) : void

methodpublicperform( ) : void

methodpublicsetBackups( bool $backups ) : void

Flag to create backups

Optional, default - false

Parameters
Name Type Description
$backups bool

If true create backups

methodpublicsetDescription( ) : void

methodpublicsetDestFile( string $file ) : void

The name of a file to send the output to, instead of patching the file(s) in place

Optional.

Parameters
Name Type Description
$file string

File to send the output to

methodpublicsetDir( string $directory ) : void

The directory to run the patch command in

Defaults to the project's base directory.

Parameters
Name Type Description
$directory string

Directory to run the patch command in

methodpublicsetForward( bool $flag ) : void

Ignore patches that seem to be reversed or already applied

Parameters
Name Type Description
$flag bool

If true set the -N (--forward) option

methodpublicsetFuzz( string $value ) : void

Set the maximum fuzz factor

Defaults to 0

Parameters
Name Type Description
$value string

Value of a fuzz factor

methodpublicsetHaltOnFailure( bool $value ) : void

If true, stop the build process if the patch command exits with an error status.

The default is "false"

Parameters
Name Type Description
$value bool

"true" if it should halt, otherwise "false"

methodpublicsetIgnoreWhiteSpace( bool $ignore ) : void

Flag to ignore whitespace differences;

Default - false

Parameters
Name Type Description
$ignore bool

If true ignore whitespace differences

methodpublicsetLocation( ) : void

methodpublicsetOriginalFile( string $file ) : void

The file to patch

Optional if it can be inferred from the diff file.

Parameters
Name Type Description
$file string

File to patch

methodpublicsetOwningTarget( ) : void

methodpublicsetPatchFile( string $file ) : void

The file containing the diff output

Required.

Parameters
Name Type Description
$file string

File containing the diff output

Throws
Exception Description
\BuildException if $file not exists
methodpublicsetProject( ) : void

methodpublicsetQuiet( bool $flag ) : void

Work silently unless an error occurs

Optional, default - false

Parameters
Name Type Description
$flag bool

If true suppress set the -s option on the patch command

methodpublicsetReverse( bool $flag ) : void

Assume patch was created with old and new files swapped

Optional, default - false

Parameters
Name Type Description
$flag bool

If true set the -R option on the patch command

methodpublicsetRuntimeConfigurableWrapper( ) : void

methodpublicsetStrip( int $num ) : void

Strip the smallest prefix containing num leading slashes from filenames.

patch's --strip option.

Parameters
Name Type Description
$num int

number of lines to strip

Throws
Exception Description
\BuildException if num is < 0, or other errors
methodpublicsetTaskName( ) : void

methodpublicsetTaskType( ) : void

Documentation was generated by DocBlox 0.17.1.