This is an archive of the discontinued Mercurial Phabricator instance.

remotenames: port partway to python3 by using collections.MutableMapping
ClosedPublic

Authored by durin42 on Feb 15 2018, 9:18 AM.

Details

Summary

test-logexchange.t doesn't pass after this, but at least the
remotenames extension can be imported.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durin42 created this revision.Feb 15 2018, 9:18 AM
durin42 added inline comments.Feb 15 2018, 9:19 AM
hgext/remotenames.py
25–26

This import style irritates the import checker. We could do

try

import UserDict
dictmixin = DictMixin

except

import collections
dictmixin = collections.MutableMapping

would that be preferable?

yuja added a subscriber: yuja.Feb 15 2018, 9:38 AM

"would that be preferable?"

Perhaps. We'll need that anyway to get around demandimport.

In D2280#37674, @yuja wrote:

"would that be preferable?"
Perhaps. We'll need that anyway to get around demandimport.

I don't think we do (python3 demandimport is slightly nicer in this regard), but I've done it anyway since it helps the import checker.

durin42 updated this revision to Diff 5764.Feb 15 2018, 10:47 AM
durin42 updated this revision to Diff 5768.Feb 15 2018, 12:54 PM
dlax added a subscriber: dlax.Feb 16 2018, 3:06 AM
dlax added inline comments.
hgext/remotenames.py
30

collections.MutableMapping exists on Python2 as well (from 2.6 apparently), can't we use it?

durin42 marked an inline comment as done.Feb 16 2018, 5:04 PM
durin42 retitled this revision from remotenames: port partway to python3 to remotenames: port partway to python3 by using collections.MutableMapping.
durin42 updated this revision to Diff 5785.
yuja accepted this revision.Feb 16 2018, 10:37 PM
This revision is now accepted and ready to land.Feb 16 2018, 10:37 PM
This revision was automatically updated to reflect the committed changes.