Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-unidiff for openSUSE:Factory 
checked in at 2022-01-29 20:59:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-unidiff (Old)
 and      /work/SRC/openSUSE:Factory/.python-unidiff.new.1898 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-unidiff"

Sat Jan 29 20:59:34 2022 rev:8 rq:949788 version:0.7.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-unidiff/python-unidiff.changes    
2021-08-23 10:08:30.420222809 +0200
+++ /work/SRC/openSUSE:Factory/.python-unidiff.new.1898/python-unidiff.changes  
2022-01-29 21:00:12.671428709 +0100
@@ -1,0 +2,9 @@
+Fri Jan 28 02:23:11 UTC 2022 - Martin Li??ka <mli...@suse.cz>
+
+- Update to version 0.7.2
+  * Fixed issue when parsing git diff header generated with --no-prefix.
+- Update to version 0.7.1
+  * Improved git added/deleted file detection.
+  * Added newline optional param when parsing from_filename.
+
+-------------------------------------------------------------------

Old:
----
  v0.7.0.tar.gz

New:
----
  v0.7.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-unidiff.spec ++++++
--- /var/tmp/diff_new_pack.XxMIYG/_old  2022-01-29 21:00:13.167425375 +0100
+++ /var/tmp/diff_new_pack.XxMIYG/_new  2022-01-29 21:00:13.191425213 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-unidiff
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-unidiff
-Version:        0.7.0
+Version:        0.7.2
 Release:        0
 Summary:        Unified diff parsing/metadata extraction library
 License:        MIT

++++++ v0.7.0.tar.gz -> v0.7.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/AUTHORS 
new/python-unidiff-0.7.2/AUTHORS
--- old/python-unidiff-0.7.0/AUTHORS    2021-08-15 20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/AUTHORS    2022-01-28 17:00:28.000000000 +0100
@@ -27,3 +27,5 @@
   * Snowhite (`@CirQ`_)
   * earonesty (`@earonesty`_)
   * Ben Carlsson (`@glacials`_)
+  * (`@huichen-cs`)
+  * Mikhail f. Shiryaev (`@Felixoid`)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/HISTORY 
new/python-unidiff-0.7.2/HISTORY
--- old/python-unidiff-0.7.0/HISTORY    2021-08-15 20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/HISTORY    2022-01-28 17:00:28.000000000 +0100
@@ -1,6 +1,17 @@
 History
 -------
 
+0.7.2 - 2022-01-28
+------------------
+
+* Fixed issue when parsing git diff header generated with `--no-prefix`.
+
+0.7.1 - 2022-01-27
+------------------
+
+* Improved git added/deleted file detection.
+* Added `newline` optional param when parsing `from_filename`.
+
 0.7.0 - 2021-08-16
 ------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/tests/samples/git_cr.diff 
new/python-unidiff-0.7.2/tests/samples/git_cr.diff
--- old/python-unidiff-0.7.0/tests/samples/git_cr.diff  1970-01-01 
01:00:00.000000000 +0100
+++ new/python-unidiff-0.7.2/tests/samples/git_cr.diff  2022-01-28 
17:00:28.000000000 +0100
@@ -0,0 +1,9 @@
+diff --git 
a/src/test/org/apache/commons/math/util/ExpandableDoubleArrayTest.java 
b/src/test/org/apache/commons/math/util/ExpandableDoubleArrayTest.java
+new file mode 100644
+index 000000000..2b38fa232
+--- /dev/null
++++ b/src/test/org/apache/commons/math/util/ExpandableDoubleArrayTest.java
+@@ -0,0 +1,3 @@
++ "This line is broken into two lines by CR. " +
                "but it should be treated as one line in the text diff file"
++ "This has no CR"
++ "This line also has CR. " +
              "but it should also be treated as one line in the text diff 
file". 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/python-unidiff-0.7.0/tests/samples/git_no_prefix.diff 
new/python-unidiff-0.7.2/tests/samples/git_no_prefix.diff
--- old/python-unidiff-0.7.0/tests/samples/git_no_prefix.diff   1970-01-01 
01:00:00.000000000 +0100
+++ new/python-unidiff-0.7.2/tests/samples/git_no_prefix.diff   2022-01-28 
17:00:28.000000000 +0100
@@ -0,0 +1,30 @@
+diff --git file1 file1
+deleted file mode 100644
+index 42f90fd..0000000
+--- file1
++++ /dev/null
+@@ -1,3 +0,0 @@
+-line11
+-line12
+-line13
+diff --git file2 file2
+index c337bf1..1cb02b9 100644
+--- file2
++++ file2
+@@ -4,0 +5,3 @@ line24
++line24n
++line24n2
++line24n3
+@@ -15,0 +19,3 @@ line215
++line215n
++line215n2
++line215n3
+diff --git file3 file3
+new file mode 100644
+index 0000000..632e269
+--- /dev/null
++++ file3
+@@ -0,0 +1,3 @@
++line31
++line32
++line33
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/tests/samples/sample8.diff 
new/python-unidiff-0.7.2/tests/samples/sample8.diff
--- old/python-unidiff-0.7.0/tests/samples/sample8.diff 2021-08-15 
20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/tests/samples/sample8.diff 2022-01-28 
17:00:28.000000000 +0100
@@ -1,3 +1,6 @@
+diff --git a/boo.bin b/boo.bin
+new file mode 100644
+index 0000000..ae000000
 diff --git a/foo.bin b/foo.bin
 new file mode 100644
 index 0000000..af000000
