删除 Bazaar 中的未知文件

发布于 2024-08-22 20:04:05 字数 252 浏览 3 评论 0原文

我的 Bazaar 工作树中有一堆我不再需要的未知文件。我可以使用 bzr stat 获取它们的列表,但我想要一种简单的方法来摆脱它们。 (我希望 bzr revert 的选项可以做到这一点,但我没有找到。)

我总是可以编写一个小脚本来解析 bzr stat 的输出> 和 rmmv 未知,但我认为某些东西可能已经存在。

我有 Bazaar (bzr) 1.13.1。

I have a bunch of unknown files in my Bazaar working tree that I no longer want. I can get a list of them using bzr stat, but I'd like an easy way to get rid of them. (I'd expect an option for bzr revert to do this, but I'm not finding one.)

I can always write a tiny script to parse the output of bzr stat and rm or mv the unknowns, but I thought something might already exist.

I have Bazaar (bzr) 1.13.1.

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

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

发布评论

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

评论(2

完美的未来在梦里 2024-08-29 20:04:05

bzr clean-tree 将删除工作树中的所有未知文件。它还具有用于删除忽略文件、合并备份和其他类型不需要的文件的开关。请参阅 bzr clean-tree --usage 了解完整详细信息。

编辑添加:对于 Bazaar 2.0.0 来说是这样,我不确定 1.13 是否如此

bzr clean-tree will get rid of all unknown files in a working tree. It also has switches to remove ignored files, merges backups and other types of unwanted files. See bzr clean-tree --usage for full details.

Edit to add: This is true for Bazaar 2.0.0, I'm not sure about 1.13

故事和酒 2024-08-29 20:04:05

制作了一个脚本:

#!/usr/bin/env ruby
# Move unknown files in a Bazaar repository to the trash.
# 
# Author: Benjamin Oakes

require 'fileutils'

TRASH_DIRECTORY = File.expand_path('~/.Trash/')

stdout = %x(bzr stat)

within = false

stdout.each_line do |line|
  if line.match(/^unknown:$/)
    within = true 
    next
  elsif line.match(/^[a-z]+:$/i)
    within = false
    next
  end

  if within
    FileUtils.move(line.match(/^\s+(.*?)$/)[1], TRASH_DIRECTORY)
  end
end

我只测试了一点,但它似乎工作得很好。如果您通过评论发现问题,请告诉我。

在一个单独的主题上,我应该学习 sed 和 sed 吗? awk?我倾向于使用 ruby​​ -e "some ruby​​ code" 来编写这些东西。

Made a script:

#!/usr/bin/env ruby
# Move unknown files in a Bazaar repository to the trash.
# 
# Author: Benjamin Oakes

require 'fileutils'

TRASH_DIRECTORY = File.expand_path('~/.Trash/')

stdout = %x(bzr stat)

within = false

stdout.each_line do |line|
  if line.match(/^unknown:$/)
    within = true 
    next
  elsif line.match(/^[a-z]+:$/i)
    within = false
    next
  end

  if within
    FileUtils.move(line.match(/^\s+(.*?)$/)[1], TRASH_DIRECTORY)
  end
end

I've only tested it a little, but it seems to work just fine. Please let me know if you find an issue via the comments.

On a separate topic, should I learn sed & awk? I tend to write these things using ruby -e "some ruby code".

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