Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
Mercurial Class Reference
Inheritance diagram for Mercurial:
Collaboration diagram for Mercurial:

Public Member Functions

None fetch_new (self, str dest, HiddenText url, RevOptions rev_options, int verbosity)
 
None switch (self, str dest, HiddenText url, RevOptions rev_options)
 
None update (self, str dest, HiddenText url, RevOptions rev_options)
 
str get_remote_url (cls, str location)
 
str get_revision (cls, str location)
 
str get_requirement_revision (cls, str location)
 
bool is_commit_id_equal (cls, str dest, Optional[str] name)
 
Optional[str] get_subdirectory (cls, str location)
 
Optional[str] get_repository_root (cls, str location)
 
- Public Member Functions inherited from VersionControl
bool should_add_vcs_url_prefix (cls, str remote_url)
 
str get_src_requirement (cls, str repo_dir, str project_name)
 
bool is_immutable_rev_checkout (self, str url, str dest)
 
RevOptions make_rev_options (cls, Optional[str] rev=None, Optional[CommandArgs] extra_args=None)
 
Tuple[str, Tuple[Optional[str], Optional[str]]] get_netloc_and_auth (cls, str netloc, str scheme)
 
Tuple[str, Optional[str], AuthInfoget_url_rev_and_auth (cls, str url)
 
Tuple[HiddenText, RevOptionsget_url_rev_options (self, HiddenText url)
 
bool compare_urls (cls, str url1, str url2)
 
None obtain (self, str dest, HiddenText url, int verbosity)
 
None unpack (self, str location, HiddenText url, int verbosity)
 
str run_command (cls, Union[List[str], CommandArgs] cmd, bool show_stdout=True, Optional[str] cwd=None, 'Literal["raise", "warn", "ignore"]' on_returncode="raise", Optional[Iterable[int]] extra_ok_returncodes=None, Optional[str] command_desc=None, Optional[Mapping[str, Any]] extra_environ=None, Optional[SpinnerInterface] spinner=None, bool log_failed_cmd=True, bool stdout_only=False)
 
bool is_repository_directory (cls, str path)
 

Static Public Member Functions

List[str] get_base_rev_args (str rev)
 
- Static Public Member Functions inherited from VersionControl
CommandArgs make_rev_args (Optional[str] username, Optional[HiddenText] password)
 
str normalize_url (str url)
 

Static Public Attributes

str name = "hg"
 
str dirname = ".hg"
 
str repo_name = "clone"
 
tuple schemes
 
- Static Public Attributes inherited from VersionControl
str name = ""
 
str dirname = ""
 
str repo_name = ""
 
tuple schemes = ()
 
tuple unset_environ = ()
 
Optional default_arg_rev = None
 

Additional Inherited Members

- Data Fields inherited from VersionControl
 repo_name
 
 name
 
 dirname
 
- Protected Member Functions inherited from VersionControl
bool _is_local_repository (cls, str repo)
 

Detailed Description

Definition at line 20 of file mercurial.py.

Member Function Documentation

◆ fetch_new()

None fetch_new (   self,
str  dest,
HiddenText  url,
RevOptions  rev_options,
int   verbosity 
)
Fetch a revision from a repository, in the case that this is the
first fetch from the repository.

Args:
  dest: the directory to fetch the repository to.
  rev_options: a RevOptions object.
  verbosity: verbosity level.

Reimplemented from VersionControl.

Definition at line 36 of file mercurial.py.

38 ) -> None:
39 rev_display = rev_options.to_display()
41 "Cloning hg %s%s to %s",
42 url,
43 rev_display,
44 display_path(dest),
45 )
46 if verbosity <= 0:
47 flags: Tuple[str, ...] = ("--quiet",)
48 elif verbosity == 1:
49 flags = ()
50 elif verbosity == 2:
51 flags = ("--verbose",)
52 else:
53 flags = ("--verbose", "--debug")
54 self.run_command(make_command("clone", "--noupdate", *flags, url, dest))
55 self.run_command(
56 make_command("update", *flags, rev_options.to_args()),
57 cwd=dest,
58 )
59
for i

References i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by VersionControl.obtain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_base_rev_args()

List[str] get_base_rev_args ( str  rev)
static
Return the base revision arguments for a vcs command.

