예제 #1
0
 def testPatchFileWithFakeNoNewline(self):
     """Testing patching a file indicating no newline with a trailing \\r"""
     old = self._get_file('orig_src', 'README.nonewline')
     new = self._get_file('new_src', 'README.nonewline')
     diff = self._get_file('diffs', 'unified', 'README.nonewline.diff')
     files = diffparser.DiffParser(diff).parse()
     patched = diffutils.patch(files[0].data, old, new)
     self.assertEqual(diff, files[0].data)
     self.assertEqual(patched, new)
예제 #2
0
    def get_parser(self, data):
        """Return a diff parser used to parse diff data.

        The diff parser will be responsible for parsing the contents of the
        diff, and should expect (but validate) that the diff content is
        appropriate for the type of repository.

        Subclasses should override this.

        Args:
            data (bytes):
                The diff data to parse.

        Returns:
            reviewboard.diffviewer.diffparser.DiffParser:
            The diff parser used to parse this data.
        """
        return diffparser.DiffParser(data)
예제 #3
0
    def test_line_counts(self):
        """Testing DiffParser with insert/delete line counts"""
        diff = (b'+ This is some line before the change\n'
                b'- And another line\n'
                b'Index: foo\n'
                b'- One last.\n'
                b'--- README  123\n'
                b'+++ README  (new)\n'
                b'@ -1,1 +1,1 @@\n'
                b'-blah blah\n'
                b'-blah\n'
                b'+blah!\n'
                b'-blah...\n'
                b'+blah?\n'
                b'-blah!\n'
                b'+blah?!\n')
        files = diffparser.DiffParser(diff).parse()

        self.assertEqual(len(files), 1)
        self.assertEqual(files[0].insert_count, 3)
        self.assertEqual(files[0].delete_count, 4)
예제 #4
0
파일: core.py 프로젝트: rhass/reviewboard
 def get_parser(self, data):
     return diffparser.DiffParser(data)
예제 #5
0
 def testContextDiff(self):
     """Testing parse on a context diff"""
     data = self.diff('-c')
     files = diffparser.DiffParser(data).parse()
     self.compareDiffs(files, "context")
예제 #6
0
 def testUnifiedDiff(self):
     """Testing parse on a unified diff"""
     data = self.diff('-u')
     files = diffparser.DiffParser(data).parse()
     self.compareDiffs(files, "unified")