2019-12-10 02:24:31 +03:00
#chg-compatible
2014-08-06 20:53:08 +04:00
#require test-repo
2014-05-05 22:42:58 +04:00
2016-05-11 07:49:27 +03:00
$ . " $ TESTDIR / helpers - testrepo . sh "
2011-11-23 05:50:58 +04:00
$ cd "$TESTDIR" / ..
2013-07-06 23:47:56 +04:00
New errors are not allowed . Warnings are strongly discouraged .
2014-01-08 01:29:15 +04:00
( The writing "no-che?k-code" is for not skipping this file when checking . )
2013-07-06 23:47:56 +04:00
2020-05-07 19:05:16 +03:00
$ testrepohg files . | egrep - v "^(edenscm/hgext/extlib/pywatchman|lib/cdatapack|lib/third-party|edenscm/mercurial/thirdparty|fb|newdoc|tests/gpg|tests/bundles|edenscm/mercurial/templates/static|i18n|slides|tests/hggit/latin-1-encoding|.*\\.(bin|bindag|hg|pdf|jpg)$)" \
2018-07-03 21:20:37 +03:00
> | sed 's-\\-/-g' > $ TESTTMP / files . txt
2020-05-07 19:05:16 +03:00
$ NPROC = `$PYTHON -c 'import multiprocessing; print(multiprocessing.cpu_count())'`
$ cat $ TESTTMP /files.txt | PYTHONPATH= xargs -n64 -P $NPROC contrib/c heck - code . py - - warnings - - per - file = 0 | sort
2019-01-29 05:29:48 +03:00
Skipping edenscm /hgext/ extlib /cstore/ datapackstore . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ datapackstore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ datastore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ deltachain . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ deltachain . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ key . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/m atch . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ py - cstore . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ py - datapackstore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ py - structs . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ py - treemanifest . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ pythondatastore . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ pythondatastore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ pythonkeyiterator . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ pythonutil . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ pythonutil . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/s tore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ uniondatapackstore . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /cstore/ uniondatapackstore . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_entry . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_entry . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_fetcher . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_fetcher . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_ptr . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/m anifest_ptr . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/ treemanifest . cpp it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ extlib /ctreemanifest/ treemanifest . h it has no - che ? k - code ( glob )
Skipping edenscm /hgext/g lobalrevs . py it has no - che ? k - code ( glob )
Skipping edenscm /hgext/ hgsql . py it has no - che ? k - code ( glob )
2019-11-07 03:10:29 +03:00
Skipping edenscm /mercurial/comm ands / eden . py it has no - che ? k - code ( glob )
2019-01-29 05:29:48 +03:00
Skipping edenscm /mercurial/ httpclient / __init__ . py it has no - che ? k - code ( glob )
Skipping edenscm /mercurial/ httpclient / _readers . py it has no - che ? k - code ( glob )
Skipping edenscm /mercurial/s tatprof . py it has no - che ? k - code ( glob )
2018-01-09 02:08:18 +03:00
Skipping lib /clib/ buffer . c it has no - che ? k - code ( glob )
Skipping lib /clib/ buffer . h it has no - che ? k - code ( glob )
Skipping lib /clib/co nvert . h it has no - che ? k - code ( glob )
Skipping lib /clib/ null_test . c it has no - che ? k - code ( glob )
2018-04-10 11:06:47 +03:00
Skipping lib /clib/ portability / dirent . h it has no - che ? k - code ( glob )
2018-01-09 02:08:18 +03:00
Skipping lib /clib/ portability / inet . h it has no - che ? k - code ( glob )
2018-02-13 18:47:38 +03:00
Skipping lib /clib/ portability / mman . h it has no - che ? k - code ( glob )
2018-01-09 02:08:18 +03:00
Skipping lib /clib/ portability / portability . h it has no - che ? k - code ( glob )
Skipping lib /clib/ portability / unistd . h it has no - che ? k - code ( glob )
Skipping lib /clib/s ha1 . h it has no - che ? k - code ( glob )
2017-04-14 08:19:28 +03:00
Skipping tests / badserverext . py it has no - che ? k - code ( glob )
2018-01-09 15:45:57 +03:00
Skipping tests / conduithttp . py it has no - che ? k - code ( glob )
2018-01-09 05:58:08 +03:00
Skipping tests / test - fb - hgext - remotefilelog - bad - configs . t it has no - che ? k - code ( glob )
2018-01-04 21:54:02 +03:00
Skipping tests / test - hgsql - encoding . t it has no - che ? k - code ( glob )
Skipping tests / test - hgsql - race - conditions . t it has no - che ? k - code ( glob )
rust: reinvent Python's threading.Condition
Summary:
Python 2's `threading.Condition` and `threading.RLock` implementation are in
pure Python. Part of `RLock.acquire` looks like (simplified):
def acquire(self, blocking=1):
me = _get_ident()
if self.__owner == me:
self.__count = self.__count + 1
return 1
rc = self.__block.acquire(blocking)
########## Here #########
if rc:
self.__owner = me
self.__count = 1
return rc
If an interruption (ex. SIGTERM) happens at "HERE". The lock would be in an
inconsistent state. And if some `finally` block, or `__exit__` in a context
manager tries to release the lock, it could deadlock.
Similar problems also apply to `release`, `_acquire_restore`, and
`_release_save`. Basically, `self.__owner`, `self.__count` and `self.__block`
(i.e. the real lock) cannot be guaranteed in a consistent state in pure Python
world, because interruption can happen before any Python bytecode instruction
(but not inside a single Python bytecode instruction).
Therefore the interruption-safe implementation cannot be done in pure Python.
Use Rust to rescue.
The added test `streetest-condint.py` has a high chance to reproduce the
deadlock issue with Python 2.
Python 3 has a native RLock implementation, which makes things better. The
"Condition" implementation is not native and I haven't checked whether it
is sound or not.
Unfortunately, as part of testing, I hit https://bugs.python.org/issue29988 and
confirmed from the Rust world. That is, `__exit__` is not guarnateed called (!!)
That means native implementations still have a chance to be wrong, and there is
no easy way to fix it. `streetest-condint.py` was then updated to expose the
issue more easily.
The implementation is better than Python 2 stdlib, though.
Reviewed By: markbt
Differential Revision: D10517920
fbshipit-source-id: 394c9050c512ce2a0f9743c28ccfafe0f560141a
2018-10-25 23:07:11 +03:00
Skipping tests / test - rustthreading . py it has no - che ? k - code ( glob )
2019-12-03 16:54:17 +03:00
edenscm /hgext/ extlib /phabricator/g raphql . py: * : use foobar , not foo_bar naming - - > ca_bundle = repo . ui . configpath ( "web" , "cacerts" ) ( glob )
edenscm /hgext/ extlib /phabricator/g raphql . py: * : use foobar , not foo_bar naming - - > def scmquery_log ( ( glob )
2020-03-06 02:03:18 +03:00
edenscm /hgext/ hggit / git_handler . py: * : use foobar , not foo_bar naming - - > git_renames = { } ( glob )
2019-07-19 21:41:33 +03:00
tests / run - tests . py: * : don ' t use camelcase in identifiers - - > self . testsSkipped = 0 ( glob )
2020-05-07 19:05:16 +03:00
tests / test - absorb - t . py:325: always assign an opened file to a variable , and close it afterwards - - > open ( f , "ab" ) . write ( line . encode ( "utf-8" ) )
tests / test - absorb - t . py:40: always assign an opened file to a variable , and close it afterwards - - > content = open ( path , "rb" ) . read ( ) . replace ( a , b )
tests / test - absorb - t . py:41: always assign an opened file to a variable , and close it afterwards - - > open ( path , "wb" ) . write ( content )
tests / test - absorb - t . py:458: always assign an opened file to a variable , and close it afterwards - - > open ( "c" , "wb" ) . write ( bytearray ( [ 0 , 1 , 2 , 10 ] ) )
tests / test - absorb - t . py:57: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "ab" ) . write ( b "%s\n" % i )
tests / test - adding - invalid - utf8 - t . py:20: always assign an opened file to a variable , and close it afterwards - - > open ( "\x9d\xc8\xac\xde\xa1\xee" , "wb" ) . write ( "test" )
tests / test - amend - restack - t . py:17: always assign an opened file to a variable , and close it afterwards - - > open ( name , "wb" ) . write ( b "%s\n" % name . encode ( "utf8" ) )
tests / test - check - win32 - signature . py:13: always assign an opened file to a variable , and close it afterwards - - > content = open ( path ) . read ( )
tests / test - command - template - t . py:2011: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "wb" ) . write ( s )
tests / test - command - template - t . py:3257: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "wb" ) . write ( "%s\n" % i )
tests / test - command - template - t . py:3914: always assign an opened file to a variable , and close it afterwards - - > open ( "utf-8" , "wb" ) . write ( utf8 )
tests / test - diff - antipatience - t . py:14: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "w" ) . write ( "\n" . join ( list ( "a" + "x" * 10 + "u" + "x" * 30 + "a\n" ) ) )
tests / test - diff - antipatience - t . py:16: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "w" ) . write ( "\n" . join ( list ( "b" + "x" * 30 + "u" + "x" * 10 + "b\n" ) ) )
tests / test - export - t . py:20: always assign an opened file to a variable , and close it afterwards - - > open ( "foo" , "ab" ) . write ( "foo-%s\n" % i )
tests / test - extension - inline . t:12: don 't use ' python ', use ' $ PYTHON ' --> $ setconfig "extensions.foo=python-base64:`python -c ' import base64 ; print ( base64 . b64encode ( open ( \ "foo.py\", " rb ").read()).decode(" utf - 8 ").replace(\"\\n\",\"\"))'`"
tests / test - fb - hgext - fastannotate - revmap . py:151: always assign an opened file to a variable , and close it afterwards - - > ensure ( len ( set ( open ( p ) . read ( ) for p in [ path , path2 ] ) ) == 1 )
tests / test - fb - hgext - merge - conflictinfo . t:81: don 't use ' python ', use ' $ PYTHON ' - - > > local result = `hg resolve --tool internal:dumpjson --all | python -c "$script"`
tests / test - fb - hgext - patchrmdir . py:47: always assign an opened file to a variable , and close it afterwards - - > open ( d2 , "w" ) . close ( )
tests /test-gitlookup-infinitepush.t:10: don't use 'python', use '$PYTHON' --> $ echo 'ssh = python "$RUNTESTDIR/ dummyssh " ' >> $ HGRCPATH
tests / test - glog - t . py:89: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "wb" ) . write ( "%s\n" % rev )
tests /test-hgsql-pushrebase2.t:13: don't use 'python', use '$PYTHON' --> $ setconfig hgsql.initialsync=false treemanifest.treeonly=1 treemanifest.sendtrees=1 remotefilelog.reponame=x remotefilelog.cachepath=$TESTTMP/c ache ui . ssh = "python $TESTDIR/dummyssh" pushrebase . verbose = 1 experimental . bundle2lazylocking = True
tests /test-hgsql-requires.t:34: don't use 'python', use '$PYTHON' --> $ hg clone --config extensions.hgsql=! --config ui.ssh='python "$TESTDIR/ dummyssh "' --uncompressed ssh://user@dummy/master client2 | grep " streaming all changes "
tests /test-hgsql-requires.t:38: don't use 'python', use '$PYTHON' --> $ hg clone --config extensions.hgsql= --config ui.ssh='python "$TESTDIR/ dummyssh " ' - - uncompressed ssh: // user @ dummy / master client3
tests / test - import - t . py:168: always assign an opened file to a variable , and close it afterwards - - > content = open ( "diffed-tip.patch" , "rb" ) . read ( ) . replace ( b "1,1" , b "foo" )
tests / test - import - t . py:169: always assign an opened file to a variable , and close it afterwards - - > open ( "broken.patch" , "wb" ) . write ( content )
tests / test - import - t . py:219: always assign an opened file to a variable , and close it afterwards - - > patch = open ( path1 , "rb" ) . read ( )
tests / test - import - t . py:223: always assign an opened file to a variable , and close it afterwards - - > open ( path2 , "wb" ) . write ( msg . as_string ( ) . encode ( "utf-8" ) )
tests / test - import - t . py:257: always assign an opened file to a variable , and close it afterwards - - > patch = open ( path1 , "rb" ) . read ( )
tests / test - import - t . py:261: always assign an opened file to a variable , and close it afterwards - - > open ( path2 , "wb" ) . write ( msg . as_string ( ) . encode ( "utf-8" ) )
tests /test-import-t.py:341: always assign an opened file to a variable, and close it afterwards --> open("subdir-tip.patch", "wb").write(open("tmp", "rb").read().replace(b"d1/ d2 ", b" " ) )
tests / test - import - t . py:473: always assign an opened file to a variable , and close it afterwards - - > open ( "b" , "wb" ) . write ( b "a\0b" )
tests / test - import - t . py:747: always assign an opened file to a variable , and close it afterwards - - > open ( "trickyheaders.patch" , "wb" ) . write (
tests /test-infinitepush-bundlestore.t:227: don't use 'python', use '$PYTHON' --> > ssh = python "$TESTDIR/ dummyssh "
tests /test-infinitepush-bundlestore.t:258: don't use 'python', use '$PYTHON' --> > ssh = python "$TESTDIR/ dummyssh "
tests /test-memcommit.t:186: don't use 'python', use '$PYTHON' --> > ( cd "$1" && setconfig ui.ssh="python \"$TESTDIR/ dummyssh \ "" )
tests / test - obsmarker - template - t . py:44: always assign an opened file to a variable , and close it afterwards - - > open ( name , "wb" ) . write ( pycompat . encodeutf8 ( "%s\n" % name ) )
tests /test-remotenames-selective-pull-accessed-bookmarks.t:40: don't use 'python', use '$PYTHON' --> > sort -k 3 $file ; python $TESTTMP/ verifylast . py
tests / test - revert - t . py:24: always assign an opened file to a variable , and close it afterwards - - > content = open ( filename ) . read ( )
tests / test - revset - age - t . py:26: always assign an opened file to a variable , and close it afterwards - - > open ( "file1" , "w" ) . write ( "%s\n" % delta )
tests / test - revset - t . py:1798: always assign an opened file to a variable , and close it afterwards - - > open ( "a" , "wb" ) . write ( "%s\n" % i )
tests /test-shelve-t.py:1025: always assign an opened file to a variable, and close it afterwards --> f.write(open(".hg/s helvedstate ").read().replace(" ae8c668541e8 ", " 123456789012 " ) )
tests / test - sparse - fetch - t . py:136: always assign an opened file to a variable , and close it afterwards - - > open ( "y" , "w" ) . write ( "2" )
tests /test-sparse-fetch-t.py:138: always assign an opened file to a variable, and close it afterwards --> open("z/ 1 ", " w ").write(" 2 " )
tests /test-sparse-fetch-t.py:139: always assign an opened file to a variable, and close it afterwards --> open("z/ z ", " w ").write(" 2 " )
tests /testutil/ argspans . py:30: always assign an opened file to a variable , and close it afterwards - - > return parso . parse ( open ( path ) . read ( ) )
tests /testutil/ autofix . py:125: always assign an opened file to a variable , and close it afterwards - - > lines = open ( path , "rb" ) . read ( ) . decode ( "utf-8" ) . splitlines ( True )
tests /testutil/ dott /shlib/ __init__ . py:219: always assign an opened file to a variable , and close it afterwards - - > open ( path , "a" )
tests /testutil/ dott /shlib/ __init__ . py:234: always assign an opened file to a variable , and close it afterwards - - > linecount += len ( open ( arg ) . read ( ) . splitlines ( ) )
tests /testutil/ dott /shlib/ __init__ . py:250: always assign an opened file to a variable , and close it afterwards - - > stdin += open ( path ) . read ( )
tests /testutil/ dott /shlib/ __init__ . py:80: always assign an opened file to a variable , and close it afterwards - - > content = "" . join ( open ( path ) . read ( ) for path in args )
tests /testutil/ dott /shlib/ hgsql . py:106: always assign an opened file to a variable , and close it afterwards - - > open ( os . path . join ( name , ".hg/hgrc" ) , "ab" ) . write (
tests /testutil/ dott /shlib/ hgsql . py:73: always assign an opened file to a variable , and close it afterwards - - > open ( os . path . join ( servername , ".hg/hgrc" ) , "ab" ) . write (
tests /testutil/ dott /shlib/ remotefilelog . py:15: always assign an opened file to a variable , and close it afterwards - - > open ( testtmp . HGRCPATH , "a" ) . write (
tests /testutil/ dott /shlib/ remotefilelog . py:51: always assign an opened file to a variable , and close it afterwards - - > open ( os . path . join ( dest , ".hg/hgrc" ) , "ab" ) . write (
tests /testutil/ dott /shlib/ remotefilelog . py:72: always assign an opened file to a variable , and close it afterwards - - > open ( os . path . join ( dest , ".hg/hgrc" ) , "ab" ) . write (
tests /testutil/ dott /shlib/ remotefilelog . py:98: always assign an opened file to a variable , and close it afterwards - - > open ( name , "wb" ) . write ( "%s\n" % name )
tests /testutil/ dott / shobj . py:71: always assign an opened file to a variable , and close it afterwards - - > open ( outpath , mode ) . write ( self . _output . encode ( "utf-8" ) )
tests /testutil/ dott / testtmp . py:68: always assign an opened file to a variable , and close it afterwards - - > open ( hgrcpath , "w" ) . write (
tests /testutil/ dott / translate . py:218: always assign an opened file to a variable , and close it afterwards - - > code = open ( path ) . read ( )
tests /testutil/ dott / translate . py:278: always assign an opened file to a variable , and close it afterwards - - > open ( cachepath , "w" ) . write ( repr ( result ) )
2016-11-25 20:55:05 +03:00
@ commands in debugcommands . py should be in alphabetical order .
>> > import re
>> > commands = []
2019-01-29 05:29:48 +03:00
>> > with open ( 'edenscm/mercurial/commands/debug.py' , 'rb' ) as fh:
2016-11-25 20:55:05 +03:00
... for line in fh:
2020-01-31 05:09:21 +03:00
... m = re . match ( b "^@command\('([a-z]+)" , line )
2016-11-25 20:55:05 +03:00
... if m:
... commands . append ( m . group ( 1 ) )
>> > scommands = list ( sorted ( commands ) )
>> > for i , command in enumerate ( scommands ) :
... if command != commands [ i ] :
... print ( 'commands in debugcommands.py not sorted; first differing '
... 'command is %s; expected %s' % ( commands [ i ] , command ) )
... break
2017-03-29 22:14:20 +03:00