def mergeNonDir(self, src, dest, content): assert isinstance(src, Pathname) assert isinstance(dest, Pathname) # src is the stow directory we're merging from srcpath = src + content # dest is the target directory that we are dropping # symlinks into destpath = dest + content if destpath.islink(): linkpath = destpath.realpath() if linkpath.exists(): if self.isWithinLocation(linkpath): warn("%s already points to %s" % (destpath, srcpath)) else: if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath, destpath) else: # It's a broken symlink and safe to nuke it (yes?) self.unsymlink(destpath) self.symlink(srcpath, destpath) elif destpath.exists(): if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath, destpath) # otherwise, we're skipping the conflict else: self.symlink(srcpath, destpath)
def mergeNonDir(self, src, dest, content): assert (isinstance(src, Pathname)) assert (isinstance(dest, Pathname)) # src is the stow directory we're merging from srcpath = src + content # dest is the target directory that we are dropping # symlinks into destpath = dest + content if destpath.islink(): linkpath = destpath.realpath() if linkpath.exists(): if self.isWithinLocation(linkpath): warn("%s already points to %s" % (destpath, srcpath)) else: if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath, destpath) else: # It's a broken symlink and safe to nuke it (yes?) self.unsymlink(destpath) self.symlink(srcpath, destpath) elif destpath.exists(): if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath, destpath) # otherwise, we're skipping the conflict else: self.symlink(srcpath, destpath)
def mergeSubDir(self,src,dest,content): "Merge the subdirectory content from src to dest" assert(isinstance(src, Pathname)) assert(isinstance(dest, Pathname)) destpath = dest + content srcpath = src + content if srcpath not in self.src_dirs: return # We skip stuff not in directories if srcpath in self.src_mkdirs and not destpath.exists(): destpath.mkdir() if destpath.islink(): linkpath = destpath.realpath() if self.isWithinLocation(linkpath): # This is fine. The link is actually one of ours. # Nuke it to make sure it's correct self.unsymlink(destpath) self.symlink(srcpath,destpath) elif destpath.exists(): if linkpath == srcpath: warn( "%s already points to %s" % (destpath, srcpath) ) return if srcpath.isdir(): other = self.__class__.fromSubdir(linkpath, self.catalog) if not other: if self._resolveConflict(src=srcpath, dst=destpath): # Retry after the resolve self.mergeSubDir(src,dest,content) else: self.unsymlink(destpath) destpath.mkdir() self.merge(src=srcpath,dest=destpath) other.merge(src=linkpath,dest=destpath) else: raise AssertionError("Untested path") self._resolveConflict(src=srcpath, dst=destpath) else: if self._resolveConflict(src=srcpath, dst=destpath): self.unsymlink(destpath) self.symlink(srcpath,destpath) elif destpath.exists(): if destpath.isdir(): self.merge(src=srcpath,dest=destpath) else: if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath,destpath) # else keep on trucking. else: self.symlink(srcpath,destpath)
def mergeSubDir(self, src, dest, content): "Merge the subdirectory content from src to dest" assert (isinstance(src, Pathname)) assert (isinstance(dest, Pathname)) destpath = dest + content srcpath = src + content if srcpath not in self.src_dirs: return # We skip stuff not in directories if srcpath in self.src_mkdirs and not destpath.exists(): destpath.mkdir() if destpath.islink(): linkpath = destpath.realpath() if self.isWithinLocation(linkpath): # This is fine. The link is actually one of ours. # Nuke it to make sure it's correct self.unsymlink(destpath) self.symlink(srcpath, destpath) elif destpath.exists(): if linkpath == srcpath: warn("%s already points to %s" % (destpath, srcpath)) return if srcpath.isdir(): other = self.__class__.fromSubdir(linkpath, self.catalog) if not other: if self._resolveConflict(src=srcpath, dst=destpath): # Retry after the resolve self.mergeSubDir(src, dest, content) else: self.unsymlink(destpath) destpath.mkdir() self.merge(src=srcpath, dest=destpath) other.merge(src=linkpath, dest=destpath) else: raise AssertionError("Untested path") self._resolveConflict(src=srcpath, dst=destpath) else: if self._resolveConflict(src=srcpath, dst=destpath): self.unsymlink(destpath) self.symlink(srcpath, destpath) elif destpath.exists(): if destpath.isdir(): self.merge(src=srcpath, dest=destpath) else: if self._resolveConflict(src=srcpath, dst=destpath): self.symlink(srcpath, destpath) # else keep on trucking. else: self.symlink(srcpath, destpath)