Mercurial > hg
comparison hgext/convert/filemap.py @ 51686:39033e7a6e0a
convert: stringify `shlex` class argument
The documentation is handwavy, but typeshed says this should be `str`[1]. I'm
not sure if this is the correct encoding (vs `fsencode` or "latin1" like the
tokens returned by the proxy class).
While we're here, we can add a few more type hints that would have caused pytype
to flag the problem.
[1] https://github.com/python/typeshed/blob/6a9b53e719a139c2d6b41cf265ed0990cf438192/stdlib/shlex.pyi#L51
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 11 Jul 2024 21:16:45 -0400 |
parents | 0eb515c7bec8 |
children | f4733654f144 |
comparison
equal
deleted
inserted
replaced
51685:0eb515c7bec8 | 51686:39033e7a6e0a |
---|---|
74 repository).""" | 74 repository).""" |
75 | 75 |
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 = {} |
83 self.rename = {} | 83 self.rename = {} |
84 self.targetprefixes = None | 84 self.targetprefixes = None |
85 if path: | 85 if path: |
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): |
94 if not name: | 93 if not name: |
95 self.ui.warn( | 94 self.ui.warn( |
216 # touch files we're interested in, but also merges that merge two | 215 # touch files we're interested in, but also merges that merge two |
217 # or more interesting revisions. | 216 # or more interesting revisions. |
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) |
225 self.commits = {} | 226 self.commits = {} |
226 # if a revision rev has parent p in the original revision graph, then | 227 # if a revision rev has parent p in the original revision graph, then |