D7208: fsmonitor: normalize hostname to bytes

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sat Nov 2 22:04:26 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Without this, we get a str/bytes mismatching when using %
  formatting a few lines below.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

REVISION DETAIL
  https://phab.mercurial-scm.org/D7208

AFFECTED FILES
  hgext/fsmonitor/state.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/state.py b/hgext/fsmonitor/state.py
--- a/hgext/fsmonitor/state.py
+++ b/hgext/fsmonitor/state.py
@@ -14,6 +14,7 @@
 
 from mercurial.i18n import _
 from mercurial import (
+    encoding,
     pathutil,
     util,
 )
@@ -81,7 +82,7 @@
                 self.invalidate()
                 return None, None, None
             diskhostname = state[0]
-            hostname = socket.gethostname()
+            hostname = encoding.strtolocal(socket.gethostname())
             if diskhostname != hostname:
                 # file got moved to a different host
                 self._ui.log(
@@ -127,7 +128,7 @@
 
         with file:
             file.write(struct.pack(_versionformat, _version))
-            file.write(socket.gethostname() + b'\0')
+            file.write(encoding.strtolocal(socket.gethostname()) + b'\0')
             file.write(clock + b'\0')
             file.write(ignorehash + b'\0')
             if notefiles:



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list