Mercurial > hg
view tests/test-encoding-align.t @ 47866:4162f6b40f2c stable
windows: degrade to py2 behavior when reading a non-symlink as a symlink
While waiting for the push to hg-committed in WSL to complete, I ran a
`phabimport` from Windows and got this traceback:
$ hg phabimport 11313
** Unknown exception encountered with possibly-broken third-party extension "mercurial_keyring" (version N/A)
** which supports versions unknown of Mercurial.
** Please disable "mercurial_keyring" and try your action again.
** If that fixes the bug please report it to https://foss.heptapod.net/mercurial/mercurial_keyring/issues
** Python 3.9.5 (default, May 6 2021, 17:29:31) [MSC v.1928 64 bit (AMD64)]
** Mercurial Distributed SCM (version 5.9rc1+hg32.0e2f5733563d)
** Extensions loaded: absorb, blackbox, evolve 10.3.3, extdiff, fastannotate, fix, mercurial_keyring, mq, phabblocker 20210126, phabricator, rebase, show, strip, topic 0.22.3
Traceback (most recent call last):
File "mercurial.lock", line 279, in _trylock
File "mercurial.vfs", line 202, in makelock
File "mercurial.util", line 2147, in makelock
FileExistsError: [WinError 183] Cannot create a file when that file already exists: b'hp-omen:78348' -> b'C:\\Users\\Matt\\hg/.hg/store/lock'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 24, in <module>
File "mercurial.dispatch", line 144, in run
File "mercurial.dispatch", line 250, in dispatch
File "mercurial.dispatch", line 294, in _rundispatch
File "mercurial.dispatch", line 470, in _runcatch
File "mercurial.dispatch", line 480, in _callcatch
File "mercurial.scmutil", line 153, in callcatch
File "mercurial.dispatch", line 460, in _runcatchfunc
File "mercurial.dispatch", line 1273, in _dispatch
File "mercurial.dispatch", line 918, in runcommand
File "mercurial.dispatch", line 1285, in _runcommand
File "mercurial.dispatch", line 1271, in <lambda>
File "mercurial.util", line 1886, in check
File "mercurial.util", line 1886, in check
File "hgext.mq", line 4239, in mqcommand
File "mercurial.util", line 1886, in check
File "mercurial.util", line 1886, in check
File "hgext.phabricator", line 314, in inner
File "hgext.phabricator", line 2222, in phabimport
File "hgext.phabricator", line 2123, in readpatch
File "hgext.phabricator", line 2199, in _write
File "mercurial.localrepo", line 2956, in lock
File "mercurial.localrepo", line 2918, in _lock
File "mercurial.lock", line 152, in trylock
File "mercurial.lock", line 283, in _trylock
File "mercurial.lock", line 314, in _readlock
File "mercurial.vfs", line 221, in readlock
File "mercurial.util", line 2163, in readlock
File "mercurial.windows", line 619, in readlink
ValueError: not a symbolic link
Both exceptions look accurate (the file exists, and the Windows side can't read
WSL side symlinks). I didn't try to reproduce this entirely within the Windows
side, but we can do better than a cryptic stacktrace. With this change, the
same scenario results in this abort:
abort: C:\Users\Matt\hg/.hg/store/lock: The file cannot be accessed by the system
When both the `push` and `phabimport` are done on the Windows side, it prints a
message about waiting for the lock, and successfully applies the patch after the
push completes.
I'm not sure if there's enough info to be able to convert the abort into the
wait scenario. As it stands now, we don't support symlinks on Windows, which
requires either a UAC Administrator level process or an opt-in in developer
mode, and there are several places where the new symlink on Windows support in
py3 was explicitly disabled in order to get tests to pass quicker.
Differential Revision: https://phab.mercurial-scm.org/D11333
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 22 Aug 2021 17:59:21 -0400 |
parents | 24bef6a99958 |
children |
line wrap: on
line source
Test alignment of multibyte characters $ HGENCODING=utf-8 $ export HGENCODING $ hg init t $ cd t $ "$PYTHON" << EOF > from mercurial import pycompat > # (byte, width) = (6, 4) > s = b"\xe7\x9f\xad\xe5\x90\x8d" > # (byte, width) = (7, 7): odd width is good for alignment test > m = b"MIDDLE_" > # (byte, width) = (18, 12) > l = b"\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d" > f = open('s', 'wb'); f.write(s); f.close() > f = open('m', 'wb'); f.write(m); f.close() > f = open('l', 'wb'); f.write(l); f.close() > # instant extension to show list of options > f = open('showoptlist.py', 'wb'); f.write(b"""# encoding: utf-8 > from mercurial import registrar > cmdtable = {} > command = registrar.command(cmdtable) > > @command(b'showoptlist', > [(b's', b'opt1', b'', b'short width' + (b' ' +%(s)s) * 8, %(s)s), > (b'm', b'opt2', b'', b'middle width' + (b' ' + %(m)s) * 8, %(m)s), > (b'l', b'opt3', b'', b'long width' + (b' ' + %(l)s) * 8, %(l)s)], > b'') > def showoptlist(ui, repo, *pats, **opts): > '''dummy command to show option descriptions''' > return 0 > """ % {b's': pycompat.byterepr(s), > b'm': pycompat.byterepr(m), > b'l': pycompat.byterepr(l), > }) > f.close() > EOF $ S=`cat s` $ M=`cat m` $ L=`cat l` alignment of option descriptions in help $ cat <<EOF > .hg/hgrc > [extensions] > ja_ext = `pwd`/showoptlist.py > EOF check alignment of option descriptions in help $ hg help showoptlist hg showoptlist dummy command to show option descriptions options: -s --opt1 \xe7\x9f\xad\xe5\x90\x8d short width \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d \xe7\x9f\xad\xe5\x90\x8d (esc) -m --opt2 MIDDLE_ middle width MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ MIDDLE_ -l --opt3 \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d long width \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) (some details hidden, use --verbose to show complete help) $ rm -f s; touch s $ rm -f m; touch m $ rm -f l; touch l add files $ cp s $S $ hg add $S $ cp m $M $ hg add $M $ cp l $L $ hg add $L commit(1) $ echo 'first line(1)' >> s; cp s $S $ echo 'first line(2)' >> m; cp m $M $ echo 'first line(3)' >> l; cp l $L $ hg commit -m 'first commit' -u $S commit(2) $ echo 'second line(1)' >> s; cp s $S $ echo 'second line(2)' >> m; cp m $M $ echo 'second line(3)' >> l; cp l $L $ hg commit -m 'second commit' -u $M commit(3) $ echo 'third line(1)' >> s; cp s $S $ echo 'third line(2)' >> m; cp m $M $ echo 'third line(3)' >> l; cp l $L $ hg commit -m 'third commit' -u $L check alignment of user names in annotate $ hg annotate -u $M \xe7\x9f\xad\xe5\x90\x8d: first line(2) (esc) MIDDLE_: second line(2) \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d: third line(2) (esc) check alignment of filenames in diffstat $ hg diff -c tip --stat MIDDLE_ | 1 + \xe7\x9f\xad\xe5\x90\x8d | 1 + (esc) \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d | 1 + (esc) 3 files changed, 3 insertions(+), 0 deletions(-) add branches/tags $ hg branch $S marked working directory as branch \xe7\x9f\xad\xe5\x90\x8d (esc) (branches are permanent and global, did you want a bookmark?) $ hg tag $S $ hg book -f $S $ hg branch $M marked working directory as branch MIDDLE_ $ hg tag $M $ hg book -f $M $ hg branch $L marked working directory as branch \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d (esc) $ hg tag $L $ hg book -f $L check alignment of branches $ hg branches \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc) MIDDLE_ 4:9259be597f19 (inactive) \xe7\x9f\xad\xe5\x90\x8d 3:b06c5b6def9e (inactive) (esc) default 2:64a70663cee8 (inactive) check alignment of tags $ hg tags tip 5:d745ff46155b \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 4:9259be597f19 (esc) MIDDLE_ 3:b06c5b6def9e \xe7\x9f\xad\xe5\x90\x8d 2:64a70663cee8 (esc) check alignment of bookmarks $ hg book MIDDLE_ 5:d745ff46155b \xe7\x9f\xad\xe5\x90\x8d 4:9259be597f19 (esc) * \xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d 5:d745ff46155b (esc)