VersionControl_SVN
[ class tree: VersionControl_SVN ] [ index: VersionControl_SVN ] [ all elements ]

Class: VersionControl_SVN_Diff

Source Location: /VersionControl_SVN-0.3.1/SVN/Diff.php

Class Overview

VersionControl_SVN
   |
   --VersionControl_SVN_Diff

Subversion Diff command manager class


Author(s):

Version:

  • 0.3.1

Copyright:

  • Copyright (c) 2004 Clay Loveless. All Rights Reserved.

Variables

Methods


Inherited Variables

Inherited Methods

Class: VersionControl_SVN

VersionControl_SVN::apiVersion()
Return the VersionControl_SVN API version
VersionControl_SVN::checkCommandRequirements()
Standardized validation of requirements for a command class.
VersionControl_SVN::declareErrorMessages()
Set up VersionControl_SVN error message templates for PEAR_ErrorStack.
VersionControl_SVN::factory()
Create a new VersionControl_SVN command object.
VersionControl_SVN::fetchCommands()
Scan through the SVN directory looking for subclasses.
VersionControl_SVN::fetchShortcuts()
Return the array of pre-defined shortcuts (also known as Alternate Names) for Subversion commands.
VersionControl_SVN::init()
Initialize an object wrapper for a Subversion subcommand.
VersionControl_SVN::parseOutput()
Handle output parsing chores.
VersionControl_SVN::prepare()
Prepare the command switches.
VersionControl_SVN::run()
Run the command with the defined switches.
VersionControl_SVN::setOptions()
Allow for overriding of previously declared options.

Class Details

[line 229]
Subversion Diff command manager class

Display the differences between two paths.

From 'svn diff --help':

usage: 1. diff [-r N[:M]] [--old OLD-TARGET] [--new NEW-TARGET] [PATH...] 2. diff -r N:M URL 3. diff [-r N[:M]] URL1[@N] URL2[@M]

  1. Display the differences between OLD-TARGET and NEW-TARGET. PATHs, if given, are relative to OLD-TARGET and NEW-TARGET and restrict the output to differences for those paths. OLD-TARGET and NEW-TARGET may be working copy paths or URL[@REV].
OLD-TARGET defaults to the path '.' and NEW-TARGET defaults to OLD-TARGET. N defaults to BASE or, if OLD-TARGET is an URL, to HEAD. M defaults to the current working version or, if NEW-TARGET is an URL, to HEAD.

'-r N' sets the revision of OLD-TGT to N, '-r N:M' also sets the revision of NEW-TGT to M.

2. Shorthand for 'svn diff -r N:M --old=URL --new=URL'.

3. Shorthand for 'svn diff [-r N[:M]] --old=URL1 --new=URL2'

Use just 'svn diff' to display local modifications in a working copy

Conversion of the above usage examples to VersionControl_SVN_Diff:

