~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_patiencediff_py.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-05-01 11:25:12 UTC
  • mfrom: (3211.7.10 protocol-v3-doc)
  • Revision ID: pqm@pqm.ubuntu.com-20080501112512-b9lgs4w8r43evtn1
Add the smart protocol v3 specification to network-protocol.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
17
 
18
 
from __future__ import absolute_import
19
18
 
20
19
from bisect import bisect
21
20
import difflib
50
49
        else:
51
50
            index[line]= i
52
51
    # make btoa[i] = position of line i in a, unless
53
 
    # that line doesn't occur exactly once in both,
 
52
    # that line doesn't occur exactly once in both, 
54
53
    # in which case it's set to None
55
54
    btoa = [None] * len(b)
56
55
    index2 = {}
80
79
            k = len(stacks)
81
80
        # as an optimization, check if the next line comes right after
82
81
        # the previous line, because usually it does
83
 
        elif stacks and stacks[k] < apos and (k == len(stacks) - 1 or
 
82
        elif stacks and stacks[k] < apos and (k == len(stacks) - 1 or 
84
83
                                              stacks[k+1] > apos):
85
84
            k += 1
86
85
        else:
177
176
    length = 0
178
177
    for i_a, i_b in matches:
179
178
        if (start_a is not None
180
 
            and (i_a == start_a + length)
 
179
            and (i_a == start_a + length) 
181
180
            and (i_b == start_b + length)):
182
181
            length += 1
183
182
        else:
197
196
    # For consistency sake, make sure all matches are only increasing
198
197
    next_a = -1
199
198
    next_b = -1
200
 
    for (a, b, match_len) in answer:
201
 
        if a < next_a:
202
 
            raise ValueError('Non increasing matches for a')
203
 
        if b < next_b:
204
 
            raise ValueError('Non increasing matches for b')
 
199
    for a,b,match_len in answer:
 
200
        assert a >= next_a, 'Non increasing matches for a'
 
201
        assert b >= next_b, 'Not increasing matches for b'
205
202
        next_a = a + match_len
206
203
        next_b = b + match_len
207
204
 
231
228
        >>> s.get_matching_blocks()
232
229
        [(0, 0, 2), (3, 2, 2), (5, 4, 0)]
233
230
        """
234
 
        # jam 20060525 This is the python 2.4.1 difflib get_matching_blocks
 
231
        # jam 20060525 This is the python 2.4.1 difflib get_matching_blocks 
235
232
        # implementation which uses __helper. 2.4.3 got rid of helper for
236
233
        # doing it inline with a queue.
237
234
        # We should consider doing the same for recurse_matches