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

Public Member Functions

bool should_add_vcs_url_prefix (cls, str remote_url)
 
str get_revision (cls, str location)
 
Tuple[str, Tuple[Optional[str], Optional[str]]] get_netloc_and_auth (cls, str netloc, str scheme)
 
Tuple[str, Optional[str], AuthInfo] get_url_rev_and_auth (cls, str url)
 
str get_remote_url (cls, str location)
 
bool is_commit_id_equal (cls, str dest, Optional[str] name)
 
None __init__ (self, Optional[bool] use_interactive=None)
 
Tuple[int,...] call_vcs_version (self)
 
Tuple[int,...] get_vcs_version (self)
 
CommandArgs get_remote_call_options (self)
 
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)
 
- Public Member Functions inherited from VersionControl
Optional[str] get_subdirectory (cls, str location)
 
str get_requirement_revision (cls, str repo_dir)
 
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[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)
 
Optional[str] get_repository_root (cls, str location)
 

Static Public Member Functions

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

Data Fields

 dirname
 
 use_interactive
 
- Data Fields inherited from VersionControl
 repo_name
 
 name
 
 dirname
 

Static Public Attributes

str name = "svn"
 
str dirname = ".svn"
 
str repo_name = "checkout"
 
tuple schemes = ("svn+ssh", "svn+http", "svn+https", "svn+svn", "svn+file")
 
- Static Public Attributes inherited from VersionControl
str name = ""
 
str dirname = ""
 
str repo_name = ""
 
tuple schemes = ()
 
tuple unset_environ = ()
 
Optional default_arg_rev = None
 

Protected Member Functions

Tuple[Optional[str], int] _get_svn_url_rev (cls, str location)
 
- Protected Member Functions inherited from VersionControl
bool _is_local_repository (cls, str repo)
 

Protected Attributes

 _vcs_version
 

Detailed Description

Definition at line 30 of file subversion.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
Optional[bool]   use_interactive = None 
)

Definition at line 187 of file subversion.py.

187 def __init__(self, use_interactive: Optional[bool] = None) -> None:
188 if use_interactive is None:
189 use_interactive = is_console_interactive()
190 self.use_interactive = use_interactive
191
192 # This member is used to cache the fetched version of the current
193 # ``svn`` client.
194 # Special value definitions:
195 # None: Not evaluated yet.
196 # Empty tuple: Could not parse version.
197 self._vcs_version: Optional[Tuple[int, ...]] = None
198
199 super().__init__()
200
for i

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ _get_svn_url_rev()

Tuple[Optional[str], int] _get_svn_url_rev (   cls,
str  location 
)
protected

Definition at line 133 of file subversion.py.

133 def _get_svn_url_rev(cls, location: str) -> Tuple[Optional[str], int]:
134 from pip._internal.exceptions import InstallationError
135
136 entries_path = os.path.join(location, cls.dirname, "entries")
137 if os.path.exists(entries_path):
138 with open(entries_path) as f:
139 data = f.read()
140 else: # subversion >= 1.7 does not have the 'entries' file
141 data = ""
142
143 url = None
144 if data.startswith("8") or data.startswith("9") or data.startswith("10"):
145 entries = list(map(str.splitlines, data.split("\n\x0c\n")))
146 del entries[0][0] # get rid of the '8'
147 url = entries[0][3]
148 revs = [int(d[9]) for d in entries if len(d) > 9 and d[9]] + [0]
149 elif data.startswith("<?xml"):
150 match = _svn_xml_url_re.search(data)
151 if not match:
152 raise ValueError(f"Badly formatted data: {data!r}")
153 url = match.group(1) # get repository URL
154 revs = [int(m.group(1)) for m in _svn_rev_re.finditer(data)] + [0]
155 else:
156 try:
157 # subversion >= 1.7
158 # Note that using get_remote_call_options is not necessary here
159 # because `svn info` is being run against a local directory.
160 # We don't need to worry about making sure interactive mode
161 # is being used to prompt for passwords, because passwords
162 # are only potentially needed for remote server requests.
163 xml = cls.run_command(
164 ["info", "--xml", location],
165 show_stdout=False,
166 stdout_only=True,
167 )
168 match = _svn_info_xml_url_re.search(xml)
169 assert match is not None
170 url = match.group(1)
171 revs = [int(m.group(1)) for m in _svn_info_xml_rev_re.finditer(xml)]
172 except InstallationError:
173 url, revs = None, []
174
175 if revs:
176 rev = max(revs)
177 else:
178 rev = 0
179
180 return url, rev
181

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

