将目录附加到 SVN 中的忽略列表 [英] Append directories to ignored list in SVN

查看:35
本文介绍了将目录附加到 SVN 中的忽略列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含许多子目录的大目录树.在许多目录中,我使用了 svn propedit svn:ignore .,并忽略了给定目录中的文件和/或目录.现在,我想忽略 all 子目录中名为 foo 的目录.在这个答案中,建议调用:

I have a big directories tree involving many subdirectories. In many of the directories I used the svn propedit svn:ignore ., and ignored files and/or directories in the given directory. Now, I want to ignore, in all subdirectories the directories called foo. In this answer, it is suggested to invoke:

svn propset --recursive svn:ignore foo .

从树的根.问题是,一旦调用它,它就会覆盖各个子目录中的所有预定义忽略——这是不希望的.本质上,我想附加到树中每个目录的忽略列表中,其中包含条目 foo 的行.SVN 支持这种操作吗? 如果不支持,那么我正在考虑编写此任务的脚本,并将其添加到文件 dir-prop-base(似乎包含忽略列表)在每个 ./sub/directory/.svn(其中 . 是树的根)所需的行.这样做安全吗?,即手动处理 .svn 内容?

from the tree's root. The problem is, that once invoking this, it overrides all predefined ignores in the various subdirectories - and this is undesired. Essentially I would like to append to the ignore list of each directory in the tree, a line with entry foo in it. Does SVN supports this kind of action? If not, then I was thinking of scripting this task, and add to the file dir-prop-base (which seems to hold the ignore list) in each ./sub/directory/.svn (where . is the tree's root) the needed line. Is it safe to do it?, namely manually mess with .svn content?

推荐答案

我建议为此任务使用 bash 脚本.但是不要直接操作文件,而是使用 svn 命令工具.该解决方案简单且安全.如果使用 find -type d 执行,以下脚本可能会完成这项工作!-path "*/.svn*" -exec/tmp/add_svn_ignore.sh {} + 来自工作目录:

I recommend using a bash script for this task. But instead of manipulating the files directly, stay with the svn command tools. This solution is simple and safe. The following script might do the job, if executed with find -type d ! -path "*/.svn*" -exec /tmp/add_svn_ignore.sh {} + from the working directory:

#! /bin/bash
ignore="foo"
for pathname in "$@"; do
    lines="$( svn propget svn:ignore "$pathname" )"
    grep -F -x -q "$ignore" - <<< "$lines" ||
    svn propset svn:ignore "$lines"$'\n'"$ignore" "$pathname"
done

这篇关于将目录附加到 SVN 中的忽略列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