b.patiencediff : module documentation

Part of bzrlib

No module docstring
Function unified_diff Compare two sequences of lines; generate the delta as a unified diff.
Function unified_diff_files Generate the diff for two files.
Class PatienceSequenceMatcher Compare a pair of sequences using longest common subset.
Function main Undocumented
def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n', sequencematcher=None):

Compare two sequences of lines; generate the delta as a unified diff.

Unified diffs are a compact way of showing line changes and a few lines of context. The number of context lines is set by 'n' which defaults to three.

By default, the diff control lines (those with ---, +++, or @@) are created with a trailing newline. This is helpful so that inputs created from file.readlines() result in diffs that are suitable for file.writelines() since both the inputs and outputs have trailing newlines.

For inputs that do not have trailing newlines, set the lineterm argument to "" so that the output will be uniformly newline free.

The unidiff format normally has a header for filenames and modification times. Any or all of these may be specified using strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification times are normally expressed in the format returned by time.ctime().

Example:

>>> for line in unified_diff('one two three four'.split(),
...             'zero one tree four'.split(), 'Original', 'Current',
...             'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003',
...             lineterm=''):
...     print line
--- Original Sat Jan 26 23:30:50 1991
+++ Current Fri Jun 06 10:20:52 2003
@@ -1,4 +1,4 @@
+zero
 one
-two
-three
+tree
 four
def unified_diff_files(a, b, sequencematcher=None):
Generate the diff for two files.
def main(args):
Undocumented
API Documentation for Bazaar, generated by pydoctor at 2014-11-24 00:01:14.