comparison hgext/fsmonitor/__init__.py @ 43395:2b8be670dcb6 stable

fsmonitor: normalize Watchman paths to bytes Otherwise it will be a str on Python 3 and operations below which operate in the bytes domain will fail. Differential Revision: https://phab.mercurial-scm.org/D7211
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 02 Nov 2019 14:26:06 -0700
parents bdebc7b54dca
children 2b5aab5e9e36
comparison
equal deleted inserted replaced
43394:d359dfc15aca 43395:2b8be670dcb6
405 # as being happens-after the exists=False entries due to the way that 405 # as being happens-after the exists=False entries due to the way that
406 # Watchman tracks files. We use this property to reconcile deletes 406 # Watchman tracks files. We use this property to reconcile deletes
407 # for name case changes. 407 # for name case changes.
408 for entry in result[b'files']: 408 for entry in result[b'files']:
409 fname = entry[b'name'] 409 fname = entry[b'name']
410
411 # Watchman always give us a str. Normalize to bytes on Python 3
412 # using Watchman's encoding, if needed.
413 if not isinstance(fname, bytes):
414 fname = fname.encode(_watchmanencoding)
415
410 if _fixencoding: 416 if _fixencoding:
411 fname = _watchmantofsencoding(fname) 417 fname = _watchmantofsencoding(fname)
418
412 if switch_slashes: 419 if switch_slashes:
413 fname = fname.replace(b'\\', b'/') 420 fname = fname.replace(b'\\', b'/')
414 if normalize: 421 if normalize:
415 normed = normcase(fname) 422 normed = normcase(fname)
416 fname = normalize(fname, True, True) 423 fname = normalize(fname, True, True)