[PATCH 3 of 3] py3: enable legacy stdio mode in exewrapper
# HG changeset patch # User Matt Harbison # Date 1545000165 18000 # Sun Dec 16 17:42:45 2018 -0500 # Node ID e30dd3309facf82f53068bcd3098cd55815a6aaf # Parent 8b4f610c06528a66f6cd437aee1fd97f5dcea066 py3: enable legacy stdio mode in exewrapper This drops the test failure count from 166 to 117. The failures were typically in the form of `hg serve -d` spawning but crashing immediately, leaving clients with "bad http status" lines, connection refusals, and so forth. The underlying message on the server side was either "OSError: [WinError 6] The handle is invalid" or "OSError: [WinError 1] Incorrect function". Additionally, no output was rendered if the pager was activated. Thanks to Yuya for diagnosing the problem. The failure count drops to 107 when PYTHONLEGACYWINDOWSSTDIO=1 is defined in the environment. These failures seem to revolve around the dummyssh server process, and dumbhttp.py. So I'll probably add that to the test runner. One small regression here (only in py3) is that if hg.exe is already built, a messagebox appears when building it again saying that python37.dll can't be loaded. Python3 isn't in PATH by default, and setup.py tries running bare `hg` first. But MSYS prepends '.' to PATH, so it runs the local hg, but can't find the library. It falls back to the python used to invoke setup.py, so ultimately it works. I'm not sure if it's better to strip '.' from PATH or just skip right to `sys.executable hg` on Windows. Also, something seems to be wrong with run-tests._usecorrectpython(). I accidentially left off the 'PYTHON="py -3"' when building (thus making py2 stuff), and yet managed to invoke run-tests.py with "py -3". (And that only had 67 failures.) diff --git a/mercurial/exewrapper.c b/mercurial/exewrapper.c --- a/mercurial/exewrapper.c +++ b/mercurial/exewrapper.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "hgpythonlib.h" @@ -46,6 +47,10 @@ int _tmain(int argc, TCHAR *argv[]) void(__cdecl * Py_SetPythonHome)(TCHAR * home); int(__cdecl * Py_Main)(int argc, TCHAR *argv[]); +#if PY_MAJOR_VERSION >= 3 + Py_LegacyWindowsStdioFlag = 1; +#endif + if (GetModuleFileName(NULL, pyscript, _countof(pyscript)) == 0) { err = "GetModuleFileName failed"; goto bail; diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -2640,6 +2640,10 @@ class TestRunner(object): self._tmpbindir = self._bindir self._pythondir = os.path.join(self._installdir, b"lib", b"python") +# Force the use of hg.exe instead of relying on MSYS to recognize hg is +# a python script and feed it to python.exe. Legacy stdio is force +# enabled by hg.exe, and this is a more realistic way to launch hg +# anyway. if os.name == 'nt' and not self._hgcommand.endswith(b'.exe'): self._hgcommand += b'.exe' ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 3] run-tests: alias hg to hg.exe on Windows
# HG changeset patch # User Matt Harbison # Date 1544999811 18000 # Sun Dec 16 17:36:51 2018 -0500 # Node ID 8b4f610c06528a66f6cd437aee1fd97f5dcea066 # Parent 1a2afc80fc6d8660bcafcf21bde92754b1bd0f18 run-tests: alias hg to hg.exe on Windows To enable legacy stdio mode on Windows, hg.exe needs to be updated. But before that, we actually have to use it when running the tests. I *think* what was happening before was when MSYS invoked `hg`, it looked at the shbang line and ran python.exe found there. The test harness must be updating $PATH to include the python used to launch it, and therefore it ran py3. As a side note, this also fixed `py -3 run-tests.py` (without --local), which complained about the space in the shbang line before this. This should also help in WSL, because the explicit '.exe' is needed to invoke a Windows app instead of invoking the Linux app. I have no idea why this change capitalizes Lib in the tests, as it was previously lowercase for both py2 and py3. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -2640,6 +2640,9 @@ class TestRunner(object): self._tmpbindir = self._bindir self._pythondir = os.path.join(self._installdir, b"lib", b"python") +if os.name == 'nt' and not self._hgcommand.endswith(b'.exe'): +self._hgcommand += b'.exe' + # set CHGHG, then replace "hg" command by "chg" chgbindir = self._bindir if self.options.chg or self.options.with_chg: diff --git a/tests/test-install.t b/tests/test-install.t --- a/tests/test-install.t +++ b/tests/test-install.t @@ -4,7 +4,7 @@ hg debuginstall checking Python executable (*) (glob) checking Python version (2.*) (glob) (no-py3 !) checking Python version (3.*) (glob) (py3 !) - checking Python lib (*lib*)... (glob) + checking Python lib (.*[Ll]ib.*)... (re) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) SNI not supported by Python install; may have connectivity issues with some servers (?) @@ -60,7 +60,7 @@ hg debuginstall with no username checking Python executable (*) (glob) checking Python version (2.*) (glob) (no-py3 !) checking Python version (3.*) (glob) (py3 !) - checking Python lib (*lib*)... (glob) + checking Python lib (.*[Ll]ib.*)... (re) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) SNI not supported by Python install; may have connectivity issues with some servers (?) @@ -105,7 +105,7 @@ path variables are expanded (~ is the sa checking Python executable (*) (glob) checking Python version (2.*) (glob) (no-py3 !) checking Python version (3.*) (glob) (py3 !) - checking Python lib (*lib*)... (glob) + checking Python lib (.*[Ll]ib.*)... (re) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) SNI not supported by Python install; may have connectivity issues with some servers (?) @@ -130,7 +130,7 @@ not found (this is intentionally using b checking Python executable (*) (glob) checking Python version (2.*) (glob) (no-py3 !) checking Python version (3.*) (glob) (py3 !) - checking Python lib (*lib*)... (glob) + checking Python lib (.*[Ll]ib.*)... (re) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) SNI not supported by Python install; may have connectivity issues with some servers (?) diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t --- a/tests/test-run-tests.t +++ b/tests/test-run-tests.t @@ -644,12 +644,14 @@ Running In Debug Mode $ rt --debug 2>&1 | grep -v pwd running 2 tests using 1 parallel processes + + alias hg=hg.exe (windows !) + echo *SALT* 0 0 (glob) *SALT* 0 0 (glob) + echo babar babar + echo *SALT* 10 0 (glob) *SALT* 10 0 (glob) + .+ alias hg=hg.exe (windows !) *+ echo *SALT* 0 0 (glob) *SALT* 0 0 (glob) + echo babar ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 3] py3: conditionalize the python version in test-install.t
# HG changeset patch # User Matt Harbison # Date 1544993228 18000 # Sun Dec 16 15:47:08 2018 -0500 # Node ID 1a2afc80fc6d8660bcafcf21bde92754b1bd0f18 # Parent b565360af9e733ae90142af8eda6c9d52fe76f61 py3: conditionalize the python version in test-install.t diff --git a/tests/test-install.t b/tests/test-install.t --- a/tests/test-install.t +++ b/tests/test-install.t @@ -2,7 +2,8 @@ hg debuginstall $ hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) - checking Python version (2.*) (glob) + checking Python version (2.*) (glob) (no-py3 !) + checking Python version (3.*) (glob) (py3 !) checking Python lib (*lib*)... (glob) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) @@ -57,7 +58,8 @@ hg debuginstall with no username $ HGUSER= hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) - checking Python version (2.*) (glob) + checking Python version (2.*) (glob) (no-py3 !) + checking Python version (3.*) (glob) (py3 !) checking Python lib (*lib*)... (glob) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) @@ -101,7 +103,8 @@ path variables are expanded (~ is the sa $ HGEDITOR="~/tools/testeditor.exe" hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) - checking Python version (*) (glob) + checking Python version (2.*) (glob) (no-py3 !) + checking Python version (3.*) (glob) (py3 !) checking Python lib (*lib*)... (glob) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) @@ -125,7 +128,8 @@ not found (this is intentionally using b $ HGEDITOR="c:\foo\bar\baz.exe -y -z" hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) - checking Python version (*) (glob) + checking Python version (2.*) (glob) (no-py3 !) + checking Python version (3.*) (glob) (py3 !) checking Python lib (*lib*)... (glob) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) @@ -240,7 +244,8 @@ since it's bin on most platforms but Scr $ ./installenv/*/hg debuginstall || cat pip.log checking encoding (ascii)... checking Python executable (*) (glob) - checking Python version (2.*) (glob) + checking Python version (2.*) (glob) (no-py3 !) + checking Python version (3.*) (glob) (py3 !) checking Python lib (*)... (glob) checking Python security support (*) (glob) TLS 1.2 not supported by Python install; network connections lack modern security (?) ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5445: tests: followup on network related errors on Debian 9
lothiraldan created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY First, update test-clonebundles.t which was failing since the introduction of the `$EADDRNOTAVAIL$` common pattern. Also update two tests from https://phab.mercurial-scm.org/rHG8695fbe17f7cbe5187b72b48f01984ce8cada594 with a more compact condition line. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5445 AFFECTED FILES tests/test-clonebundles.t tests/test-http-bad-server.t tests/test-http-proxy.t CHANGE DETAILS diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t --- a/tests/test-http-proxy.t +++ b/tests/test-http-proxy.t @@ -90,8 +90,7 @@ misconfigured hosts) $ http_proxy=localhost:$HGPORT2 hg clone --config http_proxy.always=True http://localhost:$HGPORT/ f - abort: error: (Connection refused|Protocol not supported|.* actively refused it) (re) (?) - abort: error: $EADDRNOTAVAIL$ (?) + abort: error: (Connection refused|Protocol not supported|.* actively refused it|\$EADDRNOTAVAIL\$) (re) [255] do not use the proxy if it is in the no list diff --git a/tests/test-http-bad-server.t b/tests/test-http-bad-server.t --- a/tests/test-http-bad-server.t +++ b/tests/test-http-bad-server.t @@ -38,8 +38,7 @@ $ cat hg.pid > $DAEMON_PIDS $ hg clone http://localhost:$HGPORT/ clone - abort: error: $ECONNRESET$ (?) - abort: error: $EADDRNOTAVAIL$ (?) + abort: error: (\$ECONNRESET\$|\$EADDRNOTAVAIL\$) (re) [255] (The server exits on its own, but there is a race between that and starting a new server. diff --git a/tests/test-clonebundles.t b/tests/test-clonebundles.t --- a/tests/test-clonebundles.t +++ b/tests/test-clonebundles.t @@ -64,7 +64,7 @@ $ echo "http://localhost:$HGPORT1/bundle.hg; > server/.hg/clonebundles.manifest $ hg clone http://localhost:$HGPORT server-not-runner applying clone bundle from http://localhost:$HGPORT1/bundle.hg - error fetching bundle: (.* refused.*|Protocol not supported|(.* )?Cannot assign requested address) (re) + error fetching bundle: (.* refused.*|Protocol not supported|(.* )?\$EADDRNOTAVAIL\$) (re) abort: error applying bundle (if this error persists, consider contacting the server operator or disable clone bundles via "--config ui.clonebundles=false") [255] To: lothiraldan, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 3 STABLE] context: reimplement memfilectx.cmp()
On Sun, 16 Dec 2018 16:20:12 +0300, Pulkit Goyal wrote: > On Sun, Dec 16, 2018 at 11:27 AM Yuya Nishihara wrote: > > # HG changeset patch > > # User Yuya Nishihara > > # Date 1544947726 -32400 > > # Sun Dec 16 17:08:46 2018 +0900 > > # Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224 > > # Parent f1a69099327b6c3d92d2541fe8d40f8fe37a546e > > context: reimplement memfilectx.cmp() > > > > If I added a sanity check to basefilectx, test-context.py exploded. This > > patch copies the naive implementation from overlayworkingfilectx. > > > > Did you mean the whole series is for stable or just this patch? 1 for stable, and the others for default (once merged.) I didn't tried, but memfilectx.cmp() would crash if the other fctx had data of the same size. > And how did > you managed to put the STABLE flag on just one email and not rest? I want > to learn that trick. As I'm a templater guru, I just hacked it. --config patchbomb.flagtemplate='{ifeq(node|short, "", "STABLE")}' Not lovely. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 3 STABLE] context: reimplement memfilectx.cmp()
On Sun, Dec 16, 2018 at 11:27 AM Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara > # Date 1544947726 -32400 > # Sun Dec 16 17:08:46 2018 +0900 > # Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224 > # Parent f1a69099327b6c3d92d2541fe8d40f8fe37a546e > context: reimplement memfilectx.cmp() > > If I added a sanity check to basefilectx, test-context.py exploded. This > patch copies the naive implementation from overlayworkingfilectx. > Did you mean the whole series is for stable or just this patch? And how did you managed to put the STABLE flag on just one email and not rest? I want to learn that trick. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: [PATCH 1 of 2] py3: use forcebytestr() to stringify hook exception
On Sun, Dec 16, 2018 at 12:03 PM Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara > # Date 1544950397 -32400 > # Sun Dec 16 17:53:17 2018 +0900 > # Node ID 8c8fcb385c46890e1dc5d00ce3ced360974cecef > # Parent 7654291091cf35aade1d8e628def25a2fc3b567a > py3: use forcebytestr() to stringify hook exception > > This fixes test-narrow-exchange.t. > Queued the series, many many thanks! ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
mercurial@40950: 10 new changesets
10 new changesets in mercurial: https://www.mercurial-scm.org/repo/hg/rev/db6cace18765 changeset: 40941:db6cace18765 parent: 40936:e06719b7544d user:Georges Racinet date:Thu Dec 13 17:10:03 2018 +0100 summary: perfdiscovery: benching findcommonheads() https://www.mercurial-scm.org/repo/hg/rev/e48fdeb08c77 changeset: 40942:e48fdeb08c77 user:Yuya Nishihara date:Fri Dec 14 21:19:19 2018 +0900 summary: py3: fix bad escapes of sub() replacement pattern in test-template-basic.t https://www.mercurial-scm.org/repo/hg/rev/205c639ce27d changeset: 40943:205c639ce27d user:Pulkit Goyal date:Fri Dec 14 19:10:46 2018 +0300 summary: py3: whitelist another passing test caught by buildbot https://www.mercurial-scm.org/repo/hg/rev/789515904b03 changeset: 40944:789515904b03 user:Pulkit Goyal date:Fri Dec 14 19:12:45 2018 +0300 summary: py3: use '%d' for integers instead of '%s' https://www.mercurial-scm.org/repo/hg/rev/ebc471ce9fad changeset: 40945:ebc471ce9fad user:Pulkit Goyal date:Fri Dec 14 19:21:28 2018 +0300 summary: py3: add a missing b'' prefix in contrib/perf.py https://www.mercurial-scm.org/repo/hg/rev/5fd63bca43a4 changeset: 40946:5fd63bca43a4 user:Pulkit Goyal date:Fri Dec 14 19:30:20 2018 +0300 summary: py3: use pycompat.bytechr() instead of chr() in test-fastannotate-revmap.py https://www.mercurial-scm.org/repo/hg/rev/9e462fb88f79 changeset: 40947:9e462fb88f79 user:Augie Fackler date:Fri Dec 14 11:37:50 2018 -0500 summary: match: fix doctest to use bytes instead of str https://www.mercurial-scm.org/repo/hg/rev/a314eafd7c8d changeset: 40948:a314eafd7c8d user:Augie Fackler date:Fri Dec 14 12:00:38 2018 -0500 summary: perf: add two more missing b prefixes for Python 3 https://www.mercurial-scm.org/repo/hg/rev/f732889abe0e changeset: 40949:f732889abe0e user:Augie Fackler date:Fri Dec 14 12:01:47 2018 -0500 summary: error: implement __str__ on RevlogError to fix some output defects on Py3 https://www.mercurial-scm.org/repo/hg/rev/52fbf8a9907c changeset: 40950:52fbf8a9907c bookmark:@ tag: tip user:Pulkit Goyal date:Fri Dec 14 21:00:33 2018 +0300 summary: py3: add a b'' prefix in tests/test-remotefilelog-pull-noshallow.t -- Repository URL: https://www.mercurial-scm.org/repo/hg ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 2] py3: unimplement RevlogError.__str__()
# HG changeset patch # User Yuya Nishihara # Date 1544950508 -32400 # Sun Dec 16 17:55:08 2018 +0900 # Node ID 12253a8199a0158bb2aa53ef08e8b10ec330e24c # Parent 8c8fcb385c46890e1dc5d00ce3ced360974cecef py3: unimplement RevlogError.__str__() On Python 2, str(exc) would crash if __str__() returned a unicode containing non-ASCII characters. diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -44,14 +44,6 @@ class StorageError(Hint, Exception): class RevlogError(StorageError): __bytes__ = _tobytes -def __str__(self): -# avoid cycle, and directly implement unimethod for this -# __str__ to allow delaying the import of encoding until -# someone actually wants the __str__ of a RevlogError (which -# should be very rare). -from . import encoding -return encoding.unifromlocal(_tobytes(self)) - class FilteredIndexError(IndexError): __bytes__ = _tobytes ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 2] py3: use forcebytestr() to stringify hook exception
# HG changeset patch # User Yuya Nishihara # Date 1544950397 -32400 # Sun Dec 16 17:53:17 2018 +0900 # Node ID 8c8fcb385c46890e1dc5d00ce3ced360974cecef # Parent 7654291091cf35aade1d8e628def25a2fc3b567a py3: use forcebytestr() to stringify hook exception This fixes test-narrow-exchange.t. diff --git a/mercurial/hook.py b/mercurial/hook.py --- a/mercurial/hook.py +++ b/mercurial/hook.py @@ -102,7 +102,7 @@ def pythonhook(ui, repo, htype, hname, f (hname, exc.args[0])) else: ui.warn(_('error: %s hook raised an exception: ' - '%s\n') % (hname, encoding.strtolocal(str(exc + '%s\n') % (hname, stringutil.forcebytestr(exc))) if throw: raise if not ui.tracebackflag: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 5 of 5] extensions: use ui.log() interface to provide detailed loading information
# HG changeset patch # User Yuya Nishihara # Date 1544858909 -32400 # Sat Dec 15 16:28:29 2018 +0900 # Node ID 181620a4c6fd6e9cd422e69ce0e7a07d6cf6c136 # Parent 851dd18b181c113977b6b9bd903e9791a196460f extensions: use ui.log() interface to provide detailed loading information The output format changes and the messages will be sent to stderr instead of stdout, but I don't think that matters. diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -121,13 +121,12 @@ def _importext(name, path=None, reportfu return mod def _reportimporterror(ui, err, failed, next): -# note: this ui.debug happens before --debug is processed, +# note: this ui.log happens before --debug is processed, # Use --config ui.debug=1 to see them. -if ui.configbool('devel', 'debug.extensions'): -ui.debug('debug.extensions: - could not import %s (%s): trying %s\n' - % (failed, stringutil.forcebytestr(err), next)) -if ui.debugflag: -ui.traceback() +ui.log(b'extension', b'- could not import %s (%s): trying %s\n', + failed, stringutil.forcebytestr(err), next) +if ui.debugflag and ui.configbool('devel', 'debug.extensions'): +ui.traceback() def _rejectunicode(name, xs): if isinstance(xs, (list, set, tuple)): @@ -166,7 +165,7 @@ def _validatetables(ui, mod): _rejectunicode(t, o._table) _validatecmdtable(ui, getattr(mod, 'cmdtable', {})) -def load(ui, name, path, log=lambda *a: None, loadingtime=None): +def load(ui, name, path, loadingtime=None): if name.startswith('hgext.') or name.startswith('hgext/'): shortname = name[6:] else: @@ -175,11 +174,11 @@ def load(ui, name, path, log=lambda *a: return None if shortname in _extensions: return _extensions[shortname] -log(' - loading extension: %s\n', shortname) +ui.log(b'extension', b' - loading extension: %s\n', shortname) _extensions[shortname] = None with util.timedcm('load extension %s', shortname) as stats: mod = _importext(name, path, bind(_reportimporterror, ui)) -log(' > %s extension loaded in %s\n', shortname, stats) +ui.log(b'extension', b' > %s extension loaded in %s\n', shortname, stats) if loadingtime is not None: loadingtime[shortname] += stats.elapsed @@ -193,16 +192,17 @@ def load(ui, name, path, log=lambda *a: 'of Mercurial (current: %s); disabling)\n') ui.warn(msg % (shortname, minver, util.version())) return -log('- validating extension tables: %s\n', shortname) +ui.log(b'extension', b'- validating extension tables: %s\n', shortname) _validatetables(ui, mod) _extensions[shortname] = mod _order.append(shortname) -log('- invoking registered callbacks: %s\n', shortname) +ui.log(b'extension', b'- invoking registered callbacks: %s\n', + shortname) with util.timedcm('callbacks extension %s', shortname) as stats: for fn in _aftercallbacks.get(shortname, []): fn(loaded=True) -log('> callbacks completed in %s\n', stats) +ui.log(b'extension', b'> callbacks completed in %s\n', stats) return mod def _runuisetup(name, ui): @@ -235,28 +235,25 @@ def _runextsetup(name, ui): return True def loadall(ui, whitelist=None): -if ui.configbool('devel', 'debug.extensions'): -log = lambda msg, *values: ui.debug('debug.extensions: ', -msg % values, label='debug.extensions') -else: -log = lambda *a, **kw: None loadingtime = collections.defaultdict(int) result = ui.configitems("extensions") if whitelist is not None: result = [(k, v) for (k, v) in result if k in whitelist] newindex = len(_order) -log('loading %sextensions\n', 'additional ' if newindex else '') -log('- processing %d entries\n', len(result)) +ui.log(b'extension', b'loading %sextensions\n', + 'additional ' if newindex else '') +ui.log(b'extension', b'- processing %d entries\n', len(result)) with util.timedcm('load all extensions') as stats: for (name, path) in result: if path: if path[0:1] == '!': if name not in _disabledextensions: -log(' - skipping disabled extension: %s\n', name) +ui.log(b'extension', + b' - skipping disabled extension: %s\n', name) _disabledextensions[name] = path[1:] continue try: -load(ui, name, path, log, loadingtime) +load(ui, name, path, loadingtime) except Exception as inst: msg = stringutil.forcebytestr(inst) if path: @@ -269,8 +266,8 @@ def loadall(ui, whitelist=None):
[PATCH 4 of 5] mq: implement log() on dummyui
# HG changeset patch # User Yuya Nishihara # Date 1544860324 -32400 # Sat Dec 15 16:52:04 2018 +0900 # Node ID 851dd18b181c113977b6b9bd903e9791a196460f # Parent 85b2948f95b7916920f9af6f556a9ef0c36dee49 mq: implement log() on dummyui Otherwise ui.log() in extensions.py would explode. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -139,6 +139,8 @@ except KeyError: class dummyui(object): def debug(self, msg): pass +def log(self, event, msgfmt, *msgargs, **opts): +pass stripext = extensions.load(dummyui(), 'strip', '') strip = stripext.strip ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 5] ui: install logger that sends debug.extensions messages to stderr
# HG changeset patch # User Yuya Nishihara # Date 1544858648 -32400 # Sat Dec 15 16:24:08 2018 +0900 # Node ID 85b2948f95b7916920f9af6f556a9ef0c36dee49 # Parent 51f6fb41be9b7b16157f5fc3a421b04c037b455e ui: install logger that sends debug.extensions messages to stderr This will replace the custom log function introduced at d58958676b3c "extensions: add detailed loading information." diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -30,6 +30,7 @@ from . import ( encoding, error, formatter, +loggingutil, progress, pycompat, rcutil, @@ -490,6 +491,14 @@ class ui(object): self._trustusers.update(self.configlist('trusted', 'users')) self._trustgroups.update(self.configlist('trusted', 'groups')) +if section in (None, b'devel', b'ui') and self.debugflag: +tracked = set() +if self.configbool(b'devel', b'debug.extensions'): +tracked.add(b'extension') +if tracked: +logger = loggingutil.fileobjectlogger(self._ferr, tracked) +self.setlogger(b'debug', logger) + def backupconfig(self, section, item): return (self._ocfg.backup(section, item), self._tcfg.backup(section, item), ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 5] blackbox: resurrect recursion guard
# HG changeset patch # User Yuya Nishihara # Date 1544868342 -32400 # Sat Dec 15 19:05:42 2018 +0900 # Node ID 51f6fb41be9b7b16157f5fc3a421b04c037b455e # Parent f52cf621f392643960ac3cb5ff7bb17059bd040a blackbox: resurrect recursion guard If I added ui.log() to hg.repository() function, test-merge-subrepos.t exploded. The problem is that the blackbox may create new repository instance while logging is active, and the created repository owns its new ui derived from the baseui, not from the ui which is processing the active logging. I tried to work around the issue in ui.log(), but that turned out to be not easy. We shouldn't globally lock the ui.log() since there may be more than one active repo/ui instances in threaded environment. We could store the logging state in thread-local storage, but that seems unnecessarily complex. So this patch reintroduces the _inlog flag to per-repository logger instances. diff --git a/hgext/blackbox.py b/hgext/blackbox.py --- a/hgext/blackbox.py +++ b/hgext/blackbox.py @@ -96,11 +96,24 @@ class blackboxlogger(object): self._trackedevents = set(ui.configlist('blackbox', 'track')) self._maxfiles = ui.configint('blackbox', 'maxfiles') self._maxsize = ui.configbytes('blackbox', 'maxsize') +self._inlog = False def tracked(self, event): return b'*' in self._trackedevents or event in self._trackedevents def log(self, ui, event, msg, opts): +# self._log() -> ctx.dirty() may create new subrepo instance, which +# ui is derived from baseui. So the recursion guard in ui.log() +# doesn't work as it's local to the ui instance. +if self._inlog: +return +self._inlog = True +try: +self._log(ui, event, msg, opts) +finally: +self._inlog = False + +def _log(self, ui, event, msg, opts): default = ui.configdate('devel', 'default-date') date = dateutil.datestr(default, ui.config('blackbox', 'date-format')) user = procutil.getuser() ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 5] tests: filter out uninteresting log events
# HG changeset patch # User Yuya Nishihara # Date 1544863934 -32400 # Sat Dec 15 17:52:14 2018 +0900 # Node ID f52cf621f392643960ac3cb5ff7bb17059bd040a # Parent 9143ecd26b985bc6a8d4d2dad5d30f2de0a2d3a7 tests: filter out uninteresting log events This helps adding more log()s without updating the tests. diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -22,6 +22,9 @@ setup > [alias] > confuse = log --limit 3 > so-confusing = confuse --style compact + > [blackbox] + > track = backupbundle, branchcache, command, commandalias, commandexception, + > commandfinish, debug, exthook, incoming, pythonhook, tagscache > EOF $ hg init blackboxtest diff --git a/tests/test-devel-warnings.t b/tests/test-devel-warnings.t --- a/tests/test-devel-warnings.t +++ b/tests/test-devel-warnings.t @@ -83,6 +83,8 @@ > blackbox= > [devel] > all-warnings=1 + > [blackbox] + > track = command, commandexception, commandfinish, develwarn > EOF $ hg init lock-checker diff --git a/tests/test-merge-subrepos.t b/tests/test-merge-subrepos.t --- a/tests/test-merge-subrepos.t +++ b/tests/test-merge-subrepos.t @@ -57,7 +57,8 @@ Test that dirty is consistent through su A deleted subrepo file is flagged as dirty, like the top level repo - $ hg id --config extensions.blackbox= --config blackbox.dirty=True + $ hg id --config extensions.blackbox= --config blackbox.dirty=True \ + > --config blackbox.track='command commandfinish' 9bfe45a197d7+ tip $ cat .hg/blackbox.log * @9bfe45a197d7b0ab09bf287729dd57e9619c9da5+ (*)> serve --cmdserver chgunix * (glob) (chg !) diff --git a/tests/test-obsolete-tag-cache.t b/tests/test-obsolete-tag-cache.t --- a/tests/test-obsolete-tag-cache.t +++ b/tests/test-obsolete-tag-cache.t @@ -4,6 +4,9 @@ > rebase= > mock=$TESTDIR/mockblackbox.py > + > [blackbox] + > track = command, commandfinish, tagscache + > > [experimental] > evolution.createmarkers=True > EOF diff --git a/tests/test-setdiscovery.t b/tests/test-setdiscovery.t --- a/tests/test-setdiscovery.t +++ b/tests/test-setdiscovery.t @@ -543,14 +543,14 @@ fixed in 86c35b7ae300: > unrandomsample = $TESTTMP/unrandomsample.py > EOF - $ hg -R r1 outgoing r2 -T'{rev} ' --config extensions.blackbox= + $ hg -R r1 outgoing r2 -T'{rev} ' --config extensions.blackbox= \ + > --config blackbox.track='command commandfinish discovery' comparing with r2 searching for changes 101 102 103 104 105 106 107 108 109 110 (no-eol) - $ hg -R r1 --config extensions.blackbox= blackbox + $ hg -R r1 --config extensions.blackbox= blackbox --config blackbox.track= * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> serve --cmdserver chgunix * (glob) (chg !) * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> -R r1 outgoing r2 *-T{rev} * --config *extensions.blackbox=* (glob) * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> found 101 common and 1 unknown server heads, 2 roundtrips in *.s (glob) * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> -R r1 outgoing r2 *-T{rev} * --config *extensions.blackbox=* exited 0 after *.?? seconds (glob) - * @5d0b986a083e0d91f116de4691e2aaa54d5bbec0 (*)> -R r1 --config *extensions.blackbox=* blackbox (glob) $ cd .. diff --git a/tests/test-tags.t b/tests/test-tags.t --- a/tests/test-tags.t +++ b/tests/test-tags.t @@ -4,6 +4,8 @@ setup > [extensions] > blackbox= > mock=$TESTDIR/mockblackbox.py + > [blackbox] + > track = command, commandfinish, tagscache > EOF Helper functions: ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 3 of 3] context: error out if basefilectx.cmp() is called without self._filenode
# HG changeset patch # User Yuya Nishihara # Date 1544945491 -32400 # Sun Dec 16 16:31:31 2018 +0900 # Node ID 9143ecd26b985bc6a8d4d2dad5d30f2de0a2d3a7 # Parent 913fdd3fccc6c99def4b1ac8cd60abba1f7aa81d context: error out if basefilectx.cmp() is called without self._filenode The base implementation can't handle such cases because the filelog has no knowledge about the working directory. Loading self._filenode should have no extra cost since self.size() would load it anyway. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -702,6 +702,10 @@ class basefilectx(object): if fctx._customcmp: return fctx.cmp(self) +if self._filenode is None: +raise error.ProgrammingError( +'filectx.cmp() must be reimplemented if not backed by revlog') + if fctx._filenode is None: if self._repo._encodefilterpats: # can't rely on size() because wdir content may be decoded ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 2 of 3] context: collapse complex condition to see if filelog have to be compared
# HG changeset patch # User Yuya Nishihara # Date 1544945085 -32400 # Sun Dec 16 16:24:45 2018 +0900 # Node ID 913fdd3fccc6c99def4b1ac8cd60abba1f7aa81d # Parent 79dc95eb84b0f09a39fb396c65ec591f9f0de224 context: collapse complex condition to see if filelog have to be compared It's hard to read. I'd rather make the return statement duplicated. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -702,14 +702,20 @@ class basefilectx(object): if fctx._customcmp: return fctx.cmp(self) -if (fctx._filenode is None -and (self._repo._encodefilterpats - # if file data starts with '\1\n', empty metadata block is - # prepended, which adds 4 bytes to filelog.size(). - or self.size() - 4 == fctx.size()) -or self.size() == fctx.size()): +if fctx._filenode is None: +if self._repo._encodefilterpats: +# can't rely on size() because wdir content may be decoded +return self._filelog.cmp(self._filenode, fctx.data()) +if self.size() - 4 == fctx.size(): +# size() can match: +# if file data starts with '\1\n', empty metadata block is +# prepended, which adds 4 bytes to filelog.size(). +return self._filelog.cmp(self._filenode, fctx.data()) +if self.size() == fctx.size(): +# size() matches: need to compare content return self._filelog.cmp(self._filenode, fctx.data()) +# size() differs return True def _adjustlinkrev(self, srcrev, inclusive=False, stoprev=None): ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
[PATCH 1 of 3 STABLE] context: reimplement memfilectx.cmp()
# HG changeset patch # User Yuya Nishihara # Date 1544947726 -32400 # Sun Dec 16 17:08:46 2018 +0900 # Node ID 79dc95eb84b0f09a39fb396c65ec591f9f0de224 # Parent f1a69099327b6c3d92d2541fe8d40f8fe37a546e context: reimplement memfilectx.cmp() If I added a sanity check to basefilectx, test-context.py exploded. This patch copies the naive implementation from overlayworkingfilectx. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -2330,6 +2330,9 @@ class memfilectx(committablefilectx): if copied: self._copied = (copied, nullid) +def cmp(self, fctx): +return self.data() != fctx.data() + def data(self): return self._data ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D5409: remotefilelog: accepting a None node to cmp
yuja added a comment. I'm dropping this since I found a bug in memfilectx. That's probably why absorb crashed. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D5409 To: rdamazio, #hg-reviewers Cc: yuja, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Re: D5409: remotefilelog: accepting a None node to cmp
I'm dropping this since I found a bug in memfilectx. That's probably why absorb crashed. ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel