~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-24 13:37:50 UTC
  • mfrom: (2520.7.4 bzr.mpbundle)
  • Revision ID: pqm@pqm.ubuntu.com-20070824133750-r25v5g25g1flggy6
Fix patch verification of CR and CRLF files and reactivate it

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
16
16
 
 
17
import re
17
18
 
18
19
from bzrlib import (
19
20
    errors,
352
353
        tree_a = self.make_branch_and_tree('tree_a')
353
354
        tree_a.branch.get_config().set_user_option('email',
354
355
            'J. Random Hacker <jrandom@example.com>')
355
 
        self.build_tree_contents([('tree_a/file', 'content_a\ncontent_b\n')])
356
 
        tree_a.add('file')
 
356
        self.build_tree_contents([('tree_a/file', 'content_a\ncontent_b\n'),
 
357
                                  ('tree_a/file_2', 'content_x\rcontent_y\r')])
 
358
        tree_a.add(['file', 'file_2'])
357
359
        tree_a.commit('message', rev_id='rev1')
358
360
        tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
359
361
        branch_c = tree_a.bzrdir.sprout('branch_c').open_branch()
360
362
        tree_b.commit('message', rev_id='rev2b')
361
 
        self.build_tree_contents([('tree_a/file', 'content_a\ncontent_c \n')])
 
363
        self.build_tree_contents([('tree_a/file', 'content_a\ncontent_c \n'),
 
364
                                  ('tree_a/file_2', 'content_x\rcontent_z\r')])
362
365
        tree_a.commit('Commit of rev2a', rev_id='rev2a')
363
366
        return tree_a, tree_b, branch_c
364
367
 
528
531
            self.assertEqual('inapplicable', verified)
529
532
        else:
530
533
            self.assertEqual('rev1', base)
531
 
            self.expectFailure('Patch verification is disabled',
532
 
                               self.assertEqual, 'failed', verified)
 
534
            self.assertEqual('failed', verified)
533
535
 
534
536
    def test_install_revisions_bundle(self):
535
537
        tree_a, tree_b, branch_c = self.make_trees()
628
630
        lines = md.to_lines()
629
631
        md2 = merge_directive.MergeDirective.from_lines(lines)
630
632
        md2._verify_patch(tree_a.branch.repository)
631
 
        # Stript trailing whitespace
 
633
        # Strip trailing whitespace
632
634
        md2.patch = md2.patch.replace(' \n', '\n')
633
635
        md2._verify_patch(tree_a.branch.repository)
634
636
        # Convert to Mac line-endings
635
 
        md2.patch = md2.patch.replace('\n', '\r')
 
637
        md2.patch = re.sub('(\r\n|\r|\n)', '\r', md2.patch)
636
638
        self.assertTrue(md2._verify_patch(tree_a.branch.repository))
637
639
        # Convert to DOS line-endings
638
 
        md2.patch = md2.patch.replace('\r', '\r\n')
 
640
        md2.patch = re.sub('(\r\n|\r|\n)', '\r\n', md2.patch)
639
641
        self.assertTrue(md2._verify_patch(tree_a.branch.repository))
640
642
        md2.patch = md2.patch.replace('content_c', 'content_d')
641
643
        self.assertFalse(md2._verify_patch(tree_a.branch.repository))