mg Thu Aug 19 06:23:26 2004 EDT
Modified files:
/phpdoc/en/reference/xdiff/functions xdiff-file-diff-binary.xml
xdiff-file-diff.xml
xdiff-file-merge3.xml
xdiff-file-patch-binary.xml
xdiff-file-patch.xml
xdiff-string-diff.xml
xdiff-string-patch.xml
Log:
Add examples and notes about memory usage and format of diffs.
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml:1.3
phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml:1.4
--- phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml:1.3 Wed Apr 21
17:10:21 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-file-diff-binary.xml Thu Aug 19
06:23:26 2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-file-diff-binary">
<refnamediv>
@@ -19,11 +19,33 @@
<para>
<function>xdiff_file_diff_binary</function> makes binary diff of files
<parameter>file1</parameter> and <parameter>file2</parameter> and stores
- result in file <parameter>dest</parameter>.
+ result in file <parameter>dest</parameter>. This function works with both text
+ and binary files. Resulting file is in binary format.
</para>
+ <note>
+ <para>
+ Both files will be loaded into memory so ensure that your memory_limit is set
high enough.
+ </para>
+ </note>
<para>
&return.success;
</para>
+ <example>
+ <title><function>xdiff_file_diff_binary</function> example</title>
+ <para>
+ The following code makes binary diff of two archives.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_version = 'my_script_1.0.tgz';
+$new_version = 'my_script_1.1.tgz';
+
+xdiff_file_diff_binary($old_version, $new_version, 'my_script.bdiff');
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_string_diff_binary</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml:1.2
phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml:1.3
--- phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml:1.2 Mon Feb 9 13:22:05
2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-file-diff.xml Thu Aug 19 06:23:26
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-file-diff">
<refnamediv>
@@ -25,10 +25,33 @@
<parameter>context</parameter> indicated how many lines of context you
want to include in diff result. Set <parameter>minimal</parameter> to
&true; if you want to minimalize size of diff (can take a long time).
+ Resulting file is human-readable.
</para>
+ <note>
+ <para>
+ This function doesn't work well with binary files. To make diff of binary
+ files use <function>xdiff_file_diff_binary</function>.
+ </para>
+ </note>
<para>
&return.success;
</para>
+ <example>
+ <title><function>xdiff_file_diff</function> example</title>
+ <para>
+ The following code makes unified diff of two php files.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_version = 'my_script.php';
+$new_version = 'my_new_script.php';
+
+xdiff_file_diff($old_version, $new_version, 'my_script.diff', 2);
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_string_diff</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml:1.2
phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml:1.3
--- phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml:1.2 Tue Feb 10
13:57:00 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-file-merge3.xml Thu Aug 19 06:23:26
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-file-merge3">
<refnamediv>
@@ -27,6 +27,27 @@
Returns &true; if merge was successful, string with rejected chunks if
it was not or &false; if an internal error happened.
</para>
+ <example>
+ <title><function>xdiff_file_merge3</function> example</title>
+ <para>
+ The following code merges three files into one.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_version = 'original_script.php';
+$fix1 = 'script_with_fix1.php';
+$fix2 = 'script_with_fix2.php';
+
+$errors = xdiff_file_merge3($old_version, $fix1, $fix2, 'fixed_script.php');
+if (is_string($errors)) {
+ echo "Rejects:\n";
+ echo $errors;
+}
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_string_merge3</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml?r1=1.4&r2=1.5&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml:1.4
phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml:1.5
--- phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml:1.4 Tue Aug 3
12:54:59 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-file-patch-binary.xml Thu Aug 19
06:23:26 2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-file-patch-binary">
<refnamediv>
@@ -22,9 +22,36 @@
<parameter>patch</parameter> and stores result in file
<parameter>dest</parameter>.
</para>
+ <note>
+ <para>
+ Both files (file and patch) will be loaded into memory so ensure that your
memory_limit is set high enough.
+ </para>
+ </note>
<para>
&return.success;
</para>
+ <example>
+ <title><function>xdiff_file_patch_binary</function> example</title>
+ <para>
+ The following code applies binary diff to a file.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_version = 'archive-1.0.tgz';
+$patch = 'archive.bpatch';
+
+$result = xdiff_file_patch_binary($old_version, $patch, 'archive-1.1.tgz');
+if ($result) {
+ echo "File patched";
+} else {
+ echo "File couldn't be patched";
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_string_patch_binary</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml:1.3
phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml:1.4
--- phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml:1.3 Tue Aug 3
12:54:59 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-file-patch.xml Thu Aug 19 06:23:26
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-file-patch">
<refnamediv>
@@ -32,6 +32,48 @@
Returns &false; if an internal error happened, string with rejected
chunks of patch or &true; if patch has been successfully applied.
</para>
+ <example>
+ <title><function>xdiff_file_patch</function> example</title>
+ <para>
+ The following code applies unified diff to a file.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_version = 'my_script-1.0.php';
+$patch = 'my_script.patch';
+
+$errors = xdiff_file_patch($old_version, $patch, 'my_script-1.1.php');
+if (is_string($errors)) {
+ echo "Rejects:\n";
+ echo $errors;
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Patch reversing example</title>
+ <para>
+ The following code reverses a patch.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$new_version = 'my_script-1.1.php';
+$patch = 'my_script.patch';
+
+$errors = xdiff_file_patch($new_version, $patch, 'my_script-1.0.php',
XDIFF_PATCH_REVERSE);
+if (is_string($errors)) {
+ echo "Rejects:\n";
+ echo $errors;
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_string_patch</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml:1.2
phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml:1.3
--- phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml:1.2 Wed Apr 21
17:14:25 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-string-diff.xml Thu Aug 19 06:23:26
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-string-diff">
<refnamediv>
@@ -24,9 +24,36 @@
want to include in diff result. Set <parameter>minimal</parameter> to
&true; if you want to minimalize size of diff (can take a long time).
</para>
+ <note>
+ <para>
+ This function doesn't work well with binary strings. To make diff of binary
+ strings use <function>xdiff_string_diff_binary</function>.
+ </para>
+ </note>
<para>
Returns string with result or &false; if an internal error happened.
</para>
+ <example>
+ <title><function>xdiff_string_diff</function> example</title>
+ <para>
+ The following code makes unified diff of two articles.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_article = file_get_contents('./old_article.txt');
+$new_article = $_REQUEST['article']; /* Let's say that someone pasted a new article
to html form */
+
+$diff = xdiff_string_diff($old_article, $new_article, 1);
+if (is_string($diff)) {
+ echo "Differences between two articles:\n";
+ echo $diff;
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
<para>
See also <function>xdiff_file_diff</function>.
</para>
http://cvs.php.net/diff.php/phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml?r1=1.2&r2=1.3&ty=u
Index: phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml
diff -u phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml:1.2
phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml:1.3
--- phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml:1.2 Tue Aug 3
11:51:11 2004
+++ phpdoc/en/reference/xdiff/functions/xdiff-string-patch.xml Thu Aug 19 06:23:26
2004
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
-<!-- $Revision: 1.2 $ -->
+<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.0. Found in /scripts directory of phpdoc. -->
<refentry id="function.xdiff-string-patch">
<refnamediv>
@@ -31,6 +31,34 @@
If <parameter>error</parameter> is passed then rejected parts are stored
inside this variable.
</para>
+ <example>
+ <title><function>xdiff_string_patch</function> example</title>
+ <para>
+ The following code applies changes to some article.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$old_article = file_get_contents('./old_article.txt');
+$diff = $_SERVER['patch']; /* Let's say that someone pasted a patch to html form */
+
+$errors = '';
+
+$new_article = xdiff_string_patch($old_article, $diff, XDIFF_PATCH_NORMAL, $errors);
+if (is_string($new_article)) {
+ echo "New article:\n";
+ echo $new_article;
+}
+
+if (strlen($errors)) {
+ echo "Rejects: \n";
+ echo $errors;
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
<para>
Returns a patched string.
</para>