8
8
"""
9
9
import pathlib
10
10
from collections .abc import Sequence
11
- from typing import Any , Literal , Optional , Union
11
+ from typing import Any , List , Literal , Optional , Union
12
12
13
13
from libvcs ._internal .run import run
14
14
from libvcs ._internal .types import StrOrBytesPath , StrPath
@@ -55,6 +55,9 @@ def run(
55
55
trust_server_cert : Optional [bool ] = None ,
56
56
config_dir : Optional [pathlib .Path ] = None ,
57
57
config_option : Optional [pathlib .Path ] = None ,
58
+ # Special behavior
59
+ make_parents : Optional [bool ] = True ,
60
+ check_returncode : Optional [bool ] = None ,
58
61
** kwargs : Any ,
59
62
) -> str :
60
63
"""
@@ -86,6 +89,10 @@ def run(
86
89
--config-option, ``FILE:SECTION:OPTION=[VALUE]``
87
90
cwd : :attr:`libvcs._internal.types.StrOrBytesPath`, optional
88
91
Defaults to :attr:`~.cwd`
92
+ make_parents : bool, default: ``True``
93
+ Creates checkout directory (`:attr:`self.dir`) if it doesn't already exist.
94
+ check_returncode : bool, default: ``None``
95
+ Passthrough to :meth:`Svn.run`
89
96
90
97
Examples
91
98
--------
@@ -117,7 +124,11 @@ def run(
117
124
if config_option is not None :
118
125
cli_args .extend (["--config-option" , str (config_option )])
119
126
120
- return run (args = cli_args , ** kwargs )
127
+ return run (
128
+ args = cli_args ,
129
+ check_returncode = True if check_returncode is None else check_returncode ,
130
+ ** kwargs ,
131
+ )
121
132
122
133
def checkout (
123
134
self ,
@@ -127,6 +138,15 @@ def checkout(
127
138
force : Optional [bool ] = None ,
128
139
ignore_externals : Optional [bool ] = None ,
129
140
depth : DepthLiteral = None ,
141
+ quiet : Optional [bool ] = None ,
142
+ username : Optional [str ] = None ,
143
+ password : Optional [str ] = None ,
144
+ no_auth_cache : Optional [bool ] = None ,
145
+ non_interactive : Optional [bool ] = True ,
146
+ trust_server_cert : Optional [bool ] = None ,
147
+ # Special behavior
148
+ make_parents : Optional [bool ] = True ,
149
+ check_returncode : Optional [bool ] = False ,
130
150
) -> str :
131
151
"""Check out a working copy from an SVN repo.
132
152
@@ -144,6 +164,10 @@ def checkout(
144
164
ignore externals definitions
145
165
depth :
146
166
Sparse checkout support, Optional
167
+ make_parents : bool, default: ``True``
168
+ Creates checkout directory (`:attr:`self.dir`) if it doesn't already exist.
169
+ check_returncode : bool, default: True
170
+ Passthrough to :meth:`Svn.run`
147
171
148
172
Examples
149
173
--------
@@ -157,15 +181,28 @@ def checkout(
157
181
local_flags : list [str ] = [url , str (self .dir )]
158
182
159
183
if revision is not None :
160
- local_flags .append ( f "--revision= { revision } " )
184
+ local_flags .extend ([ "--revision" , revision ] )
161
185
if depth is not None :
162
- local_flags .append ( depth )
186
+ local_flags .extend ([ "-- depth" , depth ] )
163
187
if force is True :
164
188
local_flags .append ("--force" )
165
189
if ignore_externals is True :
166
190
local_flags .append ("--ignore-externals" )
167
191
168
- return self .run (["checkout" , * local_flags ], check_returncode = False )
192
+ # libvcs special behavior
193
+ if make_parents and not self .dir .exists ():
194
+ self .dir .mkdir (parents = True )
195
+
196
+ return self .run (
197
+ ["checkout" , * local_flags ],
198
+ quiet = quiet ,
199
+ username = username ,
200
+ password = password ,
201
+ no_auth_cache = no_auth_cache ,
202
+ non_interactive = non_interactive ,
203
+ trust_server_cert = trust_server_cert ,
204
+ check_returncode = check_returncode ,
205
+ )
169
206
170
207
def add (
171
208
self ,
@@ -317,7 +354,7 @@ def blame(
317
354
local_flags : list [str ] = [str (target )]
318
355
319
356
if revision is not None :
320
- local_flags .append ( f "--revision= { revision } " )
357
+ local_flags .extend ([ "--revision" , revision ] )
321
358
if verbose is True :
322
359
local_flags .append ("--verbose" )
323
360
if use_merge_history is True :
@@ -764,7 +801,21 @@ def unlock(self, *args: Any, **kwargs: Any) -> str:
764
801
765
802
return self .run (["unlock" , * local_flags ])
766
803
767
- def update (self , * args : Any , ** kwargs : Any ) -> str :
804
+ def update (
805
+ self ,
806
+ accept : Optional [str ] = None ,
807
+ changelist : Optional [List [str ]] = None ,
808
+ diff3_cmd : Optional [str ] = None ,
809
+ editor_cmd : Optional [str ] = None ,
810
+ force : Optional [bool ] = None ,
811
+ ignore_externals : Optional [bool ] = None ,
812
+ parents : Optional [bool ] = None ,
813
+ quiet : Optional [bool ] = None ,
814
+ revision : Optional [str ] = None ,
815
+ set_depth : Optional [str ] = None ,
816
+ * args : Any ,
817
+ ** kwargs : Any ,
818
+ ) -> str :
768
819
"""
769
820
Wraps `svn update
770
821
<https://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.update.html>`_ (up).
@@ -774,6 +825,25 @@ def update(self, *args: Any, **kwargs: Any) -> str:
774
825
"""
775
826
local_flags : list [str ] = [* args ]
776
827
828
+ if revision is not None :
829
+ local_flags .extend (["--revision" , revision ])
830
+ if diff3_cmd is not None :
831
+ local_flags .extend (["--diff3-cmd" , diff3_cmd ])
832
+ if editor_cmd is not None :
833
+ local_flags .extend (["--editor-cmd" , editor_cmd ])
834
+ if set_depth is not None :
835
+ local_flags .extend (["--set-depth" , set_depth ])
836
+ if changelist is not None :
837
+ local_flags .extend (["--changelist" , * changelist ])
838
+ if force is True :
839
+ local_flags .append ("--force" )
840
+ if quiet is True :
841
+ local_flags .append ("--quiet" )
842
+ if parents is True :
843
+ local_flags .append ("--parents" )
844
+ if ignore_externals is True :
845
+ local_flags .append ("--ignore-externals" )
846
+
777
847
return self .run (["update" , * local_flags ])
778
848
779
849
def upgrade (self , * args : Any , ** kwargs : Any ) -> str :
0 commit comments