Added a `controls_location` implementation to the `Mercurial` class, so it porperly detects that subdirectories are under mercurial control.
@@ -9,6 +9,7 @@ from pip._internal.utils.misc import display_path, make_command, path_to_url
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
from pip._internal.vcs.versioncontrol import VersionControl, vcs
+from pip._internal.exceptions import BadCommand
if MYPY_CHECK_RUNNING:
from pip._internal.utils.misc import HiddenText
@@ -111,5 +112,16 @@ class Mercurial(VersionControl):
"""Always assume the versions don't match"""
return False
+ @classmethod
+ def controls_location(cls, location):
+ if super(Mercurial, cls).controls_location(location):
+ return True
+ try:
+ r = cls.run_command(['identify'], cwd=location, show_stdout=False, extra_ok_returncodes=[255])
+ return not r.startswith('abort:')
+ except BadCommand:
+ logger.debug("could not determine if %s is under hg control "
+ "because hg is not available", location)
+ return False
vcs.register(Mercurial)
