Show More
@@ -72,8 +72,10 b' class _shlexpy3proxy:' | |||||
72 | return _encodeornone(self._l.get_token()) |
|
72 | return _encodeornone(self._l.get_token()) | |
73 |
|
73 | |||
74 | @property |
|
74 | @property | |
75 | def infile(self): |
|
75 | def infile(self) -> bytes: | |
76 |
|
|
76 | if self._l.infile is not None: | |
|
77 | return encoding.strtolocal(self._l.infile) | |||
|
78 | return b'<unknown>' | |||
77 |
|
79 | |||
78 | @property |
|
80 | @property | |
79 | def lineno(self) -> int: |
|
81 | def lineno(self) -> int: | |
@@ -82,7 +84,7 b' class _shlexpy3proxy:' | |||||
82 |
|
84 | |||
83 | def shlexer( |
|
85 | def shlexer( | |
84 | data=None, |
|
86 | data=None, | |
85 |
filepath: Optional[ |
|
87 | filepath: Optional[bytes] = None, | |
86 | wordchars: Optional[bytes] = None, |
|
88 | wordchars: Optional[bytes] = None, | |
87 | whitespace: Optional[bytes] = None, |
|
89 | whitespace: Optional[bytes] = None, | |
88 | ): |
|
90 | ): | |
@@ -94,7 +96,8 b' def shlexer(' | |||||
94 | b'shlexer only accepts data or filepath, not both' |
|
96 | b'shlexer only accepts data or filepath, not both' | |
95 | ) |
|
97 | ) | |
96 | data = data.decode('latin1') |
|
98 | data = data.decode('latin1') | |
97 | l = shlex.shlex(data, infile=filepath, posix=True) |
|
99 | infile = encoding.strfromlocal(filepath) if filepath is not None else None | |
|
100 | l = shlex.shlex(data, infile=infile, posix=True) | |||
98 | if whitespace is not None: |
|
101 | if whitespace is not None: | |
99 | l.whitespace_split = True |
|
102 | l.whitespace_split = True | |
100 | l.whitespace += whitespace.decode('latin1') |
|
103 | l.whitespace += whitespace.decode('latin1') |
@@ -76,7 +76,7 b' class filemapper:' | |||||
76 | rename: MutableMapping[bytes, bytes] |
|
76 | rename: MutableMapping[bytes, bytes] | |
77 | targetprefixes: Optional[Set[bytes]] |
|
77 | targetprefixes: Optional[Set[bytes]] | |
78 |
|
78 | |||
79 | def __init__(self, ui: "uimod.ui", path=None) -> None: |
|
79 | def __init__(self, ui: "uimod.ui", path: Optional[bytes] = None) -> None: | |
80 | self.ui = ui |
|
80 | self.ui = ui | |
81 | self.include = {} |
|
81 | self.include = {} | |
82 | self.exclude = {} |
|
82 | self.exclude = {} | |
@@ -86,8 +86,7 b' class filemapper:' | |||||
86 | if self.parse(path): |
|
86 | if self.parse(path): | |
87 | raise error.Abort(_(b'errors in filemap')) |
|
87 | raise error.Abort(_(b'errors in filemap')) | |
88 |
|
88 | |||
89 | # TODO: cmd==b'source' case breaks if ``path``is str |
|
89 | def parse(self, path: Optional[bytes]) -> int: | |
90 | def parse(self, path) -> int: |
|
|||
91 | errs = 0 |
|
90 | errs = 0 | |
92 |
|
91 | |||
93 | def check(name: bytes, mapping, listname: bytes): |
|
92 | def check(name: bytes, mapping, listname: bytes): | |
@@ -218,7 +217,9 b' class filemapper:' | |||||
218 |
|
217 | |||
219 |
|
218 | |||
220 | class filemap_source(common.converter_source): |
|
219 | class filemap_source(common.converter_source): | |
221 | def __init__(self, ui: "uimod.ui", baseconverter, filemap) -> None: |
|
220 | def __init__( | |
|
221 | self, ui: "uimod.ui", baseconverter, filemap: Optional[bytes] | |||
|
222 | ) -> None: | |||
222 | super(filemap_source, self).__init__(ui, baseconverter.repotype) |
|
223 | super(filemap_source, self).__init__(ui, baseconverter.repotype) | |
223 | self.base = baseconverter |
|
224 | self.base = baseconverter | |
224 | self.filemapper = filemapper(ui, filemap) |
|
225 | self.filemapper = filemapper(ui, filemap) |
General Comments 0
You need to be logged in to leave comments.
Login now