Skip to content

Commit c0809f4

Browse files
committed
Added a controls_location implementation to the Mercurial class, so it porperly detects that subdirectories are under mercurial control.
1 parent f7d0667 commit c0809f4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/pip/_internal/vcs/mercurial.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from pip._internal.utils.temp_dir import TempDirectory
1010
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
1111
from pip._internal.vcs.versioncontrol import VersionControl, vcs
12+
from pip._internal.exceptions import BadCommand
1213

1314
if MYPY_CHECK_RUNNING:
1415
from pip._internal.utils.misc import HiddenText
@@ -111,5 +112,16 @@ def is_commit_id_equal(cls, dest, name):
111112
"""Always assume the versions don't match"""
112113
return False
113114

115+
@classmethod
116+
def controls_location(cls, location):
117+
if super(Mercurial, cls).controls_location(location):
118+
return True
119+
try:
120+
r = cls.run_command(['identify'], cwd=location, show_stdout=False, extra_ok_returncodes=[255])
121+
return not r.startswith('abort:')
122+
except BadCommand:
123+
logger.debug("could not determine if %s is under hg control "
124+
"because hg is not available", location)
125+
return False
114126

115127
vcs.register(Mercurial)

0 commit comments

Comments
 (0)