/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 breezy/_patiencediff_py.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 19:38:57 UTC
  • mfrom: (7143.16.21 even-more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116193857-bs5oma2655sp55qu
Fix another dozen flake8 errors.

Merged from https://code.launchpad.net/~jelmer/brz/even-more-cleanups/+merge/358931

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
        if line in index:
45
45
            index[line] = None
46
46
        else:
47
 
            index[line]= i
 
47
            index[line] = i
48
48
    # make btoa[i] = position of line i in a, unless
49
49
    # that line doesn't occur exactly once in both,
50
50
    # in which case it's set to None
77
77
        # as an optimization, check if the next line comes right after
78
78
        # the previous line, because usually it does
79
79
        elif stacks and stacks[k] < apos and (k == len(stacks) - 1 or
80
 
                                              stacks[k+1] > apos):
 
80
                                              stacks[k + 1] > apos):
81
81
            k += 1
82
82
        else:
83
83
            k = bisect(stacks, apos)
84
84
        if k > 0:
85
 
            backpointers[bpos] = lasts[k-1]
 
85
            backpointers[bpos] = lasts[k - 1]
86
86
        if k < len(stacks):
87
87
            stacks[k] = apos
88
88
            lasts[k] = bpos
124
124
    oldlength = len(answer)
125
125
    if alo == ahi or blo == bhi:
126
126
        return
127
 
    last_a_pos = alo-1
128
 
    last_b_pos = blo-1
 
127
    last_a_pos = alo - 1
 
128
    last_b_pos = blo - 1
129
129
    for apos, bpos in unique_lcs_py(a[alo:ahi], b[blo:bhi]):
130
130
        # recurse between lines which are unique in each file and match
131
131
        apos += alo
132
132
        bpos += blo
133
133
        # Most of the time, you will have a sequence of similar entries
134
 
        if last_a_pos+1 != apos or last_b_pos+1 != bpos:
135
 
            recurse_matches_py(a, b, last_a_pos+1, last_b_pos+1,
136
 
                apos, bpos, answer, maxrecursion - 1)
 
134
        if last_a_pos + 1 != apos or last_b_pos + 1 != bpos:
 
135
            recurse_matches_py(
 
136
                a, b, last_a_pos + 1, last_b_pos + 1, apos, bpos, answer,
 
137
                maxrecursion - 1)
137
138
        last_a_pos = apos
138
139
        last_b_pos = bpos
139
140
        answer.append((apos, bpos))
140
141
    if len(answer) > oldlength:
141
142
        # find matches between the last match and the end
142
 
        recurse_matches_py(a, b, last_a_pos+1, last_b_pos+1,
 
143
        recurse_matches_py(a, b, last_a_pos + 1, last_b_pos + 1,
143
144
                           ahi, bhi, answer, maxrecursion - 1)
144
145
    elif a[alo] == b[blo]:
145
146
        # find matching lines at the very beginning
156
157
        while nahi > alo and nbhi > blo and a[nahi - 1] == b[nbhi - 1]:
157
158
            nahi -= 1
158
159
            nbhi -= 1
159
 
        recurse_matches_py(a, b, last_a_pos+1, last_b_pos+1,
 
160
        recurse_matches_py(a, b, last_a_pos + 1, last_b_pos + 1,
160
161
                           nahi, nbhi, answer, maxrecursion - 1)
161
162
        for i in range(ahi - nahi):
162
163
            answer.append((nahi + i, nbhi + i))
173
174
    length = 0
174
175
    for i_a, i_b in matches:
175
176
        if (start_a is not None
176
 
            and (i_a == start_a + length)
177
 
            and (i_b == start_b + length)):
 
177
                and (i_a == start_a + length)
 
178
                and (i_b == start_b + length)):
178
179
            length += 1
179
180
        else:
180
181
            if start_a is not None:
241
242
        # Matches now has individual line pairs of
242
243
        # line A matches line B, at the given offsets
243
244
        self.matching_blocks = _collapse_sequences(matches)
244
 
        self.matching_blocks.append( (len(self.a), len(self.b), 0) )
 
245
        self.matching_blocks.append((len(self.a), len(self.b), 0))
245
246
        if PatienceSequenceMatcher_py._do_check_consistency:
246
247
            if __debug__:
247
248
                _check_consistency(self.matching_blocks)