Skip to content

Commit

Permalink
Added a controls_location implementation to the Mercurial class, …
Browse files Browse the repository at this point in the history
…so it porperly detects that subdirectories are under mercurial control.
  • Loading branch information
TonyBeswick committed Sep 23, 2019
1 parent f7d0667 commit c0809f4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/pip/_internal/vcs/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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
Expand Down Expand Up @@ -111,5 +112,16 @@ def is_commit_id_equal(cls, dest, name):
"""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)

0 comments on commit c0809f4

Please sign in to comment.