@@ -9,3 +12,6 @@
 deleted file mode 100644
 index af000000..0000000
 Binary files a/baz.bin and /dev/null differ
+diff --git a/fuz.bin b/fuz.bin
+new file mode 100644
+index 0000000..ae000000
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/tests/test_parser.py 
new/python-unidiff-0.7.2/tests/test_parser.py
--- old/python-unidiff-0.7.0/tests/test_parser.py       2021-08-15 
20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/tests/test_parser.py       2022-01-28 
17:00:28.000000000 +0100
@@ -231,6 +231,18 @@
         with open(utf8_file, 'r') as diff_file:
             self.assertRaises(UnidiffParseError, PatchSet, diff_file)
 
+    def test_from_filename_with_cr_in_diff_text_files(self):
+        """Parse git diff text files that contain CR"""
+        utf8_file = os.path.join(self.samples_dir, 'samples/git_cr.diff')
+        self.assertRaises(UnidiffParseError, PatchSet.from_filename, utf8_file)
+
+        ps1 = PatchSet.from_filename(utf8_file, newline='\n')
+        import io
+        with io.open(utf8_file, 'r', newline='\n') as diff_file:
+            ps2 = PatchSet(diff_file)
+
+        self.assertEqual(ps1, ps2)
+
     def test_parse_diff_with_new_and_modified_binary_files(self):
         """Parse git diff file with newly added and modified binaries files."""
         utf8_file = os.path.join(self.samples_dir, 'samples/sample8.diff')
@@ -238,26 +250,38 @@
             res = PatchSet(diff_file)
 
         # three file in the patch
-        self.assertEqual(len(res), 3)
+        self.assertEqual(len(res), 5)
 
-        # first file is added
+        # first empty file is added
         self.assertFalse(res[0].is_modified_file)
         self.assertFalse(res[0].is_removed_file)
         self.assertTrue(res[0].is_added_file)
-        self.assertTrue(res[0].is_binary_file)
+        self.assertFalse(res[0].is_binary_file)
 
-        # second file is modified
-        self.assertTrue(res[1].is_modified_file)
+        # second file is added
+        self.assertFalse(res[1].is_modified_file)
         self.assertFalse(res[1].is_removed_file)
-        self.assertFalse(res[1].is_added_file)
+        self.assertTrue(res[1].is_added_file)
         self.assertTrue(res[1].is_binary_file)
 
-        # third file is removed
-        self.assertFalse(res[2].is_modified_file)
-        self.assertTrue(res[2].is_removed_file)
+        # third file is modified
+        self.assertTrue(res[2].is_modified_file)
+        self.assertFalse(res[2].is_removed_file)
         self.assertFalse(res[2].is_added_file)
         self.assertTrue(res[2].is_binary_file)
 
+        # fourth file is removed
+        self.assertFalse(res[3].is_modified_file)
+        self.assertTrue(res[3].is_removed_file)
+        self.assertFalse(res[3].is_added_file)
+        self.assertTrue(res[3].is_binary_file)
+
+        # fifth empty file is added
+        self.assertFalse(res[4].is_modified_file)
+        self.assertFalse(res[4].is_removed_file)
+        self.assertTrue(res[4].is_added_file)
+        self.assertFalse(res[4].is_binary_file)
+
     def test_parse_round_trip_with_binary_files_in_diff(self):
         """Parse git diff with binary files though round trip"""
         utf8_file = os.path.join(self.samples_dir, 'samples/sample8.diff')
@@ -267,6 +291,28 @@
         res2 = PatchSet(str(res1))
         self.assertEqual(res1, res2)
 
