diff hgext/fsmonitor/__init__.py @ 30666:6ada1658fc6b

py3: use python 3 compatible variables in hgext/fsmontor/__init__.py Earlier this was left thinking that its part of pywatchman package. This patch replaces variables os.sep, sys.platform and os.envrion with their py3 compatible ones.
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 21 Dec 2016 23:40:38 +0530
parents 318a24b52eeb
children 1064a296a2a7
line wrap: on
line diff
--- a/hgext/fsmonitor/__init__.py	Wed Dec 21 22:42:31 2016 +0530
+++ b/hgext/fsmonitor/__init__.py	Wed Dec 21 23:40:38 2016 +0530
@@ -94,15 +94,16 @@
 import hashlib
 import os
 import stat
-import sys
 
 from mercurial.i18n import _
 from mercurial import (
     context,
+    encoding,
     extensions,
     localrepo,
     merge,
     pathutil,
+    pycompat,
     scmutil,
     util,
 )
@@ -292,7 +293,7 @@
     if normalize:
         foldmap = dict((normcase(k), k) for k in results)
 
-    switch_slashes = os.sep == '\\'
+    switch_slashes = pycompat.ossep == '\\'
     # The order of the results is, strictly speaking, undefined.
     # For case changes on a case insensitive filesystem we may receive
     # two entries, one with exists=True and another with exists=False.
@@ -392,8 +393,8 @@
 
     def _cmpsets(l1, l2):
         try:
-            if 'FSMONITOR_LOG_FILE' in os.environ:
-                fn = os.environ['FSMONITOR_LOG_FILE']
+            if 'FSMONITOR_LOG_FILE' in encoding.environ:
+                fn = encoding.environ['FSMONITOR_LOG_FILE']
                 f = open(fn, 'wb')
             else:
                 fn = 'fsmonitorfail.log'
@@ -434,7 +435,7 @@
     updatestate = (parentworking and match.always() and
                    not isinstance(ctx2, (context.workingcommitctx,
                                          context.memctx)) and
-                   'HG_PENDING' not in os.environ)
+                   'HG_PENDING' not in encoding.environ)
 
     try:
         if self._fsmonitorstate.walk_on_invalidate:
@@ -545,7 +546,7 @@
 
 def extsetup(ui):
     wrapfilecache(localrepo.localrepository, 'dirstate', wrapdirstate)
-    if sys.platform == 'darwin':
+    if pycompat.sysplatform == 'darwin':
         # An assist for avoiding the dangling-symlink fsevents bug
         extensions.wrapfunction(os, 'symlink', wrapsymlink)