~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/merge3.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-09-20 02:40:52 UTC
  • mfrom: (2835.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070920024052-y2l7r5o00zrpnr73
No longer propagate index differences automatically (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2004, 2005 by Canonical Ltd
2
 
 
 
1
# Copyright (C) 2004, 2005 Canonical Ltd
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
20
 
21
21
 
22
22
from bzrlib.errors import CantReprocessAndShowBase
23
 
from bzrlib.patiencediff import SequenceMatcher
 
23
import bzrlib.patiencediff
24
24
from bzrlib.textfile import check_text_lines
25
25
 
 
26
 
26
27
def intersect(ra, rb):
27
28
    """Given two ranges return the range where they intersect or None.
28
29
 
87
88
                    reprocess=False):
88
89
        """Return merge in cvs-like form.
89
90
        """
 
91
        newline = '\n'
 
92
        if len(self.a) > 0:
 
93
            if self.a[0].endswith('\r\n'):
 
94
                newline = '\r\n'
 
95
            elif self.a[0].endswith('\r'):
 
96
                newline = '\r'
90
97
        if base_marker and reprocess:
91
98
            raise CantReprocessAndShowBase()
92
99
        if name_a:
110
117
                for i in range(t[1], t[2]):
111
118
                    yield self.b[i]
112
119
            elif what == 'conflict':
113
 
                yield start_marker + '\n'
 
120
                yield start_marker + newline
114
121
                for i in range(t[3], t[4]):
115
122
                    yield self.a[i]
116
123
                if base_marker is not None:
117
 
                    yield base_marker + '\n'
 
124
                    yield base_marker + newline
118
125
                    for i in range(t[1], t[2]):
119
126
                        yield self.base[i]
120
 
                yield mid_marker + '\n'
 
127
                yield mid_marker + newline
121
128
                for i in range(t[5], t[6]):
122
129
                    yield self.b[i]
123
 
                yield end_marker + '\n'
 
130
                yield end_marker + newline
124
131
            else:
125
132
                raise ValueError(what)
126
133
        
293
300
            type, iz, zmatch, ia, amatch, ib, bmatch = region
294
301
            a_region = self.a[ia:amatch]
295
302
            b_region = self.b[ib:bmatch]
296
 
            matches = SequenceMatcher(None, a_region, 
297
 
                                      b_region).get_matching_blocks()
 
303
            matches = bzrlib.patiencediff.PatienceSequenceMatcher(
 
304
                    None, a_region, b_region).get_matching_blocks()
298
305
            next_a = ia
299
306
            next_b = ib
300
307
            for region_ia, region_ib, region_len in matches[:-1]:
326
333
        """
327
334
 
328
335
        ia = ib = 0
329
 
        amatches = SequenceMatcher(None, self.base, self.a).get_matching_blocks()
330
 
        bmatches = SequenceMatcher(None, self.base, self.b).get_matching_blocks()
 
336
        amatches = bzrlib.patiencediff.PatienceSequenceMatcher(
 
337
                None, self.base, self.a).get_matching_blocks()
 
338
        bmatches = bzrlib.patiencediff.PatienceSequenceMatcher(
 
339
                None, self.base, self.b).get_matching_blocks()
331
340
        len_a = len(amatches)
332
341
        len_b = len(bmatches)
333
342
 
383
392
 
384
393
    def find_unconflicted(self):
385
394
        """Return a list of ranges in base that are not conflicted."""
386
 
        am = SequenceMatcher(None, self.base, self.a).get_matching_blocks()
387
 
        bm = SequenceMatcher(None, self.base, self.b).get_matching_blocks()
 
395
        am = bzrlib.patiencediff.PatienceSequenceMatcher(
 
396
                None, self.base, self.a).get_matching_blocks()
 
397
        bm = bzrlib.patiencediff.PatienceSequenceMatcher(
 
398
                None, self.base, self.b).get_matching_blocks()
388
399
 
389
400
        unc = []
390
401