Args:
  rev: the name of a revision to install.  Cannot be None.

Reimplemented from VersionControl.

Definition at line 33 of file mercurial.py.

33 def get_base_rev_args(rev: str) -> List[str]:
34 return ["-r", rev]
35

◆ get_remote_url()

str get_remote_url (   cls,
str  location 
)
Return the url used at location

Raises RemoteNotFoundError if the repository does not have a remote
url configured.

Reimplemented from VersionControl.

Definition at line 80 of file mercurial.py.

80 def get_remote_url(cls, location: str) -> str:
81 url = cls.run_command(
82 ["showconfig", "paths.default"],
83 show_stdout=False,
84 stdout_only=True,
85 cwd=location,
86 ).strip()
87 if cls._is_local_repository(url):
88 url = path_to_url(url)
89 return url.strip()
90

References VersionControl._is_local_repository(), i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by VersionControl.get_src_requirement(), and VersionControl.obtain().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_repository_root()

Optional[str] get_repository_root (   cls,
str  location 
)
Return the "root" (top-level) directory controlled by the vcs,
or `None` if the directory is not in any.

It is meant to be overridden to implement smarter detection
mechanisms for specific vcs.

This can do more than is_repository_directory() alone. For
example, the Git override checks that Git is actually available.

Reimplemented from VersionControl.

Definition at line 138 of file mercurial.py.

138 def get_repository_root(cls, location: str) -> Optional[str]:
139 loc = super().get_repository_root(location)
140 if loc:
141 return loc
142 try:
143 r = cls.run_command(
144 ["root"],
145 cwd=location,
146 show_stdout=False,
147 stdout_only=True,
148 on_returncode="raise",
149 log_failed_cmd=False,
150 )
151 except BadCommand:
153 "could not determine if %s is under hg control "
154 "because hg is not available",
155 location,
156 )
157 return None
158 except InstallationError:
159 return None
160 return os.path.normpath(r.rstrip("\r\n"))
161
162

References Mercurial.get_repository_root(), i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by Mercurial.get_repository_root().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_requirement_revision()

str get_requirement_revision (   cls,
str  location 
)
Return the changeset identification hash, as a 40-character
hexadecimal string

Reimplemented from VersionControl.

Definition at line 105 of file mercurial.py.

105 def get_requirement_revision(cls, location: str) -> str:
106 """
107 Return the changeset identification hash, as a 40-character
108 hexadecimal string
109 """
110 current_rev_hash = cls.run_command(
111 ["parents", "--template={node}"],
112 show_stdout=False,
113 stdout_only=True,
114 cwd=location,
115 ).strip()
116 return current_rev_hash
117

References VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by VersionControl.get_src_requirement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_revision()

str get_revision (   cls,
str  location 
)
Return the repository-local changeset revision number, as an integer.

Reimplemented from VersionControl.

Definition at line 92 of file mercurial.py.

92 def get_revision(cls, location: str) -> str:
93 """
94 Return the repository-local changeset revision number, as an integer.
95 """
96 current_revision = cls.run_command(
97 ["parents", "--template={rev}"],
98 show_stdout=False,
99 stdout_only=True,
100 cwd=location,
101 ).strip()
102 return current_revision
103

References VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by VersionControl.get_requirement_revision().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_subdirectory()

Optional[str] get_subdirectory (   cls,
str  location 
)
Return the path to Python project root, relative to the repo root.
Return None if the project root is in the repo root.

Reimplemented from VersionControl.

Definition at line 124 of file mercurial.py.

124 def get_subdirectory(cls, location: str) -> Optional[str]:
125 """
126 Return the path to Python project root, relative to the repo root.
127 Return None if the project root is in the repo root.
128 """
129 # find the repo root
130 repo_root = cls.run_command(
131 ["root"], show_stdout=False, stdout_only=True, cwd=location
132 ).strip()
133 if not os.path.isabs(repo_root):
134 repo_root = os.path.abspath(os.path.join(location, repo_root))
135 return find_path_to_project_root_from_repo_root(location, repo_root)
136

References i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by VersionControl.get_src_requirement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_commit_id_equal()

bool is_commit_id_equal (   cls,
str  dest,
Optional[str]  name 
)
Always assume the versions don't match

