颠覆抹杀功能

发布于 2024-07-14 13:16:59 字数 722 浏览 7 评论 0原文

我只是想编写一个 shell 脚本来以一种简单的方式实现消除功能(在外部,使用建议的方式,但自动化)。

这就是我的想法:

在客户端

  1. svn list -R > 文件列表
  2. 以多种方式过滤文件列表,例如 grep 创建一个文件“要删除的文件”,类似于一组 grep XXX file-list>>>files-to-delete
  3. 使用 scp 将files-to-delete传输到服务器。

在服务器上

  1. 转储存储库 svnadmin dump /path/to/repos > repos-dumpfile,这也可以保留为备份。
  2. 过滤转储文件,对于“files-to-delete”中的每个单词,执行:cat repos-dumpfile | svndumpfilter 排除 $file > new-dumpfile
  3. 创建一个新的存储库并将新文件加载到其中svnadmin create new-name; svnadmin 加载新名称 < new-dumpfile

这可行吗? 怎么会失败呢? 还有其他想法吗?

I was just thinking of writing a shell script to implement the obliterate functionality in an easy to do way (externally, using the suggested way, but automated).

Here's what I had in mind:

On the client

  1. svn list -R > file-list.
  2. filter file-list in several ways like grep to create a file "files-to-delete", something like a set of grep XXX file-list>>files-to-delete.
  3. transfer files-to-delete to the server using scp.

On the server

  1. Dump the repository svnadmin dump /path/to/repos > repos-dumpfile, this can be kept as a backup too.
  2. Filter the dump file, for each word in "files-to-delete", do: cat repos-dumpfile | svndumpfilter exclude $file > new-dumpfile
  3. Create a new repository and load the new file to it svnadmin create new-name; svnadmin load new-name < new-dumpfile

Would this work? How can it fail? Any other ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

风筝在阴天搁浅。 2024-07-21 13:16:59

是的,那个脚本可以工作。
但通常您不会删除那么多文件。 通常只有在您意外泄露机密信息时才需要删除。

您确定要对这么多文件使用 obliterate 吗?

Yes, that script would work.
But usually you don't obliterate that many files. Usually obliterate is only needed if you commit confidential information accidentally.

Are you sure you want to use obliterate for so many files?

甜心 2024-07-21 13:16:59

我认为 cat new-dumpfile | svndumpfilter 排除 $file > new-dumpfile 是一个危险的例子。 new-dumpfile 将不会被完全处理,它的内容可能会丢失,不是吗?

从下面的评论来看: new-dumpfile 肯定会丢失,因为 shell 甚至在启动命令之前就会破坏它(截断到零长度)。

I think cat new-dumpfile | svndumpfilter exclude $file > new-dumpfile is a dangerous example. new-dumpfile will not be completely processed and it's contents will be probably lost, no?

From the comments below: the new-dumpfile will surely be lost, because the shell will clobber (truncate to zero length) it even before starting up the command.

短暂陪伴 2024-07-21 13:16:59

我有一个类似但稍微复杂的要求。 在过去的数百个修订中,一些非常大型(>1GB)示例数据文件被提交到存储库。 然后它们被移动并最终从 HEAD 中删除。 然而它们仍然在修订历史中,使得存储库变得非常大。 我无法使用 svn list -R,因为这些文件不再出现在工作副本中。

然而,svn list 可以被赋予一个修订参数。 我不确定大文件是什么时候被检入的,但我知道那是在修订版 2000 之后的某个时间。我还有一个文件名列表。 因此,我使用了一个简单的循环和 uniq 来生成我的 files-to-delete

cd $working_copy
for rev in {2000..2437}; do
    svn ls -R -r$rev | grep -f ~/tmp/big-file-names >> ~/tmp/file-paths;
done
cat ~/tmp/file-paths | sort | uniq > ~/tmp/files-to-delete
cd ~/tmp
# You should inspect "files-to-delete" to see if it looks reasonable!
cat dumpfile | svndumpfilter exclude `cat files-to-delete` > dumpfile.new

I had a similar but slightly more complex requirement. Several hundred revisions in the past, some very large (>1GB) sample data files were committed to the repository. They were then moved around and eventually deleted from HEAD. However they were still in revision history, making the repository cumbersomely large. I could not use svn list -R, since the files no longer appeared in the working copy.

However, svn list can be given a revision argument. I wasn't sure exactly when the big files had been checked in, but I knew it was sometime after revision 2000. I also had a list of file names. So I used a simple loop and uniq to generate my files-to-delete:

cd $working_copy
for rev in {2000..2437}; do
    svn ls -R -r$rev | grep -f ~/tmp/big-file-names >> ~/tmp/file-paths;
done
cat ~/tmp/file-paths | sort | uniq > ~/tmp/files-to-delete
cd ~/tmp
# You should inspect "files-to-delete" to see if it looks reasonable!
cat dumpfile | svndumpfilter exclude `cat files-to-delete` > dumpfile.new
给我一枪 2024-07-21 13:16:59

不同版本中具有相同路径的文件怎么样? 例如,如果您提交 /trunk/foo,然后将其重命名为 /trunk/bar,然后在 /trunk/foo 提交其他内容你想要抹去的。 您不想丢失现在的 /trunk/bar 的历史记录。 也许svndumpfilter支持peg修订

What about files with the same path in different revisions? For example, if you commit /trunk/foo, then rename it to /trunk/bar, then commit something else at /trunk/foo that you want to obliterate. You don't want to lose the history of what's now /trunk/bar. Maybe svndumpfilter supports peg revisions?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文