Mercurial > hg
changeset 41480:eb6700e6c5ea
tests: make and use a new `svnurlof.py` helper for constructing svn urls
The previous trick of a Python oneliner and some subshells is too hard
to make portable, and this lets us consolidate some Windows-specific
logic down to a single place.
Differential Revision: https://phab.mercurial-scm.org/D5766
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 30 Jan 2019 18:49:17 -0500 |
parents | 6bbb12cba5a8 |
children | 5880b4e762cd |
files | tests/svnurlof.py tests/test-convert-hg-svn.t tests/test-convert-svn-move.t tests/test-convert-svn-source.t tests/test-mq-subrepo-svn.t tests/test-subrepo-svn.t |
diffstat | 6 files changed, 23 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/svnurlof.py Wed Jan 30 18:49:17 2019 -0500 @@ -0,0 +1,18 @@ +from __future__ import absolute_import, print_function +import sys + +from mercurial import ( + pycompat, + util, +) + +def main(argv): + enc = util.urlreq.quote(pycompat.sysbytes(argv[1])) + if pycompat.iswindows: + fmt = 'file:///%s' + else: + fmt = 'file://%s' + print(fmt % pycompat.sysstr(enc)) + +if __name__ == '__main__': + main(sys.argv)
--- a/tests/test-convert-hg-svn.t Wed Jan 30 17:24:57 2019 -0500 +++ b/tests/test-convert-hg-svn.t Wed Jan 30 18:49:17 2019 -0500 @@ -11,11 +11,7 @@ > EOF $ SVNREPOPATH=`pwd`/svn-repo -#if windows - $ SVNREPOURL=file:///`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#else - $ SVNREPOURL=file://`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#endif + $ SVNREPOURL="`$PYTHON $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`" $ svnadmin create "$SVNREPOPATH" $ cat > "$SVNREPOPATH"/hooks/pre-revprop-change <<EOF
--- a/tests/test-convert-svn-move.t Wed Jan 30 17:24:57 2019 -0500 +++ b/tests/test-convert-svn-move.t Wed Jan 30 18:49:17 2019 -0500 @@ -8,11 +8,7 @@ $ svnadmin create svn-repo $ svnadmin load -q svn-repo < "$TESTDIR/svn/move.svndump" $ SVNREPOPATH=`pwd`/svn-repo -#if windows - $ SVNREPOURL=file:///`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#else - $ SVNREPOURL=file://`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#endif + $ SVNREPOURL="`$PYTHON $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`" Convert trunk and branches
--- a/tests/test-convert-svn-source.t Wed Jan 30 17:24:57 2019 -0500 +++ b/tests/test-convert-svn-source.t Wed Jan 30 18:49:17 2019 -0500 @@ -13,11 +13,7 @@ $ svnadmin create svn-repo $ SVNREPOPATH=`pwd`/svn-repo -#if windows - $ SVNREPOURL=file:///`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#else - $ SVNREPOURL=file://`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#endif + $ SVNREPOURL="`$PYTHON $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`" $ INVALIDREVISIONID=svn:x2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk@1 $ VALIDREVISIONID=svn:a2147622-4a9f-4db4-a8d3-13562ff547b2/proj%20B/mytrunk/mytrunk@1
--- a/tests/test-mq-subrepo-svn.t Wed Jan 30 17:24:57 2019 -0500 +++ b/tests/test-mq-subrepo-svn.t Wed Jan 30 18:49:17 2019 -0500 @@ -23,18 +23,7 @@ $ svnadmin create svn-repo-2499 $ SVNREPOPATH=`pwd`/svn-repo-2499/project - -#if py3 - $ pathquoted=`"$PYTHON" -c "import sys, urllib.parse; sys.stdout.write(urllib.parse.quote(sys.argv[1]))" "$SVNREPOPATH"` -#else - $ pathquoted=`"$PYTHON" -c "import sys, urllib; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#endif - -#if windows - $ SVNREPOURL=file:///$pathquoted -#else - $ SVNREPOURL=file://$pathquoted -#endif + $ SVNREPOURL="`$PYTHON $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`" $ mkdir -p svn-project-2499/trunk $ svn import -qm 'init project' svn-project-2499 "$SVNREPOURL"
--- a/tests/test-subrepo-svn.t Wed Jan 30 17:24:57 2019 -0500 +++ b/tests/test-subrepo-svn.t Wed Jan 30 18:49:17 2019 -0500 @@ -1,11 +1,7 @@ #require svn15 $ SVNREPOPATH=`pwd`/svn-repo -#if windows - $ SVNREPOURL=file:///`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#else - $ SVNREPOURL=file://`"$PYTHON" -c "import urllib, sys; sys.stdout.write(urllib.quote(sys.argv[1]))" "$SVNREPOPATH"` -#endif + $ SVNREPOURL="`$PYTHON $TESTDIR/svnurlof.py \"$SVNREPOPATH\"`" $ filter_svn_output () { > egrep -v 'Committing|Transmitting|Updating|(^$)' || true