Referenced by Subversion.get_remote_url().

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

◆ call_vcs_version()

Tuple[int, ...] call_vcs_version (   self)
Query the version of the currently installed Subversion client.

:return: A tuple containing the parts of the version information or
    ``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadCommand: If ``svn`` is not installed.

Definition at line 201 of file subversion.py.

201 def call_vcs_version(self) -> Tuple[int, ...]:
202 """Query the version of the currently installed Subversion client.
203
204 :return: A tuple containing the parts of the version information or
205 ``()`` if the version returned from ``svn`` could not be parsed.
206 :raises: BadCommand: If ``svn`` is not installed.
207 """
208 # Example versions:
209 # svn, version 1.10.3 (r1842928)
210 # compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0
211 # svn, version 1.7.14 (r1542130)
212 # compiled Mar 28 2018, 08:49:13 on x86_64-pc-linux-gnu
213 # svn, version 1.12.0-SlikSvn (SlikSvn/1.12.0)
214 # compiled May 28 2019, 13:44:56 on x86_64-microsoft-windows6.2
215 version_prefix = "svn, version "
216 version = self.run_command(["--version"], show_stdout=False, stdout_only=True)
217 if not version.startswith(version_prefix):
218 return ()
219
220 version = version[len(version_prefix) :].split()[0]
221 version_list = version.partition("-")[0].split(".")
222 try:
223 parsed_version = tuple(map(int, version_list))
224 except ValueError:
225 return ()
226
227 return parsed_version
228

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

Referenced by Subversion.get_vcs_version().

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

◆ 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 280 of file subversion.py.

282 ) -> None:
283 rev_display = rev_options.to_display()
285 "Checking out %s%s to %s",
286 url,
287 rev_display,
288 display_path(dest),
289 )
290 if verbosity <= 0:
291 flag = "--quiet"
292 else:
293 flag = ""
294 cmd_args = make_command(
295 "checkout",
296 flag,
297 self.get_remote_call_options(),
299 url,
300 dest,
301 )
302 self.run_command(cmd_args)
303

References Subversion.get_remote_call_options(), 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 41 of file subversion.py.

41 def get_base_rev_args(rev: str) -> List[str]:
42 return ["-r", rev]
43

◆ get_netloc_and_auth()

Tuple[str, Tuple[Optional[str], Optional[str]]] get_netloc_and_auth (   cls,
str  netloc,
str   scheme 
)
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.

Reimplemented from VersionControl.

Definition at line 74 of file subversion.py.

76 ) -> Tuple[str, Tuple[Optional[str], Optional[str]]]:
77 """
78 This override allows the auth information to be passed to svn via the
79 --username and --password options instead of via the URL.
80 """
81 if scheme == "ssh":
82 # The --username and --password options can't be used for
83 # svn+ssh URLs, so keep the auth information in the URL.
84 return super().get_netloc_and_auth(netloc, scheme)
85
86 return split_auth_from_netloc(netloc)
87

References Subversion.get_netloc_and_auth(), and i.

Referenced by Subversion.get_netloc_and_auth(), and VersionControl.get_url_rev_and_auth().

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

◆ get_remote_call_options()

CommandArgs get_remote_call_options (   self)
Return options to be used on calls to Subversion that contact the server.

These options are applicable for the following ``svn`` subcommands used
in this class.

    - checkout
    - switch
    - update

:return: A list of command line arguments to pass to ``svn``.

Definition at line 249 of file subversion.py.

