1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
|
<?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>
<!-- 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="notes">
&reftitle.notes;
&warn.experimental.func;
</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
-->
|