+    def test_parse_diff_git_no_prefix(self):
+        utf8_file = os.path.join(self.samples_dir, 
'samples/git_no_prefix.diff')
+        with open(utf8_file, 'r') as diff_file:
+            res = PatchSet(diff_file)
+
+        self.assertEqual(len(res), 3)
+
+        self.assertEqual(res[0].source_file, 'file1')
+        self.assertEqual(res[0].target_file, '/dev/null')
+        self.assertTrue(res[0].is_removed_file)
+        self.assertEqual(res[0].path, 'file1')
+
+        self.assertEqual(res[1].source_file, 'file2')
+        self.assertEqual(res[1].target_file, 'file2')
+        self.assertTrue(res[1].is_modified_file)
+        self.assertEqual(res[1].path, 'file2')
+
+        self.assertEqual(res[2].source_file, '/dev/null')
+        self.assertEqual(res[2].target_file, 'file3')
+        self.assertTrue(res[2].is_added_file)
+        self.assertEqual(res[2].path, 'file3')
+
     def test_diff_lines_linenos(self):
         with open(self.sample_file, 'rb') as diff_file:
             res = PatchSet(diff_file, encoding='utf-8')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/unidiff/__version__.py 
new/python-unidiff-0.7.2/unidiff/__version__.py
--- old/python-unidiff-0.7.0/unidiff/__version__.py     2021-08-15 
20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/unidiff/__version__.py     2022-01-28 
17:00:28.000000000 +0100
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # The MIT License (MIT)
-# Copyright (c) 2014-2017 Matias Bordese
+# Copyright (c) 2014-2022 Matias Bordese
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -21,4 +21,4 @@
 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
 # OR OTHER DEALINGS IN THE SOFTWARE.
 
-__version__ = '0.7.0'
+__version__ = '0.7.2'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/unidiff/constants.py 
new/python-unidiff-0.7.2/unidiff/constants.py
--- old/python-unidiff-0.7.0/unidiff/constants.py       2021-08-15 
20:46:23.000000000 +0200
+++ new/python-unidiff-0.7.2/unidiff/constants.py       2022-01-28 
17:00:28.000000000 +0100
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # The MIT License (MIT)
-# Copyright (c) 2014-2021 Matias Bordese
+# Copyright (c) 2014-2022 Matias Bordese
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -37,7 +37,13 @@
 
 # check diff git line for git renamed files support
 RE_DIFF_GIT_HEADER = re.compile(
-    r'^diff --git (?P<source>a/[^\t\n]+) (?P<target>b/[^\t\n]+)')
+    r'^diff --git (?P<source>(a/)?[^\t\n]+) (?P<target>(b/)?[^\t\n]+)')
+
+# check diff git new file marker `deleted file mode 100644`
+RE_DIFF_GIT_DELETED_FILE = re.compile(r'^deleted file mode \d+\n$')
+
+# check diff git new file marker `new file mode 100644`
+RE_DIFF_GIT_NEW_FILE = re.compile(r'^new file mode \d+\n$')
 
 
 # @@ (source offset, length) (target offset, length) @@ (section header)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/python-unidiff-0.7.0/unidiff/patch.py 
new/python-unidiff-0.7.2/unidiff/patch.py
--- old/python-unidiff-0.7.0/unidiff/patch.py   2021-08-15 20:46:23.000000000 
+0200
+++ new/python-unidiff-0.7.2/unidiff/patch.py   2022-01-28 17:00:28.000000000 
+0100
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # The MIT License (MIT)
-# Copyright (c) 2014-2021 Matias Bordese
+# Copyright (c) 2014-2022 Matias Bordese
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -38,7 +38,9 @@
     LINE_TYPE_REMOVED,
     LINE_TYPE_NO_NEWLINE,
     LINE_VALUE_NO_NEWLINE,
+    RE_DIFF_GIT_DELETED_FILE,
     RE_DIFF_GIT_HEADER,
+    RE_DIFF_GIT_NEW_FILE,
     RE_HUNK_BODY_LINE,
     RE_HUNK_EMPTY_BODY_LINE,
     RE_HUNK_HEADER,
@@ -52,8 +54,9 @@
 
 PY2 = sys.version_info[0] == 2
 if PY2:
+    import io
     from StringIO import StringIO
-    open_file = codecs.open
+    open_file = io.open
     make_str = lambda x: x.encode(DEFAULT_ENCODING)
 
     def implements_to_string(cls):
@@ -232,7 +235,7 @@
 
     def __init__(self, patch_info=None, source='', target='',
                  source_timestamp=None, target_timestamp=None,
-                 is_binary_file=False, is_rename=False):
+                 is_binary_file=False):
         # type: (Optional[PatchInfo], str, str, Optional[str], Optional[str], 
bool, bool) -> None
         super(PatchedFile, self).__init__()
         self.patch_info = patch_info