Example 1:

  1.  <?php
  2.  require_once 'VersionControl/SVN.php';
  3.  
  4.  // Setup error handling -- always a good idea!
  5.  $svnstack &PEAR_ErrorStack::singleton('VersionControl_SVN');
  6.  
  7.  // Set up runtime options. Will be passed to all
  8.  // subclasses.
  9.  $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_RAW);
  10.  
  11.  $switches = array('r' => '5:8');
  12.  $args = array('svn://svn.example.com/repos/TestProj/trunk/example.php',
  13.                'svn://svn.example.com/repos/TestProj/trunk/example2.php');
  14.  );
  15.  
  16.  $svn VersionControl_SVN::factory(array('diff')$options);
  17.  if ($diffs $svn->diff->run($args$switches)) {
  18.      echo "<pre>$diffs</pre>";
  19.  else {
  20.      if (count($errs $svnstack->getErrors())) {
  21.          foreach ($errs as $err{
  22.              echo '<br />'.$err['message']."<br />\n";
  23.              echo "Command used: " $err['params']['cmd'];
  24.          }
  25.      }
  26.  }
  27.  ?>

Example 2:

  1.  <?php
  2.  require_once 'VersionControl/SVN.php';
  3.  
  4.  // Setup error handling -- always a good idea!
  5.  $svnstack &PEAR_ErrorStack::singleton('VersionControl_SVN');
  6.  
  7.  // Set up runtime options. Will be passed to all
  8.  // subclasses.
  9.  $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_RAW);
  10.  
  11.  $switches = array('r' => '5:8');
  12.  $args = array('svn://svn.example.com/repos/TestProj/trunk/example.php');
  13.  
  14.  $svn VersionControl_SVN::factory(array('diff')$options);
  15.  if ($diffs $svn->diff->run($args$switches)) {
  16.      echo "<pre>$diffs</pre>";
  17.  else {
  18.      if (count($errs $svnstack->getErrors())) {
  19.          foreach ($errs as $err{
  20.              echo '<br />'.$err['message']."<br />\n";
  21.              echo "Command used: " $err['params']['cmd'];
  22.          }
  23.      }
  24.  }
  25.  ?>

Example 3:

  1.  <?php
  2.  require_once 'VersionControl/SVN.php';
  3.  
  4.  // Setup error handling -- always a good idea!
  5.  $svnstack &PEAR_ErrorStack::singleton('VersionControl_SVN');
  6.  
  7.  // Set up runtime options. Will be passed to all
  8.  // subclasses.
  9.  $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_RAW);
  10.  
  11.  $switches = array('r' => '5:8');
  12.  $args = array('svn://svn.example.com/repos/TestProj/trunk/example.php',
  13.                'svn://svn.example.com/repos/TestProj/trunk/example2.php');
  14.  
  15.  $svn VersionControl_SVN::factory(array('diff')$options);
  16.  if ($diffs $svn->diff->run($args$switches)) {
  17.      echo "<pre>$diffs</pre>";
  18.  else {
  19.      if (count($errs $svnstack->getErrors())) {
  20.          foreach ($errs as $err{
  21.              echo '<br />'.$err['message']."<br />\n";
  22.              echo "Command used: " $err['params']['cmd'];
  23.          }
  24.      }
  25.  }
  26.  ?>

$switches is an array containing one or more command line options defined by the following associative keys:

  1.  $switches = array(
  2.   'r [revision]'  =>  'ARG (some commands also take ARG1:ARG2 range)
  3.                         A revision argument can be one of:
  4.                            NUMBER       revision number
  5.                            "{" DATE "}" revision at start of the date
  6.                            "HEAD"       latest in repository
  7.                            "BASE"       base rev of item's working copy
  8.                            "COMMITTED"  last commit at or before BASE
  9.                            "PREV"       revision just before COMMITTED',
  10.                       // either 'r' or 'revision' may be used
  11.   'old'           =>  'OLD-TARGET',
  12.                       // use OLD-TARGET as the older target
  13.   'new'           =>  'NEW-TARGET',
  14.                       // use NEW-TARGET as the newer target
  15.   '[extensions]'=>  'ARG',
  16.                       // pass ARG as bundled options to GNU diff
  17.                       // either 'x' or 'extensions' may be used
  18.   'N'             =>  true|false,
  19.                       // operate on single directory only
  20.   'non-recursive' =>  true|false,
  21.                       // operate on single directory only
  22.   'diff-cmd'      =>  'ARG',
  23.                       // use ARG as diff command
  24.   'no-diff-deleted' => true|false,
  25.                       // do not print differences for deleted files
  26.   'notice-ancestry' => true|false,
  27.                       // notice ancestry when calculating differences
  28.   'username'      =>  'Subversion repository login',
  29.   'password'      =>  'Subversion repository password',
  30.   'no-auth-cache' =>  true|false,
  31.                       // Do not cache authentication tokens
  32.   'config-dir'    =>  'Path to a Subversion configuration directory'
  33.  );

Note: Subversion does not offer an XML output option for this subcommand

The non-interactive option available on the command-line svn client may also be set (true|false), but it is set to true by default.

The editor-cmd option available on the command-line svn client is not available since this class does not operate as an interactive shell session.

  • Author: Clay Loveless <clay@killersoft.com>
  • Version: 0.3.1
  • Copyright: Copyright (c) 2004 Clay Loveless. All Rights Reserved.


[ Top ]


Class Variables

$args = array()

[line 268]

Command-line arguments that should be passed outside of those specified in switches.
  • Access: public

Type:   array


[ Top ]

$min_args =  1

[line 277]

Minimum number of args required by this subcommand.

See Version Control with Subversion, Subversion Complete Reference for details on arguments for this subcommand.

  • Access: public

Type:   int


[ Top ]

$passthru =  false

[line 293]

Use exec or passthru to get results from command.
  • Access: public

Type:   bool


[ Top ]

$required_switches = array()

[line 286]

Switches required by this subcommand.

See Version Control with Subversion, Subversion Complete Reference for details on arguments for this subcommand.

  • Access: public

Type:   array


[ Top ]

$valid_switches = array('r',
                                'revision',
                                'old',
                                'new',
                                'x',
                                'extensions',
                                'N',
                                'non-recursive',
                                'non_recursive',
                                'diff-cmd',
                                'no-diff-deleted',
                                'no_diff_deleted',
                                'notice-ancestry',
                                'notice_ancestry',
                                'username',
                                'password',
                                'no-auth-cache',
                                'no_auth_cache',
                                'non-interactive',
                                'non_interactive',
                                'config-dir',
                                'config_dir'
                                )

[line 237]

Valid switches for svn diff
  • Access: public

Type:   array


[ Top ]



Method Detail

parseOutput   [line 406]

mixed parseOutput( array $out)

Handles output parsing of standard and verbose output of command.
  • Return: Returns output requested by fetchmode (if available), or raw output if desired fetchmode is not available.
  • Access: public

Overrides VersionControl_SVN::parseOutput() (Handle output parsing chores.)

Parameters:

array   $out   —  Array of output captured by exec command in run.

[ Top ]

parseOutputArray   [line 439]

void parseOutputArray( $out)

Helper method for parseOutput that parses output into an associative array
  • Todo: Finish this method! : )

Parameters:

   $out   — 

[ Top ]

prepare   [line 306]

int prepare( void 0)

Prepare the svn subcommand switches.

Defaults to non-interactive mode, and will auto-set the --xml switch (if available) if $fetchmode is set to VERSIONCONTROL_SVN_FETCHMODE_XML, VERSIONCONTROL_SVN_FETCHMODE_ASSOC or VERSIONCONTROL_SVN_FETCHMODE_OBJECT

  • Return: true on success, false on failure. Check PEAR_ErrorStack for error details, if any.

Overrides VersionControl_SVN::prepare() (Prepare the command switches.)

Parameters:

void   0   — 

[ Top ]


Documentation generated on Thu, 10 Dec 2015 05:46:59 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.