Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/pip/_internal/vcs/mercurial.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 from __future__ import absolute_import | |
| 2 | |
| 3 import logging | |
| 4 import os | |
| 5 | |
| 6 from pip._vendor.six.moves import configparser | |
| 7 | |
| 8 from pip._internal.utils.misc import display_path, path_to_url | |
| 9 from pip._internal.utils.temp_dir import TempDirectory | |
| 10 from pip._internal.vcs.versioncontrol import VersionControl, vcs | |
| 11 | |
| 12 logger = logging.getLogger(__name__) | |
| 13 | |
| 14 | |
| 15 class Mercurial(VersionControl): | |
| 16 name = 'hg' | |
| 17 dirname = '.hg' | |
| 18 repo_name = 'clone' | |
| 19 schemes = ('hg', 'hg+http', 'hg+https', 'hg+ssh', 'hg+static-http') | |
| 20 | |
| 21 @staticmethod | |
| 22 def get_base_rev_args(rev): | |
| 23 return [rev] | |
| 24 | |
| 25 def export(self, location, url): | |
| 26 """Export the Hg repository at the url to the destination location""" | |
| 27 with TempDirectory(kind="export") as temp_dir: | |
| 28 self.unpack(temp_dir.path, url=url) | |
| 29 | |
| 30 self.run_command( | |
| 31 ['archive', location], show_stdout=False, cwd=temp_dir.path | |
| 32 ) | |
| 33 | |
| 34 def fetch_new(self, dest, url, rev_options): | |
| 35 rev_display = rev_options.to_display() | |
| 36 logger.info( | |
| 37 'Cloning hg %s%s to %s', | |
| 38 url, | |
| 39 rev_display, | |
| 40 display_path(dest), | |
| 41 ) | |
| 42 self.run_command(['clone', '--noupdate', '-q', url, dest]) | |
| 43 cmd_args = ['update', '-q'] + rev_options.to_args() | |
| 44 self.run_command(cmd_args, cwd=dest) | |
| 45 | |
| 46 def switch(self, dest, url, rev_options): | |
| 47 repo_config = os.path.join(dest, self.dirname, 'hgrc') | |
| 48 config = configparser.RawConfigParser() | |
| 49 try: | |
| 50 config.read(repo_config) | |
| 51 config.set('paths', 'default', url) | |
| 52 with open(repo_config, 'w') as config_file: | |
| 53 config.write(config_file) | |
| 54 except (OSError, configparser.NoSectionError) as exc: | |
| 55 logger.warning( | |
| 56 'Could not switch Mercurial repository to %s: %s', url, exc, | |
| 57 ) | |
| 58 else: | |
| 59 cmd_args = ['update', '-q'] + rev_options.to_args() | |
| 60 self.run_command(cmd_args, cwd=dest) | |
| 61 | |
| 62 def update(self, dest, url, rev_options): | |
| 63 self.run_command(['pull', '-q'], cwd=dest) | |
| 64 cmd_args = ['update', '-q'] + rev_options.to_args() | |
| 65 self.run_command(cmd_args, cwd=dest) | |
| 66 | |
| 67 @classmethod | |
| 68 def get_remote_url(cls, location): | |
| 69 url = cls.run_command( | |
| 70 ['showconfig', 'paths.default'], | |
| 71 show_stdout=False, cwd=location).strip() | |
| 72 if cls._is_local_repository(url): | |
| 73 url = path_to_url(url) | |
| 74 return url.strip() | |
| 75 | |
| 76 @classmethod | |
| 77 def get_revision(cls, location): | |
| 78 """ | |
| 79 Return the repository-local changeset revision number, as an integer. | |
| 80 """ | |
| 81 current_revision = cls.run_command( | |
| 82 ['parents', '--template={rev}'], | |
| 83 show_stdout=False, cwd=location).strip() | |
| 84 return current_revision | |
| 85 | |
| 86 @classmethod | |
| 87 def get_requirement_revision(cls, location): | |
| 88 """ | |
| 89 Return the changeset identification hash, as a 40-character | |
| 90 hexadecimal string | |
| 91 """ | |
| 92 current_rev_hash = cls.run_command( | |
| 93 ['parents', '--template={node}'], | |
| 94 show_stdout=False, cwd=location).strip() | |
| 95 return current_rev_hash | |
| 96 | |
| 97 @classmethod | |
| 98 def is_commit_id_equal(cls, dest, name): | |
| 99 """Always assume the versions don't match""" | |
| 100 return False | |
| 101 | |
| 102 | |
| 103 vcs.register(Mercurial) |