@@ -241,7 +244,6 @@
         self.target_file = target
         self.target_timestamp = target_timestamp
         self.is_binary_file = is_binary_file
-        self.is_rename = is_rename
 
     def __repr__(self):
         # type: () -> str
@@ -407,6 +409,12 @@
         return sum([hunk.removed for hunk in self])
 
     @property
+    def is_rename(self):
+        return (self.source_file != DEV_NULL
+            and self.target_file != DEV_NULL
+            and self.source_file[2:] != self.target_file[2:])
+
+    @property
     def is_added_file(self):
         # type: () -> bool
         """Return True if this patch adds the file."""
@@ -472,18 +480,30 @@
             # check for a git file rename
             is_diff_git_header = RE_DIFF_GIT_HEADER.match(line)
             if is_diff_git_header:
-                if patch_info is None:
-                    patch_info = PatchInfo()
+                patch_info = PatchInfo()
                 source_file = is_diff_git_header.group('source')
                 target_file = is_diff_git_header.group('target')
-                if (source_file != DEV_NULL
-                        and target_file != DEV_NULL
-                        and source_file[2:] != target_file[2:]):
-                    # this is a renamed file
-                    current_file = PatchedFile(
-                        patch_info, source_file, target_file, None, None,
-                        is_rename=True)
-                    self.append(current_file)
+                current_file = PatchedFile(
+                    patch_info, source_file, target_file, None, None)
+                self.append(current_file)
+                patch_info.append(line)
+                continue
+
+            # check for a git new file
+            is_diff_git_new_file = RE_DIFF_GIT_NEW_FILE.match(line)
+            if is_diff_git_new_file:
+                if current_file is None or patch_info is None:
+                    raise UnidiffParseError('Unexpected new file found: %s' % 
line)
+                current_file.source_file = DEV_NULL
+                patch_info.append(line)
+                continue
+
+            # check for a git deleted file
+            is_diff_git_deleted_file = RE_DIFF_GIT_DELETED_FILE.match(line)
+            if is_diff_git_deleted_file:
+                if current_file is None or patch_info is None:
+                    raise UnidiffParseError('Unexpected deleted file found: 
%s' % line)
+                current_file.target_file = DEV_NULL
                 patch_info.append(line)
                 continue
 
@@ -494,18 +514,20 @@
                 source_timestamp = is_source_filename.group('timestamp')
                 # reset current file, unless we are processing a rename
                 # (in that case, source files should match)
-                if current_file is not None and not (current_file.is_rename and
+                if current_file is not None and not (
                         current_file.source_file == source_file):
                     current_file = None
+                elif current_file is not None:
+                    current_file.source_timestamp = source_timestamp
                 continue
 
             # check for target file header
             is_target_filename = RE_TARGET_FILENAME.match(line)
             if is_target_filename:
-                if current_file is not None and not current_file.is_rename:
-                    raise UnidiffParseError('Target without source: %s' % line)
                 target_file = is_target_filename.group('filename')
                 target_timestamp = is_target_filename.group('timestamp')
+                if current_file is not None and not (current_file.target_file 
== target_file):
+                    raise UnidiffParseError('Target without source: %s' % line)
                 if current_file is None:
                     # add current file to PatchSet
                     current_file = PatchedFile(
@@ -513,6 +535,8 @@
                         source_timestamp, target_timestamp)
                     self.append(current_file)
                     patch_info = None
+                else:
+                    current_file.target_timestamp = target_timestamp
                 continue
 
             # check for hunk header
@@ -547,9 +571,12 @@
                 source_file = is_binary_diff.group('source_filename')
                 target_file = is_binary_diff.group('target_filename')
                 patch_info.append(line)
-                current_file = PatchedFile(
-                    patch_info, source_file, target_file, is_binary_file=True)
-                self.append(current_file)
+                if current_file is not None:
+                    current_file.is_binary_file = True
+                else:
+                    current_file = PatchedFile(
+                        patch_info, source_file, target_file, 
is_binary_file=True)
+                    self.append(current_file)
                 patch_info = None
                 current_file = None
                 continue
@@ -557,10 +584,10 @@
             patch_info.append(line)
 
     @classmethod
-    def from_filename(cls, filename, encoding=DEFAULT_ENCODING, errors=None):
+    def from_filename(cls, filename, encoding=DEFAULT_ENCODING, errors=None, 
newline=None):
         # type: (str, str, Optional[str]) -> PatchSet
         """Return a PatchSet instance given a diff filename."""
-        with open_file(filename, 'r', encoding=encoding, errors=errors) as f:
+        with open_file(filename, 'r', encoding=encoding, errors=errors, 
newline=newline) as f:
             instance = cls(f)
         return instance
 

Reply via email to