##// END OF EJS Templates
py3: replace os.name with pycompat.osname (part 2 of 2)
Pulkit Goyal -
r30640:7a3e67bf default
parent child Browse files
Show More
@@ -164,8 +164,6 b' If ``pagermode`` is not defined, the ``m'
164
164
165 from __future__ import absolute_import
165 from __future__ import absolute_import
166
166
167 import os
168
169 from mercurial.i18n import _
167 from mercurial.i18n import _
170 from mercurial import (
168 from mercurial import (
171 cmdutil,
169 cmdutil,
@@ -173,6 +171,7 b' from mercurial import ('
173 dispatch,
171 dispatch,
174 encoding,
172 encoding,
175 extensions,
173 extensions,
174 pycompat,
176 subrepo,
175 subrepo,
177 ui as uimod,
176 ui as uimod,
178 util,
177 util,
@@ -257,7 +256,7 b' def _modesetup(ui, coloropt):'
257
256
258 realmode = mode
257 realmode = mode
259 if mode == 'auto':
258 if mode == 'auto':
260 if os.name == 'nt':
259 if pycompat.osname == 'nt':
261 term = encoding.environ.get('TERM')
260 term = encoding.environ.get('TERM')
262 # TERM won't be defined in a vanilla cmd.exe environment.
261 # TERM won't be defined in a vanilla cmd.exe environment.
263
262
@@ -583,7 +582,7 b' def _debugdisplaystyle(ui):'
583 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
582 ui.write(', '.join(ui.label(e, e) for e in effects.split()))
584 ui.write('\n')
583 ui.write('\n')
585
584
586 if os.name != 'nt':
585 if pycompat.osname != 'nt':
587 w32effects = None
586 w32effects = None
588 else:
587 else:
589 import ctypes
588 import ctypes
@@ -103,7 +103,7 b' def geturl(path):'
103 pass
103 pass
104 if os.path.isdir(path):
104 if os.path.isdir(path):
105 path = os.path.normpath(os.path.abspath(path))
105 path = os.path.normpath(os.path.abspath(path))
106 if os.name == 'nt':
106 if pycompat.osname == 'nt':
107 path = '/' + util.normpath(path)
107 path = '/' + util.normpath(path)
108 # Module URL is later compared with the repository URL returned
108 # Module URL is later compared with the repository URL returned
109 # by svn API, which is UTF-8.
109 # by svn API, which is UTF-8.
@@ -254,8 +254,8 b' def issvnurl(ui, url):'
254 try:
254 try:
255 proto, path = url.split('://', 1)
255 proto, path = url.split('://', 1)
256 if proto == 'file':
256 if proto == 'file':
257 if (os.name == 'nt' and path[:1] == '/' and path[1:2].isalpha()
257 if (pycompat.osname == 'nt' and path[:1] == '/'
258 and path[2:6].lower() == '%3a/'):
258 and path[1:2].isalpha() and path[2:6].lower() == '%3a/'):
259 path = path[:2] + ':/' + path[6:]
259 path = path[:2] + ':/' + path[6:]
260 path = urlreq.url2pathname(path)
260 path = urlreq.url2pathname(path)
261 except ValueError:
261 except ValueError:
@@ -23,6 +23,7 b' from mercurial import ('
23 httpconnection,
23 httpconnection,
24 match as matchmod,
24 match as matchmod,
25 node,
25 node,
26 pycompat,
26 scmutil,
27 scmutil,
27 util,
28 util,
28 )
29 )
@@ -72,7 +73,7 b' def _usercachedir(ui):'
72 path = ui.configpath(longname, 'usercache', None)
73 path = ui.configpath(longname, 'usercache', None)
73 if path:
74 if path:
74 return path
75 return path
75 if os.name == 'nt':
76 if pycompat.osname == 'nt':
76 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
77 appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
77 if appdata:
78 if appdata:
78 return os.path.join(appdata, longname)
79 return os.path.join(appdata, longname)
@@ -80,7 +81,7 b' def _usercachedir(ui):'
80 home = os.getenv('HOME')
81 home = os.getenv('HOME')
81 if home:
82 if home:
82 return os.path.join(home, 'Library', 'Caches', longname)
83 return os.path.join(home, 'Library', 'Caches', longname)
83 elif os.name == 'posix':
84 elif pycompat.osname == 'posix':
84 path = os.getenv('XDG_CACHE_HOME')
85 path = os.getenv('XDG_CACHE_HOME')
85 if path:
86 if path:
86 return os.path.join(path, longname)
87 return os.path.join(path, longname)
@@ -88,7 +89,8 b' def _usercachedir(ui):'
88 if home:
89 if home:
89 return os.path.join(home, '.cache', longname)
90 return os.path.join(home, '.cache', longname)
90 else:
91 else:
91 raise error.Abort(_('unknown operating system: %s\n') % os.name)
92 raise error.Abort(_('unknown operating system: %s\n')
93 % pycompat.osname)
92 raise error.Abort(_('unknown %s usercache location') % longname)
94 raise error.Abort(_('unknown %s usercache location') % longname)
93
95
94 def inusercache(ui, hash):
96 def inusercache(ui, hash):
@@ -50,6 +50,7 b' from mercurial import ('
50 error,
50 error,
51 extensions,
51 extensions,
52 hg,
52 hg,
53 pycompat,
53 templater,
54 templater,
54 util,
55 util,
55 )
56 )
@@ -114,7 +115,7 b' def extsetup(ui):'
114 schemes.update(dict(ui.configitems('schemes')))
115 schemes.update(dict(ui.configitems('schemes')))
115 t = templater.engine(lambda x: x)
116 t = templater.engine(lambda x: x)
116 for scheme, url in schemes.items():
117 for scheme, url in schemes.items():
117 if (os.name == 'nt' and len(scheme) == 1 and scheme.isalpha()
118 if (pycompat.osname == 'nt' and len(scheme) == 1 and scheme.isalpha()
118 and os.path.exists('%s:\\' % scheme)):
119 and os.path.exists('%s:\\' % scheme)):
119 raise error.Abort(_('custom scheme %s:// conflicts with drive '
120 raise error.Abort(_('custom scheme %s:// conflicts with drive '
120 'letter %s:\\\n') % (scheme, scheme.upper()))
121 'letter %s:\\\n') % (scheme, scheme.upper()))
@@ -179,7 +179,7 b' def extsetup(ui):'
179 if _encoding.lower() in problematic_encodings.split():
179 if _encoding.lower() in problematic_encodings.split():
180 for f in funcs.split():
180 for f in funcs.split():
181 wrapname(f, wrapper)
181 wrapname(f, wrapper)
182 if os.name == 'nt':
182 if pycompat.osname == 'nt':
183 for f in winfuncs.split():
183 for f in winfuncs.split():
184 wrapname(f, wrapper)
184 wrapname(f, wrapper)
185 wrapname("mercurial.osutil.listdir", wrapperforlistdir)
185 wrapname("mercurial.osutil.listdir", wrapperforlistdir)
General Comments 0
You need to be logged in to leave comments. Login now