1212from colorama import Fore , Style
1313
1414from vcspull ._internal .config_reader import DuplicateAwareConfigReader
15+ from vcspull ._internal .private_path import PrivatePath
1516from vcspull .config import (
1617 canonicalize_workspace_path ,
1718 expand_dir ,
2122 save_config_yaml_with_items ,
2223 workspace_root_label ,
2324)
24- from vcspull .util import contract_user_home
2525
2626if t .TYPE_CHECKING :
2727 import argparse
@@ -220,11 +220,11 @@ def handle_add_command(args: argparse.Namespace) -> None:
220220 repo_path = expand_dir (pathlib .Path (repo_input ), cwd = cwd )
221221
222222 if not repo_path .exists ():
223- log .error ("Repository path %s does not exist." , repo_path )
223+ log .error ("Repository path %s does not exist." , PrivatePath ( repo_path ) )
224224 return
225225
226226 if not repo_path .is_dir ():
227- log .error ("Repository path %s is not a directory." , repo_path )
227+ log .error ("Repository path %s is not a directory." , PrivatePath ( repo_path ) )
228228 return
229229
230230 override_name = getattr (args , "override_name" , None )
@@ -238,7 +238,7 @@ def handle_add_command(args: argparse.Namespace) -> None:
238238 display_url , config_url = _normalize_detected_url (detected_remote )
239239
240240 if not config_url :
241- display_url = contract_user_home ( repo_path )
241+ display_url = str ( PrivatePath ( repo_path ) )
242242 config_url = str (repo_path )
243243 log .warning (
244244 "Unable to determine git remote for %s; using local path in config." ,
@@ -262,7 +262,7 @@ def handle_add_command(args: argparse.Namespace) -> None:
262262
263263 summary_url = display_url or config_url
264264
265- display_path = contract_user_home ( repo_path )
265+ display_path = str ( PrivatePath ( repo_path ) )
266266
267267 log .info ("%sFound new repository to import:%s" , Fore .GREEN , Style .RESET_ALL )
268268 log .info (
@@ -319,7 +319,11 @@ def handle_add_command(args: argparse.Namespace) -> None:
319319 response = ""
320320 proceed = response .strip ().lower () in {"y" , "yes" }
321321 if not proceed :
322- log .info ("Aborted import of '%s' from %s" , repo_name , repo_path )
322+ log .info (
323+ "Aborted import of '%s' from %s" ,
324+ repo_name ,
325+ PrivatePath (repo_path ),
326+ )
323327 return
324328
325329 add_repo (
@@ -370,7 +374,7 @@ def add_repo(
370374 config_file_path = pathlib .Path .cwd () / ".vcspull.yaml"
371375 log .info (
372376 "No config specified and no default found, will create at %s" ,
373- contract_user_home (config_file_path ),
377+ PrivatePath (config_file_path ),
374378 )
375379 elif len (home_configs ) > 1 :
376380 log .error (
@@ -384,7 +388,7 @@ def add_repo(
384388 raw_config : dict [str , t .Any ]
385389 duplicate_root_occurrences : dict [str , list [t .Any ]]
386390 top_level_items : list [tuple [str , t .Any ]]
387- display_config_path = contract_user_home ( config_file_path )
391+ display_config_path = str ( PrivatePath ( config_file_path ) )
388392
389393 if config_file_path .exists () and config_file_path .is_file ():
390394 try :
@@ -400,7 +404,10 @@ def add_repo(
400404 )
401405 return
402406 except Exception :
403- log .exception ("Error loading YAML from %s. Aborting." , config_file_path )
407+ log .exception (
408+ "Error loading YAML from %s. Aborting." ,
409+ PrivatePath (config_file_path ),
410+ )
404411 if log .isEnabledFor (logging .DEBUG ):
405412 traceback .print_exc ()
406413 return
@@ -579,7 +586,10 @@ def _prepare_no_merge_items(
579586 Style .RESET_ALL ,
580587 )
581588 except Exception :
582- log .exception ("Error saving config to %s" , config_file_path )
589+ log .exception (
590+ "Error saving config to %s" ,
591+ PrivatePath (config_file_path ),
592+ )
583593 if log .isEnabledFor (logging .DEBUG ):
584594 traceback .print_exc ()
585595 elif (duplicate_merge_changes > 0 or config_was_relabelled ) and dry_run :
@@ -635,7 +645,10 @@ def _prepare_no_merge_items(
635645 Style .RESET_ALL ,
636646 )
637647 except Exception :
638- log .exception ("Error saving config to %s" , config_file_path )
648+ log .exception (
649+ "Error saving config to %s" ,
650+ PrivatePath (config_file_path ),
651+ )
639652 if log .isEnabledFor (logging .DEBUG ):
640653 traceback .print_exc ()
641654 return
@@ -719,7 +732,10 @@ def _prepare_no_merge_items(
719732 Style .RESET_ALL ,
720733 )
721734 except Exception :
722- log .exception ("Error saving config to %s" , config_file_path )
735+ log .exception (
736+ "Error saving config to %s" ,
737+ PrivatePath (config_file_path ),
738+ )
723739 if log .isEnabledFor (logging .DEBUG ):
724740 traceback .print_exc ()
725741 return
@@ -778,6 +794,9 @@ def _prepare_no_merge_items(
778794 Style .RESET_ALL ,
779795 )
780796 except Exception :
781- log .exception ("Error saving config to %s" , config_file_path )
797+ log .exception (
798+ "Error saving config to %s" ,
799+ PrivatePath (config_file_path ),
800+ )
782801 if log .isEnabledFor (logging .DEBUG ):
783802 traceback .print_exc ()
0 commit comments