##// END OF EJS Templates
osutil: proxy through util (and platform) modules (API)...
Yuya Nishihara -
r32203:d74b0cff default
parent child Browse files
Show More
@@ -182,7 +182,8 b' def extsetup(ui):'
182 182 if pycompat.osname == 'nt':
183 183 for f in winfuncs.split():
184 184 wrapname(f, wrapper)
185 wrapname("mercurial.osutil.listdir", wrapperforlistdir)
185 wrapname("mercurial.util.listdir", wrapperforlistdir)
186 wrapname("mercurial.windows.listdir", wrapperforlistdir)
186 187 # wrap functions to be called with local byte string arguments
187 188 for f in rfuncs.split():
188 189 wrapname(f, reversewrapper)
@@ -54,7 +54,6 b' from . import ('
54 54 encoding,
55 55 error,
56 56 extensions,
57 osutil,
58 57 pycompat,
59 58 util,
60 59 )
@@ -313,7 +312,7 b' class chgcmdserver(commandserver.server)'
313 312 # tell client to sendmsg() with 1-byte payload, which makes it
314 313 # distinctive from "attachio\n" command consumed by client.read()
315 314 self.clientsock.sendall(struct.pack('>cI', 'I', 1))
316 clientfds = osutil.recvfds(self.clientsock.fileno())
315 clientfds = util.recvfds(self.clientsock.fileno())
317 316 _log('received fds: %r\n' % clientfds)
318 317
319 318 ui = self.ui
@@ -458,12 +457,12 b' class chgcmdserver(commandserver.server)'
458 457 'setenv': setenv,
459 458 'setumask': setumask})
460 459
461 if util.safehasattr(osutil, 'setprocname'):
460 if util.safehasattr(util, 'setprocname'):
462 461 def setprocname(self):
463 462 """Change process title"""
464 463 name = self._readstr()
465 464 _log('setprocname: %r\n' % name)
466 osutil.setprocname(name)
465 util.setprocname(name)
467 466 capabilities['setprocname'] = setprocname
468 467
469 468 def _tempaddress(address):
@@ -18,7 +18,6 b' from . import ('
18 18 encoding,
19 19 error,
20 20 match as matchmod,
21 osutil,
22 21 parsers,
23 22 pathutil,
24 23 pycompat,
@@ -988,7 +987,7 b' class dirstate(object):'
988 987 matchalways = match.always()
989 988 matchtdir = match.traversedir
990 989 dmap = self._map
991 listdir = osutil.listdir
990 listdir = util.listdir
992 991 lstat = os.lstat
993 992 dirkind = stat.S_IFDIR
994 993 regkind = stat.S_IFREG
@@ -11,7 +11,6 b' import os'
11 11
12 12 from . import (
13 13 encoding,
14 osutil,
15 14 pycompat,
16 15 util,
17 16 )
@@ -30,7 +29,7 b' def _expandrcpath(path):'
30 29 p = util.expandpath(path)
31 30 if os.path.isdir(p):
32 31 join = os.path.join
33 return [join(p, f) for f, k in osutil.listdir(p) if f.endswith('.rc')]
32 return [join(p, f) for f, k in util.listdir(p) if f.endswith('.rc')]
34 33 return [p]
35 34
36 35 def envrcitems(env=None):
@@ -8,8 +8,8 b' import sys'
8 8
9 9 from . import (
10 10 encoding,
11 osutil,
12 11 pycompat,
12 util,
13 13 )
14 14
15 15 # BSD 'more' escapes ANSI color sequences by default. This can be disabled by
@@ -23,7 +23,7 b' def _rcfiles(path):'
23 23 rcdir = os.path.join(path, 'hgrc.d')
24 24 try:
25 25 rcs.extend([os.path.join(rcdir, f)
26 for f, kind in osutil.listdir(rcdir)
26 for f, kind in util.listdir(rcdir)
27 27 if f.endswith(".rc")])
28 28 except OSError:
29 29 pass
@@ -4,7 +4,6 b' import os'
4 4
5 5 from . import (
6 6 encoding,
7 osutil,
8 7 pycompat,
9 8 util,
10 9 win32,
@@ -29,7 +28,7 b' def systemrcpath():'
29 28 # Use hgrc.d found in directory with hg.exe
30 29 progrcd = os.path.join(os.path.dirname(filename), 'hgrc.d')
31 30 if os.path.isdir(progrcd):
32 for f, kind in osutil.listdir(progrcd):
31 for f, kind in util.listdir(progrcd):
33 32 if f.endswith('.rc'):
34 33 rcpath.append(os.path.join(progrcd, f))
35 34 # else look for a system rcpath in the registry
@@ -42,7 +41,7 b' def systemrcpath():'
42 41 if p.lower().endswith('mercurial.ini'):
43 42 rcpath.append(p)
44 43 elif os.path.isdir(p):
45 for f, kind in osutil.listdir(p):
44 for f, kind in util.listdir(p):
46 45 if f.endswith('.rc'):
47 46 rcpath.append(os.path.join(p, f))
48 47 return rcpath
@@ -106,6 +106,7 b' groupname = platform.groupname'
106 106 hidewindow = platform.hidewindow
107 107 isexec = platform.isexec
108 108 isowner = platform.isowner
109 listdir = osutil.listdir
109 110 localpath = platform.localpath
110 111 lookupreg = platform.lookupreg
111 112 makedir = platform.makedir
@@ -143,6 +144,15 b' umask = platform.umask'
143 144 unlink = platform.unlink
144 145 username = platform.username
145 146
147 try:
148 recvfds = osutil.recvfds
149 except AttributeError:
150 pass
151 try:
152 setprocname = osutil.setprocname
153 except AttributeError:
154 pass
155
146 156 # Python compatibility
147 157
148 158 _notset = object()
@@ -1165,7 +1175,7 b' def copyfiles(src, dst, hardlink=None, p'
1165 1175 os.stat(os.path.dirname(dst)).st_dev)
1166 1176 topic = gettopic()
1167 1177 os.mkdir(dst)
1168 for name, kind in osutil.listdir(src):
1178 for name, kind in listdir(src):
1169 1179 srcname = os.path.join(src, name)
1170 1180 dstname = os.path.join(dst, name)
1171 1181 def nprog(t, pos):
@@ -17,7 +17,6 b' import threading'
17 17 from .i18n import _
18 18 from . import (
19 19 error,
20 osutil,
21 20 pathutil,
22 21 pycompat,
23 22 util,
@@ -163,7 +162,7 b' class abstractvfs(object):'
163 162 return fd, fname
164 163
165 164 def readdir(self, path=None, stat=None, skip=None):
166 return osutil.listdir(self.join(path), stat, skip)
165 return util.listdir(self.join(path), stat, skip)
167 166
168 167 def readlock(self, path):
169 168 return util.readlock(self.join(path))
@@ -136,6 +136,9 b" def posixfile(name, mode='r', buffering="
136 136 # convert to a friendlier exception
137 137 raise IOError(err.errno, '%s: %s' % (name, err.strerror))
138 138
139 # may be wrapped by win32mbcs extension
140 listdir = osutil.listdir
141
139 142 class winstdout(object):
140 143 '''stdout on windows misbehaves if sent through a pipe'''
141 144
@@ -349,7 +352,7 b' def statfiles(files):'
349 352 if cache is None:
350 353 try:
351 354 dmap = dict([(normcase(n), s)
352 for n, k, s in osutil.listdir(dir, True)
355 for n, k, s in listdir(dir, True)
353 356 if getkind(s.st_mode) in _wantedkinds])
354 357 except OSError as err:
355 358 # Python >= 2.5 returns ENOENT and adds winerror field
@@ -376,7 +379,7 b' def groupname(gid=None):'
376 379 def removedirs(name):
377 380 """special version of os.removedirs that does not remove symlinked
378 381 directories or junction points if they actually contain files"""
379 if osutil.listdir(name):
382 if listdir(name):
380 383 return
381 384 os.rmdir(name)
382 385 head, tail = os.path.split(name)
@@ -384,7 +387,7 b' def removedirs(name):'
384 387 head, tail = os.path.split(head)
385 388 while head and tail:
386 389 try:
387 if osutil.listdir(head):
390 if listdir(head):
388 391 return
389 392 os.rmdir(head)
390 393 except (ValueError, OSError):
General Comments 0
You need to be logged in to leave comments. Login now