Reimplemented from VersionControl.

Definition at line 119 of file mercurial.py.

119 def is_commit_id_equal(cls, dest: str, name: Optional[str]) -> bool:
120 """Always assume the versions don't match"""
121 return False
122

Referenced by VersionControl.obtain().

Here is the caller graph for this function:

◆ switch()

None switch (   self,
str  dest,
HiddenText  url,
RevOptions  rev_options 
)
Switch the repo at ``dest`` to point to ``URL``.

Args:
  rev_options: a RevOptions object.

Reimplemented from VersionControl.

Definition at line 60 of file mercurial.py.

60 def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
61 repo_config = os.path.join(dest, self.dirname, "hgrc")
63 try:
64 config.read(repo_config)
65 config.set("paths", "default", url.secret)
66 with open(repo_config, "w") as config_file:
67 config.write(config_file)
68 except (OSError, configparser.NoSectionError) as exc:
69 logger.warning("Could not switch Mercurial repository to %s: %s", url, exc)
70 else:
71 cmd_args = make_command("update", "-q", rev_options.to_args())
72 self.run_command(cmd_args, cwd=dest)
73

References Bazaar.dirname, Mercurial.dirname, Subversion.dirname, VersionControl.dirname, Wheel.dirname, i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Here is the call graph for this function:

◆ update()

None update (   self,
str  dest,
HiddenText  url,
RevOptions  rev_options 
)
Update an already-existing repo to the given ``rev_options``.

Args:
  rev_options: a RevOptions object.

Reimplemented from VersionControl.

Definition at line 74 of file mercurial.py.

74 def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
75 self.run_command(["pull", "-q"], cwd=dest)
76 cmd_args = make_command("update", "-q", rev_options.to_args())
77 self.run_command(cmd_args, cwd=dest)
78

References i, VersionControl.run_command(), SubprocessMixin.run_command(), and PackageIndex.run_command().

Referenced by Progress.increment(), Progress.open(), Progress.start(), Progress.stop(), Progress.track(), and Progress.wrap_file().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ dirname

◆ name

str name = "hg"
static

Definition at line 21 of file mercurial.py.

Referenced by AlreadyInstalledCandidate.__eq__(), Distribution.__eq__(), ExportEntry.__eq__(), _LazyDescr.__get__(), Distribution.__hash__(), ElementState.__init__(), Requirement.__init__(), LinkHash.__post_init__(), InstallationCandidate.__repr__(), Distribution.__repr__(), Metadata.__repr__(), ExportEntry.__repr__(), Encoding.__repr__(), Color.__rich_repr__(), Layout.__rich_repr__(), InstallationCandidate.__str__(), InstalledDistribution.__str__(), EggInfoDistribution.__str__(), Requirement.__str__(), ParserElement.__str__(), Tag.__str__(), _SixMetaPathImporter._add_module(), Matcher._check_compatible(), InstallRequirement._get_archive_name(), Wheel._get_extensions(), _SixMetaPathImporter._get_module(), ConfigOptionParser._get_ordered_configuration_items(), Distribution._get_requirements(), _Cache.add(), InstallRequirement.archive(), LinkHash.as_dict(), LinkHash.as_hashes(), Wheel.build(), _Cache.clear(), Wheel.filename(), Layout.get(), InstallRequirement.get_dist(), InstalledDistribution.get_distinfo_file(), RequirementCommand.get_requirements(), Wheel.get_wheel_metadata(), InstallRequirement.install(), Wheel.install(), SpecifierRequirement.is_satisfied_by(), LinuxDistribution.linux_distribution(), Wheel.metadata(), Distribution.name_and_version(), InstallRequirement.prepare_metadata(), Distribution.provides(), Metadata.provides(), VcsSupport.register(), VersionControl.run_command(), InstallRequirement.uninstall(), Wheel.update(), and Wheel.verify().

◆ repo_name

str repo_name = "clone"
static

Definition at line 23 of file mercurial.py.

Referenced by VersionControl.obtain().

◆ schemes

tuple schemes
static
Initial value:
= (
"hg+file",
"hg+http",
"hg+https",
"hg+ssh",
"hg+static-http",
)

Definition at line 24 of file mercurial.py.


The documentation for this class was generated from the following file: