Show More
@@ -114,13 +114,13 b' def archive_repo(walker, archive_dest_pa' | |||||
114 | f'Remote does not support: "{kind}" archive type.') |
|
114 | f'Remote does not support: "{kind}" archive type.') | |
115 |
|
115 | |||
116 | for f in walker(commit_id, archive_at_path): |
|
116 | for f in walker(commit_id, archive_at_path): | |
117 | f_path = os.path.join(safe_bytes(archive_dir_name), f.path.lstrip(b'/')) |
|
117 | f_path = os.path.join(safe_bytes(archive_dir_name), safe_bytes(f.path).lstrip(b'/')) | |
118 | try: |
|
118 | try: | |
119 | archiver.addfile(f_path, f.mode, f.is_link, f.raw_bytes()) |
|
119 | archiver.addfile(f_path, f.mode, f.is_link, f.raw_bytes()) | |
120 | except NoContentException: |
|
120 | except NoContentException: | |
121 | # NOTE(marcink): this is a special case for SVN so we can create "empty" |
|
121 | # NOTE(marcink): this is a special case for SVN so we can create "empty" | |
122 | # directories which arent supported by archiver |
|
122 | # directories which arent supported by archiver | |
123 | archiver.addfile(os.path.join(f_path, b'.dir'), f.mode, f.is_link, '') |
|
123 | archiver.addfile(os.path.join(f_path, b'.dir'), f.mode, f.is_link, b'') | |
124 |
|
124 | |||
125 | if write_metadata: |
|
125 | if write_metadata: | |
126 | metadata = dict([ |
|
126 | metadata = dict([ |
@@ -1127,6 +1127,7 b' class GitRemote(RemoteBase):' | |||||
1127 | @reraise_safe_exceptions |
|
1127 | @reraise_safe_exceptions | |
1128 | def diff(self, wire, commit_id_1, commit_id_2, file_filter, opt_ignorews, context): |
|
1128 | def diff(self, wire, commit_id_1, commit_id_2, file_filter, opt_ignorews, context): | |
1129 | repo_init = self._factory.repo_libgit2(wire) |
|
1129 | repo_init = self._factory.repo_libgit2(wire) | |
|
1130 | ||||
1130 | with repo_init as repo: |
|
1131 | with repo_init as repo: | |
1131 | swap = True |
|
1132 | swap = True | |
1132 | flags = 0 |
|
1133 | flags = 0 | |
@@ -1152,7 +1153,7 b' class GitRemote(RemoteBase):' | |||||
1152 | if file_filter: |
|
1153 | if file_filter: | |
1153 | for p in diff_obj: |
|
1154 | for p in diff_obj: | |
1154 | if p.delta.old_file.path == file_filter: |
|
1155 | if p.delta.old_file.path == file_filter: | |
1155 |
return p. |
|
1156 | return p.data or '' | |
1156 | # fo matching path == no diff |
|
1157 | # fo matching path == no diff | |
1157 | return '' |
|
1158 | return '' | |
1158 | return diff_obj.patch or '' |
|
1159 | return diff_obj.patch or '' |
@@ -14,7 +14,7 b'' | |||||
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software Foundation, |
|
15 | # along with this program; if not, write to the Free Software Foundation, | |
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
16 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 |
|
17 | import binascii | ||
18 | import io |
|
18 | import io | |
19 | import logging |
|
19 | import logging | |
20 | import stat |
|
20 | import stat | |
@@ -471,7 +471,9 b' class HgRemote(RemoteBase):' | |||||
471 | repo = self._factory.repo(wire) |
|
471 | repo = self._factory.repo(wire) | |
472 |
|
472 | |||
473 | if file_filter: |
|
473 | if file_filter: | |
474 | match_filter = match(file_filter[0], '', [file_filter[1]]) |
|
474 | # unpack the file-filter | |
|
475 | repo_path, node_path = file_filter | |||
|
476 | match_filter = match(safe_bytes(repo_path), b'', [safe_bytes(node_path)]) | |||
475 | else: |
|
477 | else: | |
476 | match_filter = file_filter |
|
478 | match_filter = file_filter | |
477 | opts = diffopts(git=opt_git, ignorews=opt_ignorews, context=context, showfunc=1) |
|
479 | opts = diffopts(git=opt_git, ignorews=opt_ignorews, context=context, showfunc=1) | |
@@ -683,7 +685,7 b' class HgRemote(RemoteBase):' | |||||
683 | rev = rev + -1 |
|
685 | rev = rev + -1 | |
684 | try: |
|
686 | try: | |
685 | ctx = self._get_ctx(repo, rev) |
|
687 | ctx = self._get_ctx(repo, rev) | |
686 | except (TypeError, RepoLookupError) as e: |
|
688 | except (TypeError, RepoLookupError, binascii.Error) as e: | |
687 | e._org_exc_tb = traceback.format_exc() |
|
689 | e._org_exc_tb = traceback.format_exc() | |
688 | raise exceptions.LookupException(e)(rev) |
|
690 | raise exceptions.LookupException(e)(rev) | |
689 | except LookupError as e: |
|
691 | except LookupError as e: |
@@ -559,6 +559,7 b' class SvnRemote(RemoteBase):' | |||||
559 | """ |
|
559 | """ | |
560 | Special recursive svn repo walker |
|
560 | Special recursive svn repo walker | |
561 | """ |
|
561 | """ | |
|
562 | root_dir = safe_bytes(root_dir) | |||
562 |
|
563 | |||
563 | filemode_default = 0o100644 |
|
564 | filemode_default = 0o100644 | |
564 | filemode_executable = 0o100755 |
|
565 | filemode_executable = 0o100755 | |
@@ -574,7 +575,8 b' class SvnRemote(RemoteBase):' | |||||
574 | for _f_name, _f_data, _f_type in walk_tree(root, new_root, _commit_id): |
|
575 | for _f_name, _f_data, _f_type in walk_tree(root, new_root, _commit_id): | |
575 | yield _f_name, _f_data, _f_type |
|
576 | yield _f_name, _f_data, _f_type | |
576 | else: |
|
577 | else: | |
577 | f_path = os.path.join(root_dir, f_name).rstrip('/') |
|
578 | ||
|
579 | f_path = os.path.join(root_dir, f_name).rstrip(b'/') | |||
578 | prop_list = svn.fs.node_proplist(root, f_path) |
|
580 | prop_list = svn.fs.node_proplist(root, f_path) | |
579 |
|
581 | |||
580 | f_mode = filemode_default |
|
582 | f_mode = filemode_default | |
@@ -697,6 +699,11 b' class SvnDiffer(object):' | |||||
697 | def _generate_node_diff( |
|
699 | def _generate_node_diff( | |
698 | self, buf, change, tgt_path, tgt_base, src_path, src_base): |
|
700 | self, buf, change, tgt_path, tgt_base, src_path, src_base): | |
699 |
|
701 | |||
|
702 | ||||
|
703 | tgt_path = safe_str(tgt_path) | |||
|
704 | src_path = safe_str(src_path) | |||
|
705 | ||||
|
706 | ||||
700 | if self.src_rev == self.tgt_rev and tgt_base == src_base: |
|
707 | if self.src_rev == self.tgt_rev and tgt_base == src_base: | |
701 | # makes consistent behaviour with git/hg to return empty diff if |
|
708 | # makes consistent behaviour with git/hg to return empty diff if | |
702 | # we compare same revisions |
|
709 | # we compare same revisions | |
@@ -754,6 +761,7 b' class SvnDiffer(object):' | |||||
754 | ignore_blank_lines=self.ignore_whitespace, |
|
761 | ignore_blank_lines=self.ignore_whitespace, | |
755 | ignore_case=False, |
|
762 | ignore_case=False, | |
756 | ignore_space_changes=self.ignore_whitespace) |
|
763 | ignore_space_changes=self.ignore_whitespace) | |
|
764 | ||||
757 | buf.writelines(udiff) |
|
765 | buf.writelines(udiff) | |
758 |
|
766 | |||
759 | def _get_mime_type(self, path): |
|
767 | def _get_mime_type(self, path): | |
@@ -774,6 +782,7 b' class SvnDiffer(object):' | |||||
774 | return [] |
|
782 | return [] | |
775 | content = svn.core.Stream( |
|
783 | content = svn.core.Stream( | |
776 | svn.fs.file_contents(fs_root, node_path)).read() |
|
784 | svn.fs.file_contents(fs_root, node_path)).read() | |
|
785 | ||||
777 | return content.splitlines(True) |
|
786 | return content.splitlines(True) | |
778 |
|
787 | |||
779 |
|
788 |
@@ -161,6 +161,7 b' def unified_diff(fromlines, tolines, con' | |||||
161 | See `get_filtered_hunks` for the parameter descriptions. |
|
161 | See `get_filtered_hunks` for the parameter descriptions. | |
162 | """ |
|
162 | """ | |
163 | # TODO: johbo: Check if this can be nicely integrated into the matching |
|
163 | # TODO: johbo: Check if this can be nicely integrated into the matching | |
|
164 | ||||
164 | if ignore_space_changes: |
|
165 | if ignore_space_changes: | |
165 | fromlines = [l.strip() for l in fromlines] |
|
166 | fromlines = [l.strip() for l in fromlines] | |
166 | tolines = [l.strip() for l in tolines] |
|
167 | tolines = [l.strip() for l in tolines] |
General Comments 0
You need to be logged in to leave comments.
Login now