| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,14 +225,17 @@ def is_exec(fpath): | |||
| 225 | 225 | return progs | |
| 226 | 226 | ||
| 227 | 227 | ||
| 228 | - def _cygpath(winpath): | ||
| 228 | + def _cygpath(winpath, inverse=False): | ||
| 229 | 229 | """Invokes `cygpath` cmd to parse Windoews paths.""" | |
| 230 | 230 | import subprocess as sbp | |
| 231 | 231 | ||
| 232 | 232 | cmd = ['cygpath', winpath] | |
| 233 | + if inverse: | ||
| 234 | + cmd.insert(1, '-w') | ||
| 233 | 235 | try: | |
| 234 | 236 | cygpath = sbp.check_output(cmd, universal_newlines=True) | |
| 235 | - cygpath = cygpath and cygpath[:-1] | ||
| 237 | + if cygpath and cygpath[-1] == '\n': | ||
| 238 | + cygpath = cygpath[:-1] | ||
| 236 | 239 | except Exception as ex: | |
| 237 | 240 | log.warning("`cygpath.exe` failed on '%s' due to: %s" | |
| 238 | 241 | " Using winpath as it is.", | |
@@ -290,7 +293,7 @@ def _cyg_regex_path(drive, path): | |||
| 290 | 293 | ) | |
| 291 | 294 | ||
| 292 | 295 | ||
| 293 | - @lru_cache(500) # Sice arg required only for py3.2 backport `repoze.lru` lib. | ||
| 296 | + @lru_cache(500) # Size arg required only for py3.2 backport `repoze.lru` lib. | ||
| 294 | 297 | def cygpath(path): | |
| 295 | 298 | """Use :meth:`git.cmd.Git.polish_url()` instead, that works on any environment.""" | |
| 296 | 299 | for regex, parser, recurse in _cygpath_parsers: | |
@@ -309,20 +312,23 @@ def cygpath(path): | |||
| 309 | 312 | _decygpath_regex = re.compile(r"/cygdrive/(\w)(/.*)?") | |
| 310 | 313 | ||
| 311 | 314 | ||
| 315 | + @lru_cache(500) # Size arg required only for py3.2 backport `repoze.lru` lib. | ||
| 312 | 316 | def decygpath(path): | |
| 313 | - m = _decygpath_regex.match(path) | ||
| 314 | - if m: | ||
| 315 | - drive, rest_path = m.groups() | ||
| 316 | - path = '%s:%s' % (drive.upper(), rest_path or '') | ||
| 317 | + if path: | ||
| 318 | + winpath = _cygpath(path, inverse=True) | ||
| 319 | + if path[-1] in '/\\' and winpath[-1] not in '/\\': | ||
| 320 | + winpath += '\\' | ||
| 321 | + path = winpath | ||
| 317 | 322 | ||
| 318 | - return path.replace('/', '\\') | ||
| 323 | + return path | ||
| 319 | 324 | ||
| 320 | 325 | ||
| 321 | 326 | #: Store boolean flags denoting if a specific Git executable | |
| 322 | 327 | #: is from a Cygwin installation (since `cache_lru()` unsupported on PY2). | |
| 323 | 328 | _is_cygwin_cache = {} | |
| 324 | 329 | ||
| 325 | 330 | ||
| 331 | + @lru_cache(50) # Size arg required only for py3.2 backport `repoze.lru` lib. | ||
| 326 | 332 | def is_cygwin_git(git_executable): | |
| 327 | 333 | if not is_win: | |
| 328 | 334 | return False | |
| Back | FazBrowse Home | New Git URL |
0 commit comments