link_tree: support choosing the link function

This can be used to make hardlinks rather than symlinks.
This commit is contained in:
Oliver Breitwieser 2017-09-18 09:26:22 -04:00 committed by scheibelp
parent 9024ddcf05
commit 00a893aa79

View file

@ -64,7 +64,7 @@ def find_conflict(self, dest_root, **kwargs):
return dest
return None
def merge(self, dest_root, **kwargs):
def merge(self, dest_root, link=os.symlink, **kwargs):
"""Link all files in src into dest, creating directories
if necessary.
If ignore_conflicts is True, do not break when the target exists but
@ -95,7 +95,7 @@ def merge(self, dest_root, **kwargs):
else:
raise AssertionError("File already exists: %s" % dest)
else:
os.symlink(src, dest)
link(src, dest)
if ignore_conflicts:
return existing