# HG changeset patch # User Raphaël Gomès # Date 2021-05-17 13:05:24 # Node ID bcafcd779d2e892dd72aba70c1d3bd7f4127c76b # Parent 33096e77598cb39ffa42d4cab8c6e3aa9c311256 # Parent 8be95673eb8a3422b895099650a08ef6cacafbde branching: merge stable into default diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml --- a/contrib/heptapod-ci.yml +++ b/contrib/heptapod-ci.yml @@ -125,3 +125,17 @@ test-py3-chg: PYTHON: python3 RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg" TEST_HGMODULEPOLICY: "c" + +check-pytype-py3: + extends: .runtests_template + when: manual + before_script: + - hg clone . /tmp/mercurial-ci/ --noupdate --config phases.publish=no + - hg -R /tmp/mercurial-ci/ update `hg log --rev '.' --template '{node}'` + - cd /tmp/mercurial-ci/ + - make local PYTHON=$PYTHON + - $PYTHON -m pip install --user -U pytype==2021.04.15 + variables: + RUNTEST_ARGS: " --allow-slow-tests tests/test-check-pytype.t" + PYTHON: python3 + TEST_HGMODULEPOLICY: "c" diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py --- a/hgext/convert/p4.py +++ b/hgext/convert/p4.py @@ -151,12 +151,10 @@ class p4_source(common.converter_source) views[sview] = cview # list of changes that affect our source files - p4changes = p4changes.keys() - p4changes.sort(key=int) + p4changes = sorted(p4changes.keys(), key=int) # list with depot pathnames, longest first - vieworder = views.keys() - vieworder.sort(key=len, reverse=True) + vieworder = sorted(views.keys(), key=len, reverse=True) # handle revision limiting startrev = self.ui.config(b'convert', b'p4.startrev') @@ -188,7 +186,7 @@ class p4_source(common.converter_source) else: shortdesc = b'**empty changelist description**' - t = b'%s %s' % (c.rev, repr(shortdesc)[1:-1]) + t = b'%s %s' % (c.rev, shortdesc) ui.status(stringutil.ellipsis(t, 80) + b'\n') files = [] diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -1054,7 +1054,7 @@ def clone( # as the only "bad" outcome would be some slowness. That potential # slowness already affect reader. with destrepo.lock(): - destrepo.updatecaches(full=True) + destrepo.updatecaches(full=b"post-clone") finally: release(srclock, destlock) if cleandir is not None: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -2727,6 +2727,11 @@ class localrepository(object): If 'full' is set, make sure all caches the function knows about have up-to-date data. Even the ones usually loaded more lazily. + + The `full` argument can take a special "post-clone" value. In this case + the cache warming is made after a clone and of the slower cache might + be skipped, namely the `.fnodetags` one. This argument is 5.8 specific + as we plan for a cleaner way to deal with this for 5.9. """ if tr is not None and tr.hookargs.get(b'source') == b'strip': # During strip, many caches are invalid but @@ -2754,8 +2759,9 @@ class localrepository(object): for ctx in self[b'.'].parents(): ctx.manifest() # accessing the manifest is enough - # accessing fnode cache warms the cache - tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs()) + if not full == b"post-clone": + # accessing fnode cache warms the cache + tagsmod.fnoderevs(self.ui, unfi, unfi.changelog.revs()) # accessing tags warm the cache self.tags() self.filtered(b'served').tags() diff --git a/mercurial/posix.py b/mercurial/posix.py --- a/mercurial/posix.py +++ b/mercurial/posix.py @@ -381,6 +381,10 @@ def getfstype(dirpath): return getattr(osutil, 'getfstype', lambda x: None)(dirpath) +def get_password(): + return encoding.strtolocal(getpass.getpass('')) + + def setbinary(fd): pass diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -11,7 +11,6 @@ import collections import contextlib import datetime import errno -import getpass import inspect import os import re @@ -1781,7 +1780,7 @@ class ui(object): raise EOFError return l.rstrip(b'\n') else: - return encoding.strtolocal(getpass.getpass('')) + return util.get_password() except EOFError: raise error.ResponseExpected() diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -107,6 +107,7 @@ copymode = platform.copymode expandglobs = platform.expandglobs getfsmountpoint = platform.getfsmountpoint getfstype = platform.getfstype +get_password = platform.get_password groupmembers = platform.groupmembers groupname = platform.groupname isexec = platform.isexec diff --git a/mercurial/windows.py b/mercurial/windows.py --- a/mercurial/windows.py +++ b/mercurial/windows.py @@ -194,6 +194,28 @@ def _isatty(fp): return False +def get_password(): + """Prompt for password with echo off, using Windows getch(). + + This shouldn't be called directly- use ``ui.getpass()`` instead, which + checks if the session is interactive first. + """ + pw = "" + while True: + c = msvcrt.getwch() + if c == '\r' or c == '\n': + break + if c == '\003': + raise KeyboardInterrupt + if c == '\b': + pw = pw[:-1] + else: + pw = pw + c + msvcrt.putwch('\r') + msvcrt.putwch('\n') + return encoding.strtolocal(pw) + + class winstdout(object): """Some files on Windows misbehave. diff --git a/tests/hghave.py b/tests/hghave.py --- a/tests/hghave.py +++ b/tests/hghave.py @@ -863,7 +863,10 @@ def has_py3(): @check("py3exe", "a Python 3.x interpreter is available") def has_python3exe(): - return matchoutput('python3 -V', br'^Python 3.(5|6|7|8|9)') + py = 'python3' + if os.name == 'nt': + py = 'py -3' + return matchoutput('%s -V' % py, br'^Python 3.(5|6|7|8|9)') @check("pure", "running with pure Python code") diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -262,7 +262,13 @@ def checkportisavailable(port): except socket.error as exc: if os.name == 'nt' and exc.errno == errno.WSAEACCES: return False - elif exc.errno not in ( + elif PYTHON3: + # TODO: make a proper exception handler after dropping py2. This + # works because socket.error is an alias for OSError on py3, + # which is also the baseclass of PermissionError. + if isinstance(exc, PermissionError): + return False + if exc.errno not in ( errno.EADDRINUSE, errno.EADDRNOTAVAIL, errno.EPROTONOSUPPORT, @@ -355,7 +361,8 @@ def parselistfiles(files, listtype, warn for line in f.readlines(): line = line.split(b'#', 1)[0].strip() if line: - entries[line] = filename + # Ensure path entries are compatible with os.path.relpath() + entries[os.path.normpath(line)] = filename f.close() return entries diff --git a/tests/test-check-pyflakes.t b/tests/test-check-pyflakes.t --- a/tests/test-check-pyflakes.t +++ b/tests/test-check-pyflakes.t @@ -23,4 +23,5 @@ run pyflakes on all tracked files ending mercurial/hgweb/server.py:*:* undefined name 'reload' (glob) (?) mercurial/util.py:*:* undefined name 'file' (glob) (?) mercurial/encoding.py:*:* undefined name 'localstr' (glob) (?) + tests/run-tests.py:*:* undefined name 'PermissionError' (glob) (?) diff --git a/tests/test-clone-uncompressed.t b/tests/test-clone-uncompressed.t --- a/tests/test-clone-uncompressed.t +++ b/tests/test-clone-uncompressed.t @@ -201,7 +201,6 @@ Basic clone branch2-served.hidden branch2-visible branch2-visible-hidden - hgtagsfnodes1 rbc-names-v1 rbc-revs-v1 tags2 diff --git a/tests/test-clone.t b/tests/test-clone.t --- a/tests/test-clone.t +++ b/tests/test-clone.t @@ -62,7 +62,6 @@ Ensure branchcache got copied over: branch2-served.hidden branch2-visible branch2-visible-hidden - hgtagsfnodes1 rbc-names-v1 rbc-revs-v1 tags2 @@ -142,7 +141,6 @@ Ensure branchcache got copied over: branch2-served.hidden branch2-visible branch2-visible-hidden - hgtagsfnodes1 rbc-names-v1 rbc-revs-v1 tags2 diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t --- a/tests/test-hardlinks.t +++ b/tests/test-hardlinks.t @@ -244,7 +244,6 @@ r4 has hardlinks in the working dir (not 2 r4/.hg/cache/branch2-served.hidden 2 r4/.hg/cache/branch2-visible 2 r4/.hg/cache/branch2-visible-hidden - 2 r4/.hg/cache/hgtagsfnodes1 2 r4/.hg/cache/rbc-names-v1 2 r4/.hg/cache/rbc-revs-v1 2 r4/.hg/cache/tags2 @@ -302,7 +301,6 @@ Update back to revision 12 in r4 should 2 r4/.hg/cache/branch2-served.hidden 2 r4/.hg/cache/branch2-visible 2 r4/.hg/cache/branch2-visible-hidden - 2 r4/.hg/cache/hgtagsfnodes1 2 r4/.hg/cache/rbc-names-v1 2 r4/.hg/cache/rbc-revs-v1 2 r4/.hg/cache/tags2 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 @@ -1116,15 +1116,17 @@ Skips with xml Missing skips or blacklisted skips don't count as executed: - $ echo test-failure.t > blacklist + $ mkdir tests + $ echo tests/test-failure.t > blacklist + $ cp test-failure.t tests $ rt --blacklist=blacklist --json\ - > test-failure.t test-bogus.t + > tests/test-failure.t tests/test-bogus.t running 2 tests using 1 parallel processes ss Skipped test-bogus.t: Doesn't exist Skipped test-failure.t: blacklisted # Ran 0 tests, 2 skipped, 0 failed. - $ cat report.json + $ cat tests/report.json testreport ={ "test-bogus.t": { "result": "skip" @@ -1133,6 +1135,8 @@ Missing skips or blacklisted skips don't "result": "skip" } } (no-eol) + $ rm -r tests + $ echo test-failure.t > blacklist Whitelist trumps blacklist $ echo test-failure.t > whitelist diff --git a/tests/test-share.t b/tests/test-share.t --- a/tests/test-share.t +++ b/tests/test-share.t @@ -68,7 +68,6 @@ Cloning a shared repo should pick up the branch2-served.hidden branch2-visible branch2-visible-hidden - hgtagsfnodes1 rbc-names-v1 rbc-revs-v1 tags2 diff --git a/tests/test-ssh.t b/tests/test-ssh.t --- a/tests/test-ssh.t +++ b/tests/test-ssh.t @@ -86,7 +86,7 @@ clone bookmarks via stream $ hg -R local-stream book mybook $ hg clone -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" --stream ssh://user@dummy/local-stream stream2 streaming all changes - 16 files to transfer, * of data (glob) + 15 files to transfer, * of data (glob) transferred * in * seconds (*) (glob) updating to branch default 2 files updated, 0 files merged, 0 files removed, 0 files unresolved diff --git a/tests/test-tags.t b/tests/test-tags.t --- a/tests/test-tags.t +++ b/tests/test-tags.t @@ -807,11 +807,11 @@ Cache should contain the head only, even $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1 tagsclient/.hg/cache/hgtagsfnodes1: size=96 - 0000: 96 ee 1d 73 00 00 00 00 00 00 00 00 00 00 00 00 |...s............| - 0010: 00 00 00 00 00 00 00 00 c4 da b0 c2 94 65 e1 c6 |.............e..| - 0020: 0d f7 f0 dd 32 04 ea 57 78 c8 97 97 79 fc d5 95 |....2..Wx...y...| - 0030: f6 3c c8 fe 94 65 e1 c6 0d f7 f0 dd 32 04 ea 57 |.<...e......2..W| - 0040: 78 c8 97 97 79 fc d5 95 40 f0 35 8c 19 e0 a7 d3 |x...y...@.5.....| + 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....| 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.| Running hg tags should produce tags2* file and not change cache @@ -837,11 +837,11 @@ Running hg tags should produce tags2* fi $ f --size --hexdump tagsclient/.hg/cache/hgtagsfnodes1 tagsclient/.hg/cache/hgtagsfnodes1: size=96 - 0000: 96 ee 1d 73 00 00 00 00 00 00 00 00 00 00 00 00 |...s............| - 0010: 00 00 00 00 00 00 00 00 c4 da b0 c2 94 65 e1 c6 |.............e..| - 0020: 0d f7 f0 dd 32 04 ea 57 78 c8 97 97 79 fc d5 95 |....2..Wx...y...| - 0030: f6 3c c8 fe 94 65 e1 c6 0d f7 f0 dd 32 04 ea 57 |.<...e......2..W| - 0040: 78 c8 97 97 79 fc d5 95 40 f0 35 8c 19 e0 a7 d3 |x...y...@.5.....| + 0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| + 0040: ff ff ff ff ff ff ff ff 40 f0 35 8c 19 e0 a7 d3 |........@.5.....| 0050: 8a 5c 6a 82 4d cf fb a5 87 d0 2f a3 1e 4f 2f 8a |.\j.M...../..O/.| Check that the bundle includes cache data diff --git a/tests/test-treemanifest.t b/tests/test-treemanifest.t --- a/tests/test-treemanifest.t +++ b/tests/test-treemanifest.t @@ -792,7 +792,7 @@ Stream clone with basicstore $ hg clone --config experimental.changegroup3=True --stream -U \ > http://localhost:$HGPORT1 stream-clone-basicstore streaming all changes - 29 files to transfer, * of data (glob) + 28 files to transfer, * of data (glob) transferred * in * seconds (*) (glob) $ hg -R stream-clone-basicstore verify checking changesets @@ -806,7 +806,7 @@ Stream clone with encodedstore $ hg clone --config experimental.changegroup3=True --stream -U \ > http://localhost:$HGPORT2 stream-clone-encodedstore streaming all changes - 29 files to transfer, * of data (glob) + 28 files to transfer, * of data (glob) transferred * in * seconds (*) (glob) $ hg -R stream-clone-encodedstore verify checking changesets