/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/patiencediff.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
 
from __future__ import absolute_import
19
18
 
20
 
from .lazy_import import lazy_import
 
19
from bzrlib.lazy_import import lazy_import
21
20
lazy_import(globals(), """
22
21
import os
23
22
import sys
74
73
     four
75
74
    """
76
75
    if sequencematcher is None:
 
76
        import difflib
77
77
        sequencematcher = difflib.SequenceMatcher
78
78
 
79
79
    if fromfiledate:
82
82
        tofiledate = '\t' + str(tofiledate)
83
83
 
84
84
    started = False
85
 
    for group in sequencematcher(None, a, b).get_grouped_opcodes(n):
 
85
    for group in sequencematcher(None,a,b).get_grouped_opcodes(n):
86
86
        if not started:
87
87
            yield '--- %s%s%s' % (fromfile, fromfiledate, lineterm)
88
88
            yield '+++ %s%s%s' % (tofile, tofiledate, lineterm)
129
129
 
130
130
 
131
131
try:
132
 
    from ._patiencediff_c import (
 
132
    from bzrlib._patiencediff_c import (
133
133
        unique_lcs_c as unique_lcs,
134
134
        recurse_matches_c as recurse_matches,
135
135
        PatienceSequenceMatcher_c as PatienceSequenceMatcher
136
136
        )
137
137
except ImportError:
138
 
    from ._patiencediff_py import (
 
138
    from bzrlib._patiencediff_py import (
139
139
        unique_lcs_py as unique_lcs,
140
140
        recurse_matches_py as recurse_matches,
141
141
        PatienceSequenceMatcher_py as PatienceSequenceMatcher
157
157
    matcher = algorithms[opts.matcher]
158
158
 
159
159
    if len(args) != 2:
160
 
        print('You must supply 2 filenames to diff')
 
160
        print 'You must supply 2 filenames to diff'
161
161
        return -1
162
162
 
163
163
    for line in unified_diff_files(args[0], args[1], sequencematcher=matcher):