249 def get_remote_call_options(self) -> CommandArgs:
250 """Return options to be used on calls to Subversion that contact the server.
251
252 These options are applicable for the following ``svn`` subcommands used
253 in this class.
254
255 - checkout
256 - switch
257 - update
258
259 :return: A list of command line arguments to pass to ``svn``.
260 """
261 if not self.use_interactive:
262 # --non-interactive switch is available since Subversion 0.14.4.
263 # Subversion < 1.8 runs in interactive mode by default.
264 return ["--non-interactive"]
265
266 svn_version = self.get_vcs_version()
267 # By default, Subversion >= 1.8 runs in non-interactive mode if
268 # stdin is not a TTY. Since that is how pip invokes SVN, in
269 # call_subprocess(), pip must pass --force-interactive to ensure
270 # the user can be prompted for a password, if required.
271 # SVN added the --force-interactive option in SVN 1.8. Since
272 # e.g. RHEL/CentOS 7, which is supported until 2024, ships with
273 # SVN 1.7, pip should continue to support SVN 1.7. Therefore, pip
274 # can't safely add the option if the SVN version is < 1.8 (or unknown).
275 if svn_version >= (1, 8):
276 return ["--force-interactive"]
277
278 return []
279

References Subversion.get_vcs_version(), and Subversion.use_interactive.

Referenced by Subversion.fetch_new(), Subversion.switch(), and Subversion.update().

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

◆ 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 109 of file subversion.py.

109 def get_remote_url(cls, location: str) -> str:
110 # In cases where the source is in a subdirectory, we have to look up in
111 # the location until we find a valid project root.
112 orig_location = location
113 while not is_installable_dir(location):
114 last_location = location
115 location = os.path.dirname(location)
116 if location == last_location:
117 # We've traversed up to the root of the filesystem without
118 # finding a Python project.
120 "Could not find Python project for directory %s (tried all "
121 "parent directories)",
122 orig_location,
123 )
124 raise RemoteNotFoundError
125
126 url, _rev = cls._get_svn_url_rev(location)
127 if url is None:
128 raise RemoteNotFoundError
129
130 return url
131

References Subversion._get_svn_url_rev(), and i.

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_revision()

str get_revision (   cls,
str  location 
)
Return the maximum revision for all files under a given location

Reimplemented from VersionControl.

Definition at line 45 of file subversion.py.

45 def get_revision(cls, location: str) -> str:
46 """
47 Return the maximum revision for all files under a given location
48 """
49 # Note: taken from setuptools.command.egg_info
50 revision = 0
51
52 for base, dirs, _ in os.walk(location):
53 if cls.dirname not in dirs:
54 dirs[:] = []
55 continue # no sense walking uncontrolled subdirs
56 dirs.remove(cls.dirname)
57 entries_fn = os.path.join(base, cls.dirname, "entries")
58 if not os.path.exists(entries_fn):
59 # FIXME: should we warn?
60 continue
61
62 dirurl, localrev = cls._get_svn_url_rev(base)
63
64 if base == location:
65 assert dirurl is not None
66 base = dirurl + "/" # save the root url
67 elif not dirurl or not dirurl.startswith(base):
68 dirs[:] = []
69 continue # not part of the same svn tree, skip it
70 revision = max(revision, localrev)
71 return str(revision)
72

References Bazaar.dirname, Mercurial.dirname, Subversion.dirname, VersionControl.dirname, Wheel.dirname, and i.

Referenced by VersionControl.get_requirement_revision().

Here is the caller graph for this function:

◆ get_url_rev_and_auth()

Tuple[str, Optional[str], AuthInfo] get_url_rev_and_auth (   cls,
str  url 
)
Parse the repository URL to use, and return the URL, revision,
and auth info to use.

Returns: (url, rev, (username, password)).

Reimplemented from VersionControl.

Definition at line 89 of file subversion.py.

