8000 Sync: Use cmd library by tony · Pull Request #430 · vcs-python/libvcs · GitHub
[go: up one dir, main page]

Skip to content

Sync: Use cmd library #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Oct 23, 2022
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
348532c
refactor(run): log_in_real_time, add behavior and make false by default
tony Oct 17, 2022
2bf56a1
feat(cmd): Add hg update
tony Oct 13, 2022
59be5a1
feat(cmd[hg.clone]): Add make_parents, default=True
tony Oct 14, 2022
1c36ea0
feat(cmd[hg]): check_returncode, quiet, verbose
tony Oct 14, 2022
9d8c9a5
feat(cmd[hg]): Add pull
tony Oct 14, 2022
76e1d69
refactor(sync[hg]): Move to cmd
tony Oct 13, 2022
9ebb8fa
ci(git): Add LF line ending for .dump files
tony Oct 16, 2022
404f80f
tests(svn): Add repotest data
tony Oct 16, 2022
37d21bd
feat(pytest_plugin): Use SVN import dump
tony Oct 16, 2022
190106e
refactor (sync[svn}): Remove convert_pip_url
tony Oct 16, 2022
834096c
feat(cmd[svn]): More SVN command support
tony Oct 16, 2022
8bbf668
feat(sync[svn]): Move to cmd
tony Oct 16, 2022
bff3a02
feat(cmd[svn]): Update to svn dumpfile
tony Oct 16, 2022
d9d2cc4
refactor(cmd[svn]): Remove get_rev_options() (unused)
tony Oct 16, 2022
3c24fb4
feat(cmd[svn]): Fill out svn.info
tony Oct 16, 2022
30f5a9f
refactor(sync[svn]): Remove last non-cmd dependency
tony Oct 16, 2022
0099900
feat(cmd[svn]): Much more SVN support and tests
tony Oct 23, 2022
6bb9391
feat(cmd[git]): Add Git.version
tony Oct 16, 2022
7dc3a7c
feat(cmd[git]): Improve config param by using dict
tony Oct 16, 2022
a1c5fc9
feat(cmd[git]): Add GitSubmodule (initial)
tony Oct 16, 2022
da44d50
feat(cmd[git]): Add submodule and remote
tony Oct 16, 2022
3176cf6
feat(cmd[git]): More commands
tony Oct 22, 2022
502a52d
feat(sync[git]): Moving to cmd
tony Oct 16, 2022
0d0659b
refactor(sync[git]): Callback pass-through
tony Oct 23, 2022
b561ac0
refactor(git[sync]): Move to cmd
tony Oct 22, 2022
d34382b
test(sync[git]): Update to GitSync.cmd.symbolic_ref
tony Oct 22, 2022
6ec9990
test(sync[git]): Update progress callback
tony Oct 23, 2022
de39b02
chore(git[cmd]): Clean up typings for sub-commands
tony Oct 23, 2022
5cdb96a
feat(cmd[svn]): Add progress_callback
tony Oct 23, 2022
8f7b27c
refactor(sync[svn]): Attach command as attribute
tony Oct 23, 2022
ec17ada
refactor(cmd[hg]): Pass-through progress_callback
tony Oct 23, 2022
0f65f27
refactor(sync[hg]): Use cmd via attribute
tony Oct 23, 2022
90abbe6
docs(CHANGES): Note bolstering of command and sync
tony Oct 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(cmd[svn]): More SVN command support
  • Loading branch information
tony committed Oct 23, 2022
commit 834096c763eb1b532ffd76b06856f6d735a56ab6
84 changes: 77 additions & 7 deletions src/libvcs/cmd/svn.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
import pathlib
from collections.abc import Sequence
from typing import Any, Literal, Optional, Union
from typing import Any, List, Literal, Optional, Union

