How to use the unidiff.PatchedFile function in unidiff

To help you get started, we’ve selected a few unidiff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gcc-mirror / gcc / contrib / gcc-changelog / test_email.py View on Github external
# along with GCC; see the file COPYING3.  If not see
# .  */

import os
import tempfile
import unittest

from git_commit import GitCommit

from git_email import GitEmail

import unidiff

script_path = os.path.dirname(os.path.realpath(__file__))

unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')


NAME_STATUS1 = """
M	gcc/ada/impunit.adb'
R097	gcc/ada/libgnat/s-atopar.adb	gcc/ada/libgnat/s-aoinar.adb
"""


class TestGccChangelog(unittest.TestCase):
    def setUp(self):
        self.patches = {}
        self.temps = []

        filename = None
        patch_lines = []
        with open(os.path.join(script_path, 'test_patches.txt')) as f:
github gcc-mirror / gcc / contrib / test_mklog.py View on Github external
# Boston, MA 02110-1301, USA.

# This script parses a .diff file generated with 'diff -up' or 'diff -cp'
# and adds a skeleton ChangeLog file to the file. It does not try to be
# too smart when parsing function names, but it produces a reasonable
# approximation.
#
# Author: Martin Liska 

import unittest

from mklog import generate_changelog

import unidiff

unidiff_supports_renaming = hasattr(unidiff.PatchedFile(), 'is_rename')


PATCH1 = '''\
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 567c23380fe..e6209ede9d6 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -920,6 +920,7 @@ extern unsigned riscv_stack_boundary;
 #define SHIFT_RS1 15
 #define SHIFT_IMM 20
 #define IMM_BITS 12
+#define C_S_BITS 5
 #define C_SxSP_BITS 6
 
 #define IMM_REACH (1LL << IMM_BITS)
@@ -929,6 +930,10 @@ extern unsigned riscv_stack_boundary;