]>
jfr.im git - dlqueue.git/blob - venv/lib/python3.11/site-packages/pip/_internal/vcs/bazaar.py
2 from typing
import List
, Optional
, Tuple
4 from pip
._internal
.utils
.misc
import HiddenText
, display_path
5 from pip
._internal
.utils
.subprocess
import make_command
6 from pip
._internal
.utils
.urls
import path_to_url
7 from pip
._internal
.vcs
.versioncontrol
import (
15 logger
= logging
.getLogger(__name__
)
18 class Bazaar(VersionControl
):
33 def get_base_rev_args(rev
: str) -> List
[str]:
37 self
, dest
: str, url
: HiddenText
, rev_options
: RevOptions
, verbosity
: int
39 rev_display
= rev_options
.to_display()
41 "Checking out %s%s to %s",
51 flag
= f
"-{'v'*verbosity}"
52 cmd_args
= make_command(
53 "checkout", "--lightweight", flag
, rev_options
.to_args(), url
, dest
55 self
.run_command(cmd_args
)
57 def switch(self
, dest
: str, url
: HiddenText
, rev_options
: RevOptions
) -> None:
58 self
.run_command(make_command("switch", url
), cwd
=dest
)
60 def update(self
, dest
: str, url
: HiddenText
, rev_options
: RevOptions
) -> None:
61 output
= self
.run_command(
62 make_command("info"), show_stdout
=False, stdout_only
=True, cwd
=dest
64 if output
.startswith("Standalone "):
65 # Older versions of pip used to create standalone branches.
66 # Convert the standalone branch to a checkout by calling "bzr bind".
67 cmd_args
= make_command("bind", "-q", url
)
68 self
.run_command(cmd_args
, cwd
=dest
)
70 cmd_args
= make_command("update", "-q", rev_options
.to_args())
71 self
.run_command(cmd_args
, cwd
=dest
)
74 def get_url_rev_and_auth(cls
, url
: str) -> Tuple
[str, Optional
[str], AuthInfo
]:
75 # hotfix the URL scheme after removing bzr+ from bzr+ssh:// re-add it
76 url
, rev
, user_pass
= super().get_url_rev_and_auth(url
)
77 if url
.startswith("ssh://"):
79 return url
, rev
, user_pass
82 def get_remote_url(cls
, location
: str) -> str:
83 urls
= cls
.run_command(
84 ["info"], show_stdout
=False, stdout_only
=True, cwd
=location
86 for line
in urls
.splitlines():
88 for x
in ("checkout of branch: ", "parent branch: "):
89 if line
.startswith(x
):
90 repo
= line
.split(x
)[1]
91 if cls
._is
_local
_repository
(repo
):
92 return path_to_url(repo
)
94 raise RemoteNotFoundError
97 def get_revision(cls
, location
: str) -> str:
98 revision
= cls
.run_command(
104 return revision
.splitlines()[-1]
107 def is_commit_id_equal(cls
, dest
: str, name
: Optional
[str]) -> bool:
108 """Always assume the versions don't match"""