|
7 | 7 | from typing import Callable, Dict, Iterable, Optional, Tuple
|
8 | 8 |
|
9 | 9 | from dvc.path_info import PathInfo
|
| 10 | +from dvc.progress import Tqdm |
10 | 11 | from dvc.scm.base import SCMError
|
11 | 12 | from dvc.utils import relpath
|
12 | 13 |
|
@@ -54,6 +55,10 @@ def scandir(self) -> Iterable["DulwichObject"]:
|
54 | 55 | class DulwichBackend(BaseGitBackend): # pylint:disable=abstract-method
|
55 | 56 | """Dulwich Git backend."""
|
56 | 57 |
|
| 58 | + # Dulwich progress will return messages equivalent to git CLI, |
| 59 | + # our pbars should just display the messages as formatted by dulwich |
| 60 | + BAR_FMT_NOTOTAL = "{desc}{bar:b}|{postfix[info]} [{elapsed}]" |
| 61 | + |
57 | 62 | def __init__( # pylint:disable=W0231
|
58 | 63 | self, root_dir=os.curdir, search_parent_directories=True
|
59 | 64 | ):
|
@@ -346,16 +351,23 @@ def update_refs(refs):
|
346 | 351 | new_refs[ref] = value
|
347 | 352 | return new_refs
|
348 | 353 |
|
349 |
| - def progress(msg): |
350 |
| - logger.trace("git send_pack: %s", msg) |
351 |
| - |
352 | 354 | try:
|
353 |
| - client.send_pack( |
354 |
| - path, |
355 |
| - update_refs, |
356 |
| - self.repo.object_store.generate_pack_data, |
357 |
| - progress=progress, |
358 |
| - ) |
| 355 | + with Tqdm( |
| 356 | + desc="Pushing git refs", bar_format=self.BAR_FMT_NOTOTAL |
| 357 | + ) as pbar: |
| 358 | + |
| 359 | + def progress(msg_b): |
| 360 | + msg = msg_b.decode("ascii").strip() |
| 361 | + pbar.update_msg(msg) |
| 362 | + pbar.refresh() |
| 363 | + logger.trace(msg) |
| 364 | + |
| 365 | + client.send_pack( |
| 366 | + path, |
| 367 | + update_refs, |
| 368 | + self.repo.object_store.generate_pack_data, |
| 369 | + progress=progress, |
| 370 | + ) |
359 | 371 | except (NotGitRepository, SendPackError) as exc:
|
360 | 372 | raise SCMError("Git failed to push '{src}' to '{url}'") from exc
|
361 | 373 |
|
@@ -417,12 +429,22 @@ def determine_wants(remote_refs):
|
417 | 429 | f"'{url}' is not a valid Git remote or URL"
|
418 | 430 | ) from exc
|
419 | 431 |
|
420 |
| - def progress(msg): |
421 |
| - logger.trace("git fetch: %s", msg) |
| 432 | + with Tqdm( |
| 433 | + desc="Fetching git refs", bar_format=self.BAR_FMT_NOTOTAL |
| 434 | + ) as pbar: |
422 | 435 |
|
423 |
| - fetch_result = client.fetch( |
424 |
| - path, self.repo, progress=progress, determine_wants=determine_wants |
425 |
| - ) |
| 436 | + def progress(msg_b): |
| 437 | + msg = msg_b.decode("ascii").strip() |
| 438 | + pbar.update_msg(msg) |
| 439 | + pbar.refresh() |
| 440 | + logger.trace(msg) |
| 441 | + |
| 442 | + fetch_result = client.fetch( |
| 443 | + path, |
| 444 | + self.repo, |
| 445 | + progress=progress, |
| 446 | + determine_wants=determine_wants, |
| 447 | + ) |
426 | 448 | for (lh, rh, _) in fetch_refs:
|
427 | 449 | try:
|
428 | 450 | if rh in self.repo.refs:
|
|
0 commit comments