[PATCH 06 of 12] osutil: proxy through util (and platform) modules (API)

Martin von Zweigbergk martinvonz at google.com
Sun May 14 16:36:55 EDT 2017


On Sat, May 13, 2017 at 2:41 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Fri, 12 May 2017 22:03:59 -0400, Augie Fackler wrote:
>> On Fri, May 12, 2017 at 09:40:08AM -0700, Martin von Zweigbergk via Mercurial-devel wrote:
>> > On Sat, May 6, 2017 at 6:45 PM, Yuya Nishihara <yuya at tcha.org> wrote:
>>
>> [...]
>>
>> > > diff --git a/mercurial/util.py b/mercurial/util.py
>> > > --- a/mercurial/util.py
>> > > +++ b/mercurial/util.py
>> > > @@ -106,6 +106,7 @@ groupname = platform.groupname
>> > >  hidewindow = platform.hidewindow
>> > >  isexec = platform.isexec
>> > >  isowner = platform.isowner
>> > > +listdir = osutil.listdir
>> > >  localpath = platform.localpath
>> > >  lookupreg = platform.lookupreg
>> > >  makedir = platform.makedir
>> > > @@ -143,6 +144,15 @@ umask = platform.umask
>> > >  unlink = platform.unlink
>> > >  username = platform.username
>> > >
>> > > +try:
>> > > +    recvfds = osutil.recvfds
>> > > +except AttributeError:
>> > > +    pass
>> > > +try:
>> > > +    setprocname = osutil.setprocname
>> > > +except AttributeError:
>> > > +    pass
>> > > +
>> >
>> > What happens with the users of util.{recvfds,setprocname} in the
>> > AttributeError case? Also, when would that happen? Doesn't the C
>> > version also export those methods?
>>
>> Both of those methods are only used by chgserver.py. The former
>> appears to be used unconditionally (but I think that's unavoidable?)
>> adn the latter is only used if it exists (it's guarded by
>> util.safehasattr).
>>
>> I wouldn't worry about it in this case since chgserver is only useful
>> in cases where a compiler exists to compile chg.
>
> Yeah, they are for chgserver.py and unavailable on Windows (and some Unices.)

Aha, that's what I had been missing (i.e. that even the pure version
is unavailable on Windows).

> I could wrap them by e.g. maybesetprocname() but I didn't do that in this
> series.


More information about the Mercurial-devel mailing list