D5025: py3: make test-contrib-perf.t work on python 3
mharbison72 added a comment. In https://phab.mercurial-scm.org/D5025#76443, @mharbison72 wrote: > In https://phab.mercurial-scm.org/D5025#75556, @yuja wrote: > > > > def perfstartup(ui, repo, **opts): > > > opts = _byteskwargs(opts) > > > timer, fm = gettimer(ui, opts) > > > > > > - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) > > > > Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, > > I don't care. > > > Sadly, it doesn't work on Windows. But since os.system() is called with an r-string, bytes wouldn't be right anyway. When I simply formatted in sys.argv[0], I got this: > > --- c:/Users/Matt/projects/hg_py3/tests/test-contrib-perf.t > +++ c:/Users/Matt/projects/hg_py3/tests/test-contrib-perf.t.err > @@ -184,6 +184,7 @@ > $ hg perfrevrange > $ hg perfrevset 'all()' > $ hg perfstartup > + (null): can't open file '': [Errno 2] $ENOENT$ > $ hg perfstatus > $ hg perftags > $ hg perftemplating > > > This will be good to figure out because there are ~400 other instances of this error, mostly around launching hooks. Nevermind. Looking closer at exewrapper.c, the signature of Py_Main() changed. Is there any reason not to convert that file to the usual TCHAR type, and #define UNICODE when building for py3? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 To: pulkit, #hg-reviewers Cc: mharbison72, yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
mharbison72 added a comment. In https://phab.mercurial-scm.org/D5025#75556, @yuja wrote: > > def perfstartup(ui, repo, **opts): > > opts = _byteskwargs(opts) > > timer, fm = gettimer(ui, opts) > > > > - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) > > Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, > I don't care. Sadly, it doesn't work on Windows. But since os.system() is called with an r-string, bytes wouldn't be right anyway. When I simply formatted in sys.argv[0], I got this: --- c:/Users/Matt/projects/hg_py3/tests/test-contrib-perf.t +++ c:/Users/Matt/projects/hg_py3/tests/test-contrib-perf.t.err @@ -184,6 +184,7 @@ $ hg perfrevrange $ hg perfrevset 'all()' $ hg perfstartup + (null): can't open file '': [Errno 2] $ENOENT$ $ hg perfstatus $ hg perftags $ hg perftemplating This will be good to figure out because there are ~400 other instances of this error, mostly around launching hooks. What I've found to work (both here and for the hooks) is to make sure that python3 is launched: os.system(r"py -3 %s version -q > NUL" % sys.argv[0]) It's perfectly capable of running `r'notepad'`, so this must be an hg.exe/python.exe issue. This probably gets messy (at least with the hooks) because *.py files are associated with python2, and python2 is in $PATH (but not python3- both of which are named python.exe). `py -3` will also pay attention to the shbang line, all of which are coded to python2. The only other thing of note that I see is that wrapper.exe implements main() and not wmain(), but I can't believe that py3 is incapable of launching things built without Unicode support. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 To: pulkit, #hg-reviewers Cc: mharbison72, yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
yuja added a comment. > >> - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) > > > > Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, > > I don't care. > > What's the right way to do it on windows? I think `encoding.strtolocal()` is close, but I have no idea what's the best way to get `char *argv[]` back from `wchar_t *argv[]`. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 To: pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D5025: py3: make test-contrib-perf.t work on python 3
> >> - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) > > > > Applying fsencode() on sys.argv is probably wrong on Windows, but it's > perf.py, > > I don't care. > > What's the right way to do it on windows? I think `encoding.strtolocal()` is close, but I have no idea what's the best way to get `char *argv[]` back from `wchar_t *argv[]`. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
pulkit added a comment. >> def perfstartup(ui, repo, **opts): >> opts = _byteskwargs(opts) >> timer, fm = gettimer(ui, opts) >> >> - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) > > Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, > I don't care. What's the right way to do it on windows? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 To: pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
This revision was automatically updated to reflect the committed changes. Closed by commit rHGb456b2e0ad9f: py3: make test-contrib-perf.t work on python 3 (authored by pulkit, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D5025?vs=11959=11980#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D5025?vs=11959=11980 REVISION DETAIL https://phab.mercurial-scm.org/D5025 AFFECTED FILES contrib/perf.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -85,6 +85,7 @@ test-contrib-check-code.t test-contrib-check-commit.t test-contrib-dumprevlog.t +test-contrib-perf.t test-contrib-testparseutil.t test-convert-authormap.t test-convert-clonebranches.t diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -75,14 +75,16 @@ _byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) _xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) +fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) if pycompat.ispy3: _maxint = sys.maxsize # per py3 docs for replacing maxint else: _maxint = sys.maxint except (ImportError, AttributeError): import inspect getargspec = inspect.getargspec _byteskwargs = identity +fsencode = identity # no py3 support _maxint = sys.maxint # no py3 support _sysstr = lambda x: x # no py3 support _xrange = xrange @@ -968,7 +970,7 @@ def perfstartup(ui, repo, **opts): opts = _byteskwargs(opts) timer, fm = gettimer(ui, opts) -cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) def d(): if os.name != r'nt': os.system(b"HGRCPATH= %s version -q > /dev/null" % cmd) @@ -1387,17 +1389,18 @@ opts = _byteskwargs(opts) timer, fm = gettimer(ui, opts) options = { -b'w': b'ignore_all_space', -b'b': b'ignore_space_change', -b'B': b'ignore_blank_lines', +'w': 'ignore_all_space', +'b': 'ignore_space_change', +'B': 'ignore_blank_lines', } -for diffopt in (b'', b'w', b'b', b'B', b'wB'): +for diffopt in ('', 'w', 'b', 'B', 'wB'): opts = dict((options[c], b'1') for c in diffopt) def d(): ui.pushbuffer() commands.diff(ui, repo, **opts) ui.popbuffer() +diffopt = diffopt.encode('ascii') title = b'diffopts: %s' % (diffopt and (b'-' + diffopt) or b'none') timer(d, title) fm.end() @@ -1773,7 +1776,7 @@ data = segmentforrevs(chain[0], chain[-1])[1] rawchunks = getrawchunks(data, chain) bins = r._chunks(chain) -text = str(bins[0]) +text = bytes(bins[0]) bins = bins[1:] text = mdiff.patches(text, bins) To: pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
yuja added a comment. > - a/contrib/perf.py +++ b/contrib/perf.py @@ -75,14 +75,16 @@ _byteskwargs = pycompat.byteskwargs # since 4.1 (or https://phab.mercurial-scm.org/rHGfbc3f73dc802774fbda1fa5da02af1157b637038) _sysstr = pycompat.sysstr # since 4.0 (or https://phab.mercurial-scm.org/rHG2219f4f82ede7a66e5e3d8fb7c8a3ac76b129e87) _xrange = pycompat.xrange # since 4.8 (or https://phab.mercurial-scm.org/rHG7eba8f83129bc0642d19ee72ae335d0d1846803e) + fsencode = pycompat.fsencode # since 3.9 (or https://phab.mercurial-scm.org/rHGf4a5e0e86a7e1b5ed52e5ae0431e1e6463cb35fd) if pycompat.ispy3: _maxint = sys.maxsize # per py3 docs for replacing maxint else: _maxint = sys.maxint except (ImportError, AttributeError): import inspect getargspec = inspect.getargspec _byteskwargs = identity +fsencode = fsencode # no py3 support Fixed invalid reference in flight. > def perfstartup(ui, repo, **opts): > opts = _byteskwargs(opts) > timer, fm = gettimer(ui, opts) > > - cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, I don't care. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 To: pulkit, #hg-reviewers Cc: yuja, mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D5025: py3: make test-contrib-perf.t work on python 3
> --- a/contrib/perf.py > +++ b/contrib/perf.py > @@ -75,14 +75,16 @@ > _byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) > _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) > _xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) > +fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) > if pycompat.ispy3: > _maxint = sys.maxsize # per py3 docs for replacing maxint > else: > _maxint = sys.maxint > except (ImportError, AttributeError): > import inspect > getargspec = inspect.getargspec > _byteskwargs = identity > +fsencode = fsencode # no py3 support Fixed invalid reference in flight. > def perfstartup(ui, repo, **opts): > opts = _byteskwargs(opts) > timer, fm = gettimer(ui, opts) > -cmd = sys.argv[0] > +cmd = fsencode(sys.argv[0]) Applying fsencode() on sys.argv is probably wrong on Windows, but it's perf.py, I don't care. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5025: py3: make test-contrib-perf.t work on python 3
pulkit created this revision. Herald added subscribers: mercurial-devel, mjpieters. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5025 AFFECTED FILES contrib/perf.py contrib/python3-whitelist CHANGE DETAILS diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist --- a/contrib/python3-whitelist +++ b/contrib/python3-whitelist @@ -85,6 +85,7 @@ test-contrib-check-code.t test-contrib-check-commit.t test-contrib-dumprevlog.t +test-contrib-perf.t test-contrib-testparseutil.t test-convert-authormap.t test-convert-clonebranches.t diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -75,14 +75,16 @@ _byteskwargs = pycompat.byteskwargs # since 4.1 (or fbc3f73dc802) _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) _xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) +fsencode = pycompat.fsencode # since 3.9 (or f4a5e0e86a7e) if pycompat.ispy3: _maxint = sys.maxsize # per py3 docs for replacing maxint else: _maxint = sys.maxint except (ImportError, AttributeError): import inspect getargspec = inspect.getargspec _byteskwargs = identity +fsencode = fsencode # no py3 support _maxint = sys.maxint # no py3 support _sysstr = lambda x: x # no py3 support _xrange = xrange @@ -968,7 +970,7 @@ def perfstartup(ui, repo, **opts): opts = _byteskwargs(opts) timer, fm = gettimer(ui, opts) -cmd = sys.argv[0] +cmd = fsencode(sys.argv[0]) def d(): if os.name != r'nt': os.system(b"HGRCPATH= %s version -q > /dev/null" % cmd) @@ -1387,17 +1389,18 @@ opts = _byteskwargs(opts) timer, fm = gettimer(ui, opts) options = { -b'w': b'ignore_all_space', -b'b': b'ignore_space_change', -b'B': b'ignore_blank_lines', +'w': 'ignore_all_space', +'b': 'ignore_space_change', +'B': 'ignore_blank_lines', } -for diffopt in (b'', b'w', b'b', b'B', b'wB'): +for diffopt in ('', 'w', 'b', 'B', 'wB'): opts = dict((options[c], b'1') for c in diffopt) def d(): ui.pushbuffer() commands.diff(ui, repo, **opts) ui.popbuffer() +diffopt = diffopt.encode('ascii') title = b'diffopts: %s' % (diffopt and (b'-' + diffopt) or b'none') timer(d, title) fm.end() @@ -1773,7 +1776,7 @@ data = segmentforrevs(chain[0], chain[-1])[1] rawchunks = getrawchunks(data, chain) bins = r._chunks(chain) -text = str(bins[0]) +text = bytes(bins[0]) bins = bins[1:] text = mdiff.patches(text, bins) To: pulkit, #hg-reviewers Cc: mjpieters, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel