~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_merge_directive.py

  • Committer: Aaron Bentley
  • Date: 2007-08-15 20:49:22 UTC
  • mto: This revision was merged to the branch mainline in revision 2747.
  • Revision ID: abentley@panoramicfeedback.com-20070815204922-sm909246487o1thf
Restore patch verification for CR, CRLF files

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
 
627
630
        lines = md.to_lines()
628
631
        md2 = merge_directive.MergeDirective.from_lines(lines)
629
632
        md2._verify_patch(tree_a.branch.repository)
630
 
        # Stript trailing whitespace
 
633
        # Strip trailing whitespace
631
634
        md2.patch = md2.patch.replace(' \n', '\n')
632
635
        md2._verify_patch(tree_a.branch.repository)
633
636
        # Convert to Mac line-endings
634
 
        md2.patch = md2.patch.replace('\n', '\r')
 
637
        md2.patch = re.sub('(\r\n|\r|\n)', '\r', md2.patch)
635
638
        self.assertTrue(md2._verify_patch(tree_a.branch.repository))
636
639
        # Convert to DOS line-endings
637
 
        md2.patch = md2.patch.replace('\r', '\r\n')
 
640
        md2.patch = re.sub('(\r\n|\r|\n)', '\r\n', md2.patch)
638
641
        self.assertTrue(md2._verify_patch(tree_a.branch.repository))
639
642
        md2.patch = md2.patch.replace('content_c', 'content_d')
640
643
        self.assertFalse(md2._verify_patch(tree_a.branch.repository))