89 def get_url_rev_and_auth(cls, url: str) -> Tuple[str, Optional[str], AuthInfo]:
90 # hotfix the URL scheme after removing svn+ from svn+ssh:// re-add it
91 url, rev, user_pass = super().get_url_rev_and_auth(url)
92 if url.startswith("ssh://"):
93 url = "svn+" + url
94 return url, rev, user_pass
95

References Subversion.get_url_rev_and_auth(), and i.

Referenced by Subversion.get_url_rev_and_auth(), and VersionControl.get_url_rev_options().

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

◆ get_vcs_version()

Tuple[int, ...] get_vcs_version (   self)
Return the version of the currently installed Subversion client.

If the version of the Subversion client has already been queried,
a cached value will be used.

:return: A tuple containing the parts of the version information or
    ``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadCommand: If ``svn`` is not installed.

Definition at line 229 of file subversion.py.

229 def get_vcs_version(self) -> Tuple[int, ...]:
230 """Return the version of the currently installed Subversion client.
231
232 If the version of the Subversion client has already been queried,
233 a cached value will be used.
234
235 :return: A tuple containing the parts of the version information or
236 ``()`` if the version returned from ``svn`` could not be parsed.
237 :raises: BadCommand: If ``svn`` is not installed.
238 """
239 if self._vcs_version is not None:
240 # Use cached version, if available.
241 # If parsing the version failed previously (empty tuple),
242 # do not attempt to parse it again.
243 return self._vcs_version
244
245 vcs_version = self.call_vcs_version()
246 self._vcs_version = vcs_version
247 return vcs_version
248

References Subversion._vcs_version, and Subversion.call_vcs_version().

Referenced by Subversion.get_remote_call_options().

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 183 of file subversion.py.

183 def is_commit_id_equal(cls, dest: str, name: Optional[str]) -> bool:
184 """Always assume the versions don't match"""
185 return False
186

Referenced by VersionControl.obtain().

Here is the caller graph for this function:

◆ make_rev_args()

CommandArgs make_rev_args ( Optional[str]  username,
Optional[HiddenText]   password 
)
static
Return the RevOptions "extra arguments" to use in obtain().

Reimplemented from VersionControl.

Definition at line 97 of file subversion.py.

99 ) -> CommandArgs:
100 extra_args: CommandArgs = []
101 if username:
102 extra_args += ["--username", username]
103 if password:
104 extra_args += ["--password", password]
105
106 return extra_args
107

Referenced by VersionControl.get_url_rev_options().

Here is the caller graph for this function:

◆ should_add_vcs_url_prefix()

bool should_add_vcs_url_prefix (   cls,
str  remote_url 
)
Return whether the vcs prefix (e.g. "git+") should be added to a
repository's remote url when used in a requirement.

Reimplemented from VersionControl.

Definition at line 37 of file subversion.py.

37 def should_add_vcs_url_prefix(cls, remote_url: str) -> bool:
38 return True
39

Referenced by VersionControl.get_src_requirement().

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 304 of file subversion.py.

304 def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
305 cmd_args = make_command(
306 "switch",
307 self.get_remote_call_options(),
309 url,
310 dest,
311 )
312 self.run_command(cmd_args)
313

References Subversion.get_remote_call_options(), 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 314 of file subversion.py.

314 def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
315 cmd_args = make_command(
316 "update",
317 self.get_remote_call_options(),
319 dest,
320 )
321 self.run_command(cmd_args)
322
323

References Subversion.get_remote_call_options(), 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

◆ _vcs_version

_vcs_version
protected

Definition at line 246 of file subversion.py.

Referenced by Subversion.get_vcs_version().

◆ dirname [1/2]

◆ dirname [2/2]

◆ name

str name = "svn"
static

Definition at line 31 of file subversion.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 = "checkout"
static

Definition at line 33 of file subversion.py.

Referenced by VersionControl.obtain().

◆ schemes

tuple schemes = ("svn+ssh", "svn+http", "svn+https", "svn+svn", "svn+file")
static

Definition at line 34 of file subversion.py.

◆ use_interactive

use_interactive

Definition at line 190 of file subversion.py.

Referenced by Subversion.get_remote_call_options().


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