~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/weave.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-05-19 06:14:38 UTC
  • mfrom: (1704.2.23 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060519061438-6300caf3926c3cff
(mbp) small fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
from copy import copy
72
72
from cStringIO import StringIO
 
73
from difflib import SequenceMatcher
73
74
import os
74
75
import sha
75
76
import time
83
84
        )
84
85
import bzrlib.errors as errors
85
86
from bzrlib.osutils import sha_strings
86
 
import bzrlib.patiencediff
87
87
from bzrlib.symbol_versioning import *
88
88
from bzrlib.tsort import topo_sort
89
89
from bzrlib.versionedfile import VersionedFile, InterVersionedFile
180
180
    """
181
181
 
182
182
    __slots__ = ['_weave', '_parents', '_sha1s', '_names', '_name_map',
183
 
                 '_weave_name', '_matcher']
 
183
                 '_weave_name']
184
184
    
185
 
    def __init__(self, weave_name=None, access_mode='w', matcher=None):
 
185
    def __init__(self, weave_name=None, access_mode='w'):
186
186
        super(Weave, self).__init__(access_mode)
187
187
        self._weave = []
188
188
        self._parents = []
190
190
        self._names = []
191
191
        self._name_map = {}
192
192
        self._weave_name = weave_name
193
 
        if matcher is None:
194
 
            self._matcher = bzrlib.patiencediff.PatienceSequenceMatcher
195
 
        else:
196
 
            self._matcher = matcher
197
193
 
198
194
    def __repr__(self):
199
195
        return "Weave(%r)" % self._weave_name
532
528
        #print 'basis_lines:', basis_lines
533
529
        #print 'new_lines:  ', lines
534
530
 
535
 
        s = self._matcher(None, basis_lines, lines)
 
531
        s = SequenceMatcher(None, basis_lines, lines)
536
532
 
537
533
        # offset gives the number of lines that have been inserted
538
534
        # into the weave up to the current point; if the original edit instruction
1360
1356
        sys.stdout.writelines(w.get_iter(int(argv[3])))
1361
1357
        
1362
1358
    elif cmd == 'diff':
 
1359
        from difflib import unified_diff
1363
1360
        w = readit()
1364
1361
        fn = argv[2]
1365
1362
        v1, v2 = map(int, argv[3:5])
1366
1363
        lines1 = w.get(v1)
1367
1364
        lines2 = w.get(v2)
1368
 
        diff_gen = bzrlib.patiencediff.unified_diff(lines1, lines2,
 
1365
        diff_gen = unified_diff(lines1, lines2,
1369
1366
                                '%s version %d' % (fn, v1),
1370
1367
                                '%s version %d' % (fn, v2))
1371
1368
        sys.stdout.writelines(diff_gen)