dvc-utils 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dvc_utils/main.py +39 -4
- {dvc_utils-0.0.3.dist-info → dvc_utils-0.0.4.dist-info}/METADATA +12 -6
- dvc_utils-0.0.4.dist-info/RECORD +9 -0
- dvc_utils-0.0.3.dist-info/RECORD +0 -9
- {dvc_utils-0.0.3.dist-info → dvc_utils-0.0.4.dist-info}/LICENSE +0 -0
- {dvc_utils-0.0.3.dist-info → dvc_utils-0.0.4.dist-info}/WHEEL +0 -0
- {dvc_utils-0.0.3.dist-info → dvc_utils-0.0.4.dist-info}/entry_points.txt +0 -0
- {dvc_utils-0.0.3.dist-info → dvc_utils-0.0.4.dist-info}/top_level.txt +0 -0
dvc_utils/main.py
CHANGED
@@ -72,13 +72,29 @@ def dvc_cache_path(ref: str, dvc_path: Optional[str] = None, log: bool = False)
|
|
72
72
|
return join(dvc_cache_dir(log=log), 'files', 'md5', dirname, basename)
|
73
73
|
|
74
74
|
|
75
|
-
def diff_cmds(
|
75
|
+
def diff_cmds(
|
76
|
+
cmd1: str,
|
77
|
+
cmd2: str,
|
78
|
+
verbose: bool = False,
|
79
|
+
color: bool = False,
|
80
|
+
unified: int | None = None,
|
81
|
+
ignore_whitespace: bool = False,
|
82
|
+
**kwargs,
|
83
|
+
):
|
76
84
|
"""Run two commands and diff their output.
|
77
85
|
|
78
86
|
Adapted from https://stackoverflow.com/a/28840955"""
|
79
87
|
with named_pipes(n=2) as pipes:
|
80
88
|
(pipe1, pipe2) = pipes
|
81
|
-
|
89
|
+
diff_cmd = [
|
90
|
+
'diff',
|
91
|
+
*(['-w'] if ignore_whitespace else []),
|
92
|
+
*(['-U', str(unified)] if unified is not None else []),
|
93
|
+
*(['--color=always'] if color else []),
|
94
|
+
pipe1,
|
95
|
+
pipe2,
|
96
|
+
]
|
97
|
+
diff = Popen(diff_cmd)
|
82
98
|
processes = []
|
83
99
|
for path, cmd in ((pipe1, cmd1), (pipe2, cmd2)):
|
84
100
|
with open(path, 'wb', 0) as pipe:
|
@@ -90,11 +106,22 @@ def diff_cmds(cmd1: str, cmd2: str, verbose: bool = False, **kwargs):
|
|
90
106
|
|
91
107
|
|
92
108
|
@cli.command('diff', short_help='Diff a DVC-tracked file at two commits (or one commit vs. current worktree), optionally passing both through another command first')
|
109
|
+
@option('-c', '--color', is_flag=True, help='Colorize the output')
|
93
110
|
@option('-r', '--refspec', default='HEAD', help='<commit 1>..<commit 2> (compare two commits) or <commit> (compare <commit> to the worktree)')
|
94
111
|
@option('-S', '--no-shell', is_flag=True, help="Don't pass `shell=True` to Python `subprocess`es")
|
112
|
+
@option('-U', '--unified', type=int, help='Number of lines of context to show (passes through to `diff`)')
|
95
113
|
@option('-v', '--verbose', is_flag=True, help="Log intermediate commands to stderr")
|
114
|
+
@option('-w', '--ignore-whitespace', is_flag=True, help="Ignore whitespace differences (pass `-w` to `diff`)")
|
96
115
|
@argument('args', metavar='[cmd...] <path>', nargs=-1)
|
97
|
-
def dvc_utils_diff(
|
116
|
+
def dvc_utils_diff(
|
117
|
+
color: bool,
|
118
|
+
refspec: str | None,
|
119
|
+
no_shell: bool,
|
120
|
+
unified: int | None,
|
121
|
+
verbose: bool,
|
122
|
+
ignore_whitespace: bool,
|
123
|
+
args: Tuple[str, ...],
|
124
|
+
):
|
98
125
|
"""Diff a file at two commits (or one commit vs. current worktree), optionally passing both through `cmd` first
|
99
126
|
|
100
127
|
Examples:
|
@@ -139,7 +166,15 @@ def dvc_utils_diff(refspec, no_shell, verbose, args):
|
|
139
166
|
shell_kwargs = dict(shell=shell) if shell else {}
|
140
167
|
before_cmd = args(before_path)
|
141
168
|
after_cmd = args(after_path)
|
142
|
-
diff_cmds(
|
169
|
+
diff_cmds(
|
170
|
+
before_cmd,
|
171
|
+
after_cmd,
|
172
|
+
verbose=verbose,
|
173
|
+
color=color,
|
174
|
+
unified=unified,
|
175
|
+
ignore_whitespace=ignore_whitespace,
|
176
|
+
**shell_kwargs,
|
177
|
+
)
|
143
178
|
else:
|
144
179
|
process.run('diff', before_path, after_path, log=log)
|
145
180
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: dvc-utils
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.4
|
4
4
|
Summary: CLI for diffing DVC files at two commits (or one commit vs. current worktree), optionally passing both through another command first
|
5
5
|
Home-page: https://github.com/runsascoded/dvc-utils
|
6
6
|
Author: Ryan Williams
|
@@ -29,6 +29,7 @@ pip install dvc-utils
|
|
29
29
|
```
|
30
30
|
|
31
31
|
## Usage <a id="usage"></a>
|
32
|
+
<!-- `bmdf -- dvc-utils --help` -->
|
32
33
|
```bash
|
33
34
|
dvc-utils --help
|
34
35
|
# Usage: dvc-utils [OPTIONS] COMMAND [ARGS]...
|
@@ -42,6 +43,7 @@ dvc-utils --help
|
|
42
43
|
```
|
43
44
|
|
44
45
|
### `dvc-utils diff` <a id="dvc-utils-diff"></a>
|
46
|
+
<!-- `bmdf -- dvc-utils diff --help` -->
|
45
47
|
```bash
|
46
48
|
dvc-utils diff --help
|
47
49
|
# Usage: dvc-utils diff [OPTIONS] [cmd...] <path>
|
@@ -59,11 +61,15 @@ dvc-utils diff --help
|
|
59
61
|
# optional) at HEAD (last committed value) vs. the current worktree content.
|
60
62
|
#
|
61
63
|
# Options:
|
62
|
-
# -
|
63
|
-
#
|
64
|
-
#
|
65
|
-
# -
|
66
|
-
# --
|
64
|
+
# -c, --color Colorize the output
|
65
|
+
# -r, --refspec TEXT <commit 1>..<commit 2> (compare two commits) or
|
66
|
+
# <commit> (compare <commit> to the worktree)
|
67
|
+
# -S, --no-shell Don't pass `shell=True` to Python `subprocess`es
|
68
|
+
# -U, --unified INTEGER Number of lines of context to show (passes through
|
69
|
+
# to `diff`)
|
70
|
+
# -v, --verbose Log intermediate commands to stderr
|
71
|
+
# -w, --ignore-whitespace Ignore whitespace differences (pass `-w` to `diff`)
|
72
|
+
# --help Show this message and exit.
|
67
73
|
```
|
68
74
|
|
69
75
|
## Examples <a id="examples"></a>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
dvc_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
dvc_utils/main.py,sha256=oszbPch2tASbhKQunE9DiiOZxUHkfd_s2iHWqDM5vZg,5687
|
3
|
+
dvc_utils/named_pipes.py,sha256=VQ2t9BYCazFq_-MABj4t2HS7GHDvSqXXx8fOLz5DsTc,492
|
4
|
+
dvc_utils-0.0.4.dist-info/LICENSE,sha256=ZS8AReay7xmQzBAHwxIuTouGXz3SKgUa2_Sz8Ip0EzQ,1070
|
5
|
+
dvc_utils-0.0.4.dist-info/METADATA,sha256=Pr8ov2afc0wlJkzWWqTNoey-LvrKRSIrG8JM_x4q03A,6924
|
6
|
+
dvc_utils-0.0.4.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
7
|
+
dvc_utils-0.0.4.dist-info/entry_points.txt,sha256=W9OuZ6CX8QF9ojbqLtfXFo8Q2hnJ-zlcGY4_7nO8paM,49
|
8
|
+
dvc_utils-0.0.4.dist-info/top_level.txt,sha256=jT0-PJa2t_eFRE9rn-52AjdnZ8nQeEHllf2kJmaGh80,10
|
9
|
+
dvc_utils-0.0.4.dist-info/RECORD,,
|
dvc_utils-0.0.3.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
dvc_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
dvc_utils/main.py,sha256=0rpJptELszWdFLoCKoYOY6VQtAm2mp-3_-kN075T-TE,4743
|
3
|
-
dvc_utils/named_pipes.py,sha256=VQ2t9BYCazFq_-MABj4t2HS7GHDvSqXXx8fOLz5DsTc,492
|
4
|
-
dvc_utils-0.0.3.dist-info/LICENSE,sha256=ZS8AReay7xmQzBAHwxIuTouGXz3SKgUa2_Sz8Ip0EzQ,1070
|
5
|
-
dvc_utils-0.0.3.dist-info/METADATA,sha256=ExDOJDxXQTUrklQfYm6qTdWNW8Le6xknle4mG2sQFpg,6572
|
6
|
-
dvc_utils-0.0.3.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
7
|
-
dvc_utils-0.0.3.dist-info/entry_points.txt,sha256=W9OuZ6CX8QF9ojbqLtfXFo8Q2hnJ-zlcGY4_7nO8paM,49
|
8
|
-
dvc_utils-0.0.3.dist-info/top_level.txt,sha256=jT0-PJa2t_eFRE9rn-52AjdnZ8nQeEHllf2kJmaGh80,10
|
9
|
-
dvc_utils-0.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|