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