from libvcs._internal.run import run
from libvcs._internal.types import StrOrBytesPath, StrPath
Expand Down Expand Up @@ -55,6 +55,9 @@ def run(
trust_server_cert: Optional[bool] = None,
config_dir: Optional[pathlib.Path] = None,
config_option: Optional[pathlib.Path] = None,
# Special behavior
make_parents: Optional[bool] = True,
check_returncode: Optional[bool] = None,
**kwargs: Any,
) -> str:
"""
Expand Down Expand Up @@ -86,6 +89,10 @@ def run(
--config-option, ``FILE:SECTION:OPTION=[VALUE]``
cwd : :attr:`libvcs._internal.types.StrOrBytesPath`, optional
Defaults to :attr:`~.cwd`
make_parents : bool, default: ``True``
Creates checkout directory (`:attr:`self.dir`) if it doesn't already exist.
check_returncode : bool, default: ``None``
Passthrough to :meth:`Svn.run`

Examples
--------
Expand Down Expand Up @@ -117,7 +124,11 @@ def run(
if config_option is not None:
cli_args.extend(["--config-option", str(config_option)])

return run(args=cli_args, **kwargs)
return run(
args=cli_args,
check_returncode=True if check_returncode is None else check_returncode,
**kwargs,
)

def checkout(
self,
Expand All @@ -127,6 +138,15 @@ def checkout(
force: Optional[bool] = None,
ignore_externals: Optional[bool] = None,
depth: DepthLiteral = None,
quiet: Optional[bool] = None,
username: Optional[str] = None,
password: Optional[str] = None,
no_auth_cache: Optional[bool] = None,
non_interactive: Optional[bool] = True,
trust_server_cert: Optional[bool] = None,
# Special behavior
make_parents: Optional[bool] = True,
check_returncode: Optional[bool] = False,
) -> str:
"""Check out a working copy from an SVN repo.

Expand All @@ -144,6 +164,10 @@ def checkout(
ignore externals definitions
depth :
Sparse checkout support, Optional
make_parents : bool, default: ``True``
Creates checkout directory (`:attr:`self.dir`) if it doesn't already exist.
check_returncode : bool, default: True
Passthrough to :meth:`Svn.run`

Examples
--------
Expand All @@ -157,15 +181,28 @@ def checkout(
local_flags: list[str] = [url, str(self.dir)]

if revision is not None:
local_flags.append(f"--revision={revision}")
local_flags.extend(["--revision", revision])
if depth is not None:
local_flags.append(depth)
local_flags.extend(["--depth", depth])
if force is True:
local_flags.append("--force")
if ignore_externals is True:
local_flags.append("--ignore-externals")

return self.run(["checkout", *local_flags], check_returncode=False)
# libvcs special behavior
if make_parents and not self.dir.exists():
self.dir.mkdir(parents=True)

return self.run(
["checkout", *local_flags],
quiet=quiet,
username=username,
password=password,
no_auth_cache=no_auth_cache,
non_interactive=non_interactive,
trust_server_cert=trust_server_cert,
check_returncode=check_returncode,
)

def add(
self,
Expand Down Expand Up @@ -317,7 +354,7 @@ def blame(
local_flags: list[str] = [str(target)]

if revision is not None:
local_flags.append(f"--revision={revision}")
local_flags.extend(["--revision", revision])
if verbose is True:
local_flags.append("--verbose")
if use_merge_history is True:
Expand Down Expand Up @@ -764,7 +801,21 @@ def unlock(self, *args: Any, **kwargs: Any) -> str:

return self.run(["unlock", *local_flags])

def update(self, *args: Any, **kwargs: Any) -> str:
def update(
self,
accept: Optional[str] = None,
changelist: Optional[List[str]] = None,
diff3_cmd: Optional[str] = None,
editor_cmd: Optional[str] = None,
force: Optional[bool] = None,
ignore_externals: Optional[bool] = None,
parents: Optional[bool] = None,
quiet: Optional[bool] = None,
revision: Optional[str] = None,
set_depth: Optional[str] = None,
*args: Any,
**kwargs: Any,
) -> str:
"""
Wraps `svn update
<https://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.update.html>`_ (up).
Expand All @@ -774,6 +825,25 @@ def update(self, *args: Any, **kwargs: Any) -> str:
"""
local_flags: list[str] = [*args]

if revision is not None:
local_flags.extend(["--revision", revision])
if diff3_cmd is not None:
local_flags.extend(["--diff3-cmd", diff3_cmd])
if editor_cmd is not None:
local_flags.extend(["--editor-cmd", editor_cmd])
if set_depth is not None:
local_flags.extend(["--set-depth", set_depth])
if changelist is not None:
local_flags.extend(["--changelist", *changelist])
if force is True:
local_flags.append("--force")
if quiet is True:
local_flags.append("--quiet")
if parents is True:
local_flags.append("--parents")
if ignore_externals is True:
local_flags.append("--ignore-externals")

return self.run(["update", *local_flags])

def upgrade(self, *args: Any, **kwargs: Any) -> str:
Expand Down
0