Skip to content

Commit 2570161

Browse files
committed
feat(vcs): add verbosity argument to update
verbosity argument to the update method allows for controlling the supression of output executed from this method. The argument should be a boolean value as the `-q` flag is binary, but it now is of type int as to not require a refactor of the base class callers. Implements: #13329
1 parent 8e7b496 commit 2570161

File tree

5 files changed

+62
-12
lines changed

5 files changed

+62
-12
lines changed

src/pip/_internal/vcs/bazaar.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,28 @@ def fetch_new(
5858
def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
5959
self.run_command(make_command("switch", url), cwd=dest)
6060

61-
def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
61+
def update(
62+
self,
63+
dest: str,
64+
url: HiddenText,
65+
rev_options: RevOptions,
66+
verbosity: int = 0,
67+
) -> None:
68+
flags = []
69+
70+
if verbosity <= 0:
71+
flags.append("-q")
72+
6273
output = self.run_command(
6374
make_command("info"), show_stdout=False, stdout_only=True, cwd=dest
6475
)
6576
if output.startswith("Standalone "):
6677
# Older versions of pip used to create standalone branches.
6778
# Convert the standalone branch to a checkout by calling "bzr bind".
68-
cmd_args = make_command("bind", "-q", url)
79+
cmd_args = make_command("bind", *flags, url)
6980
self.run_command(cmd_args, cwd=dest)
7081

71-
cmd_args = make_command("update", "-q", rev_options.to_args())
82+
cmd_args = make_command("update", *flags, rev_options.to_args())
7283
self.run_command(cmd_args, cwd=dest)
7384

7485
@classmethod

src/pip/_internal/vcs/git.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,32 @@ def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
343343

344344
self.update_submodules(dest)
345345

346-
def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
346+
def update(
347+
self,
348+
dest: str,
349+
url: HiddenText,
350+
rev_options: RevOptions,
351+
verbosity: int = 0,
352+
) -> None:
353+
extra_flags = []
354+
355+
if verbosity <= 0:
356+
extra_flags.append("-q")
357+
347358
# First fetch changes from the default remote
348359
if self.get_git_version() >= (1, 9):
349360
# fetch tags in addition to everything else
350-
self.run_command(["fetch", "-q", "--tags"], cwd=dest)
361+
self.run_command(["fetch", "--tags", *extra_flags], cwd=dest)
351362
else:
352-
self.run_command(["fetch", "-q"], cwd=dest)
363+
self.run_command(["fetch", *extra_flags], cwd=dest)
353364
# Then reset to wanted revision (maybe even origin/master)
354365
rev_options = self.resolve_revision(dest, url, rev_options)
355-
cmd_args = make_command("reset", "--hard", "-q", rev_options.to_args())
366+
cmd_args = make_command(
367+
"reset",
368+
"--hard",
369+
*extra_flags,
370+
rev_options.to_args(),
371+
)
356372
self.run_command(cmd_args, cwd=dest)
357373
#: update submodules
358374
self.update_submodules(dest)

src/pip/_internal/vcs/mercurial.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,20 @@ def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
7272
cmd_args = make_command("update", "-q", rev_options.to_args())
7373
self.run_command(cmd_args, cwd=dest)
7474

75-
def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
76-
self.run_command(["pull", "-q"], cwd=dest)
77-
cmd_args = make_command("update", "-q", rev_options.to_args())
75+
def update(
76+
self,
77+
dest: str,
78+
url: HiddenText,
79+
rev_options: RevOptions,
80+
verbosity: int = 0,
81+
) -> None:
82+
extra_flags = []
83+
84+
if verbosity <= 0:
85+
extra_flags.append("-q")
86+
87+
self.run_command(["pull", *extra_flags], cwd=dest)
88+
cmd_args = make_command("update", *extra_flags, rev_options.to_args())
7889
self.run_command(cmd_args, cwd=dest)
7990

8091
@classmethod

src/pip/_internal/vcs/subversion.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,13 @@ def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
310310
)
311311
self.run_command(cmd_args)
312312

313-
def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
313+
def update(
314+
self,
315+
dest: str,
316+
url: HiddenText,
317+
rev_options: RevOptions,
318+
verbosity: int = 0,
319+
) -> None:
314320
cmd_args = make_command(
315321
"update",
316322
self.get_remote_call_options(),

src/pip/_internal/vcs/versioncontrol.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,13 @@ def switch(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
460460
"""
461461
raise NotImplementedError
462462

463-
def update(self, dest: str, url: HiddenText, rev_options: RevOptions) -> None:
463+
def update(
464+
self,
465+
dest: str,
466+
url: HiddenText,
467+
rev_options: RevOptions,
468+
verbosity: int = 0,
469+
) -> None:
464470
"""
465471
Update an already-existing repo to the given ``rev_options``.
466472

0 commit comments

Comments
 (0)