Example #1
0
    def untrack(self, path):
        dst_path = utils.truepath(path)

        if not os.path.exists(dst_path):
            raise Exception("Path '%s' not found" % dst_path)

        if not os.path.islink(dst_path):
            raise Exception("Path '%s' is not a symlink" % dst_path)

        src_path = os.path.realpath(dst_path)

        undo_log = []
        utils.remove_symlink(dst_path, dry_run=self.dry_run, undo_log=undo_log)
        try:
            utils.rename(src_path, dst_path, dry_run=self.dry_run)
        except:
            utils.undo_operations(undo_log)
            raise

        self.git.rm(src_path)
        self.git.commit(message="Untracking '%s'" % path)
Example #2
0
    def _unlink_bundle(self, bundle, undo_log):
        utils.log("Unlinking bundle '%s'" % bundle)

        for dirpath, dirnames, filenames, relpath in \
                self._walk_bundle(bundle):

            for filename in filenames:
                if self._ignore_match(filename):
                    continue
                file_path = os.path.join(self.root_path, relpath, filename)
                utils.remove_symlink(file_path, dry_run=self.dry_run,
                                     undo_log=undo_log)

            for dirname in dirnames:
                if self._ignore_match(dirname):
                    continue
                src_dirpath = os.path.join(dirpath, dirname)
                dst_dirpath = os.path.join(self.root_path, relpath, dirname)
                if self._is_directory_tracked(src_dirpath):
                    utils.remove_symlink(dst_dirpath, dry_run=self.dry_run,
                                         undo_log=undo_log)