create-sibling: Add support for local paths (v2) #4187
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Modified-by: Kyle Meyer <firstname.lastname@example.org> This is rebased from the patch posted at dataladgh-2615. No changes were made aside from dealing with conflicts.
copy() was renamed to put() in a93922c (2019-05-16).
If git-annex doesn't exist on the remote, we clumsily tell the user [ERROR ] git-annex is missing. on the remote system The period is coming from MissingExternalDependency.__str__(), and we can't avoid it without reworking things there. Instead rephrase the message we give to work better after a period.
It's unlikely that a caller gets to the point of calling create-sibling if git-annex isn't installed locally, but it's possible. And even if it weren't, we might as well make the code path for SSH and local paths as close as possible.
With Python 3, copytree() allows the caller to specify an alternative copy function that will be used instead of the attribute-preserving copy2().
SSHConnection.put() uses an scp call that will overwrite existing directories as well as files. shutil.copytree() isn't so aggressive. create-sibling does rely on put() being able to handle existing and destination directories in some cases (e.g., "reconfigure"). Fall back to `cp` so we can handle this case.
Using "localhost" for the default sibling name for local paths is fine, but let's use "local" instead to distinguish it from the similar but not-quite-the-same case of a localhost:// SSH URL.
This debug message isn't as useful for the local case, because the name is always the same, but there's no harm in logging it, and in general it's good to keep the SSH/local code paths as close as possible.
The current convention for relative path handling is that the path is relative to the dataset if an instance is given to a command and relative to the current working directory in all other cases. Apply this treatment to a local path given as `sshurl`.
When working with an SSH sibling, --target-dir is taken as relative to the user's home directory. In the context of a local path is given for the SSH URL, this behavior doesn't make sense. Instead, tack the target directory onto the "URL".
@@ Coverage Diff @@ ## master #4187 +/- ## ========================================== - Coverage 89.26% 89.23% -0.03% ========================================== Files 275 275 Lines 36036 36119 +83 ========================================== + Hits 32166 32232 +66 - Misses 3870 3887 +17
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge.