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