mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 10:28:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
248 lines
6.5 KiB
XML
248 lines
6.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.svn-diff" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>svn_diff</refname>
|
|
<refpurpose>Recursively diffs two paths</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>svn_diff</methodname>
|
|
<methodparam><type>string</type><parameter>path1</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>rev1</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>path2</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>rev2</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Recursively diffs two paths, <parameter>path1</parameter> and
|
|
<parameter>path2</parameter>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
This is not a general-purpose diff utility. Only local files
|
|
that are versioned may be diffed: other files will fail.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>path1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
First path to diff. This can be a URL to a file/directory in an SVN
|
|
repository or a local file/directory path.
|
|
</para>
|
|
&svn.relativepath;
|
|
<warning>
|
|
<simpara>
|
|
If a local file path has only backslashes and no forward slashes,
|
|
this extension will fail to find the path. Always
|
|
replace all backslashes with forward slashes when using this
|
|
function.
|
|
</simpara>
|
|
</warning>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>rev1</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
First path's revision number. Use <constant>SVN_REVISION_HEAD</constant>
|
|
to specify the most recent revision.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>path2</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Second path to diff. See <parameter>path1</parameter> for description.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>rev2</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Second path's revision number. See <parameter>rev1</parameter>
|
|
for description.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns an array-list consisting of two streams: the first is the diff output
|
|
and the second contains error stream output. The streams can be
|
|
read using <function>fread</function>. Returns &false; or &null; on
|
|
error.
|
|
</para>
|
|
<para>
|
|
The diff output will, by default, be in the form of Subversion's
|
|
custom unified diff format, but an
|
|
<link xlink:href="&url.svn.manual.externaldifftools;">external
|
|
diff engine</link> may be
|
|
used depending on Subversion's configuration.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
&warn.experimental.func;
|
|
</refsect1>
|
|
|
|
<!-- Use when ERRORS exist
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
When does this function throw E_* level errors, or exceptions?
|
|
</para>
|
|
</refsect1>
|
|
-->
|
|
|
|
<!-- Use when a CHANGELOG exists
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>Enter the PHP version of change here</entry>
|
|
<entry>Description of change</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
-->
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Basic example</title>
|
|
<para>
|
|
This example demonstrates the basic usage of this function, and
|
|
the retrieval of contents from the stream:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
list($diff, $errors) = svn_diff(
|
|
'http://www.example.com/svnroot/trunk/foo', SVN_REVISION_HEAD,
|
|
'http://www.example.com/svnroot/branches/dev/foo', SVN_REVISION_HEAD
|
|
);
|
|
if (!$diff) exit;
|
|
$contents = '';
|
|
while (!feof($diff)) {
|
|
$contents .= fread($diff, 8192);
|
|
}
|
|
fclose($diff);
|
|
fclose($errors);
|
|
var_dump($contents);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Index: http://www.example.com/svnroot/trunk/foo
|
|
===================================================================
|
|
--- http://www.example.com/svnroot/trunk/foo (.../foo) (revision 23)
|
|
+++ http://www.example.com/svnroot/branches/dev/foo (.../foo) (revision 27)
|
|
// further diff output
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Diffing two revisions of a repository path</title>
|
|
<para>
|
|
This example implements a wrapper function that allows a user
|
|
to easily diff two revisions of the same item using an external
|
|
repository path (the default syntax is somewhat verbose):
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function svn_diff_same_item($path, $rev1, $rev2) {
|
|
return svn_diff($path, $rev1, $path, $rev2);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Portably diffing two local files</title>
|
|
<para>
|
|
This example implements a wrapper function that portably
|
|
diffs two local files, compensating for the <function>realpath</function>
|
|
fix and the backslashes bug:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function svn_diff_local($path1, $rev1, $path2, $rev2) {
|
|
$path1 = str_replace('\\', '/', realpath($path1));
|
|
$path2 = str_replace('\\', '/', realpath($path2));
|
|
return svn_diff($path1, $rev1, $path2, $rev2);
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><link xlink:href="&url.svn.manual.diff;">SVN documentation on svn diff</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|