From 3f98ee42509679a5bfd53899c9b6127d6f52e44d Mon Sep 17 00:00:00 2001 From: Adam Tse Date: Sun, 28 Oct 2018 11:44:03 +0000 Subject: [PATCH 1/5] Explicit support and tests for `hg+file` scheme for `pip install`. --- docs/html/reference/pip_install.rst | 2 +- news/4358.bugfix | 2 ++ src/pip/_internal/vcs/mercurial.py | 4 +++- tests/functional/test_install.py | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 news/4358.bugfix diff --git a/docs/html/reference/pip_install.rst b/docs/html/reference/pip_install.rst index fa475c462..9fcf94676 100644 --- a/docs/html/reference/pip_install.rst +++ b/docs/html/reference/pip_install.rst @@ -418,7 +418,7 @@ Mercurial ~~~~~~~~~ The supported schemes are: ``hg+http``, ``hg+https``, -``hg+static-http`` and ``hg+ssh``. +``hg+static-http``, ``hg+ssh`` and ``hg+file``. Here are the supported forms:: diff --git a/news/4358.bugfix b/news/4358.bugfix new file mode 100644 index 000000000..891d819de --- /dev/null +++ b/news/4358.bugfix @@ -0,0 +1,2 @@ +Not a feature because the ``hg+file`` scheme was already functioning implicitly but inconsistently documented. +This change is to make the scheme support explicit, including tests and docs. \ No newline at end of file diff --git a/src/pip/_internal/vcs/mercurial.py b/src/pip/_internal/vcs/mercurial.py index 21697ff15..e9906632d 100644 --- a/src/pip/_internal/vcs/mercurial.py +++ b/src/pip/_internal/vcs/mercurial.py @@ -22,7 +22,9 @@ class Mercurial(VersionControl): name = 'hg' dirname = '.hg' repo_name = 'clone' - schemes = ('hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http') + schemes = ( + 'hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http', 'hg+file' + ) @staticmethod def get_base_rev_args(rev): diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 7a0e4a9cb..d11368b11 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -334,11 +334,13 @@ def test_install_editable_uninstalls_existing_from_path(script, data): @need_mercurial def test_basic_install_editable_from_hg(script, tmpdir): - """Test cloning from Mercurial.""" + """Test cloning and hg+file install from Mercurial.""" pkg_path = _create_test_package(script, name='testpackage', vcs='hg') args = ['install', '-e', 'hg+%s#egg=testpackage' % path_to_url(pkg_path)] result = script.pip(*args) result.assert_installed('testpackage', with_files=['.hg']) + assert path_to_url(pkg_path).startswith("file://") + @need_mercurial From 30df34de98122c1c532e2039a6bf2da4143bcad6 Mon Sep 17 00:00:00 2001 From: atse Date: Sun, 28 Oct 2018 14:56:15 +0000 Subject: [PATCH 2/5] Update 4358.bugfix --- news/4358.bugfix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/news/4358.bugfix b/news/4358.bugfix index 891d819de..912083dc1 100644 --- a/news/4358.bugfix +++ b/news/4358.bugfix @@ -1,2 +1 @@ -Not a feature because the ``hg+file`` scheme was already functioning implicitly but inconsistently documented. -This change is to make the scheme support explicit, including tests and docs. \ No newline at end of file +Correct inconsistency related to the `hg+file` scheme. From 4022ac277fae64b4c514c3e36f64a6372bf56525 Mon Sep 17 00:00:00 2001 From: Adam Tse Date: Sun, 28 Oct 2018 15:16:14 +0000 Subject: [PATCH 3/5] :fixed whitespace --- tests/functional/test_install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index d11368b11..59511bcdd 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -342,7 +342,6 @@ def test_basic_install_editable_from_hg(script, tmpdir): assert path_to_url(pkg_path).startswith("file://") - @need_mercurial def test_vcs_url_final_slash_normalization(script, tmpdir): """ From 658425a555f7fbdc53d02fd8aeb0a467bd377146 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sun, 22 Sep 2019 11:06:07 -0400 Subject: [PATCH 4/5] Add explicit test for hg+file This was previously failing on the master branch. --- tests/unit/test_link.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/test_link.py b/tests/unit/test_link.py index 8fbafe082..a9e75e38b 100644 --- a/tests/unit/test_link.py +++ b/tests/unit/test_link.py @@ -131,6 +131,7 @@ class TestLink: @pytest.mark.parametrize('url, expected', [ ('git+https://github.com/org/repo', True), ('bzr+http://bzr.myproject.org/MyProject/trunk/#egg=MyProject', True), + ('hg+file://hg.company.com/repo', True), ('https://example.com/some.whl', False), ('file://home/foo/some.whl', False), ]) From 05964ead48159cb92841e18dbb355b913267ca0f Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Sun, 22 Sep 2019 11:10:25 -0400 Subject: [PATCH 5/5] Address previous review comments --- docs/html/reference/pip_install.rst | 4 ++-- src/pip/_internal/vcs/mercurial.py | 2 +- tests/functional/test_install.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/html/reference/pip_install.rst b/docs/html/reference/pip_install.rst index 9fcf94676..ca3ffb51e 100644 --- a/docs/html/reference/pip_install.rst +++ b/docs/html/reference/pip_install.rst @@ -417,8 +417,8 @@ making fewer network calls). Mercurial ~~~~~~~~~ -The supported schemes are: ``hg+http``, ``hg+https``, -``hg+static-http``, ``hg+ssh`` and ``hg+file``. +The supported schemes are: ``hg+file``, ``hg+http``, ``hg+https``, +``hg+static-http``, and ``hg+ssh``. Here are the supported forms:: diff --git a/src/pip/_internal/vcs/mercurial.py b/src/pip/_internal/vcs/mercurial.py index e9906632d..a4d007c76 100644 --- a/src/pip/_internal/vcs/mercurial.py +++ b/src/pip/_internal/vcs/mercurial.py @@ -23,7 +23,7 @@ class Mercurial(VersionControl): dirname = '.hg' repo_name = 'clone' schemes = ( - 'hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http', 'hg+file' + 'hg', 'hg+file', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http', ) @staticmethod diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 59511bcdd..7f5f8cfdc 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -336,10 +336,11 @@ def test_install_editable_uninstalls_existing_from_path(script, data): def test_basic_install_editable_from_hg(script, tmpdir): """Test cloning and hg+file install from Mercurial.""" pkg_path = _create_test_package(script, name='testpackage', vcs='hg') - args = ['install', '-e', 'hg+%s#egg=testpackage' % path_to_url(pkg_path)] + url = 'hg+{}#egg=testpackage'.format(path_to_url(pkg_path)) + assert url.startswith('hg+file') + args = ['install', '-e', url] result = script.pip(*args) result.assert_installed('testpackage', with_files=['.hg']) - assert path_to_url(pkg_path).startswith("file://") @need_mercurial