实际上,如何从工作区中的目录中删除文件,而这些文件不属于工作区?

发布于 2024-09-09 01:24:16 字数 155 浏览 3 评论 0原文

如果我要删除的文件不属于工作区,那么如何从工作区的目录中删除文件?

我的文件系统上有一个目录,其中包含从 perforce 获取的文件,但在某些进程运行后,它会在这些目录中创建一些新文件。

是否有 perforce 命令可以删除这些生成的不属于我的工作空间的文件?

In perforce how can I delete files from a directory in my workspace where the files I want deleted are not part of the workspace?

I have a directory on my file system with files it gets from perforce but after some processes run, it creates some new files in those directories.

Is there a perforce command to remove these generated files that are not part of my workspace?

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

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

发布评论

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

评论(7

折戟 2024-09-16 01:24:16

Perforce 2013.2 有一个 p4 status 命令,它是 p4 reconcile -n 的别名,

我不知道它在早期版本中是否可用。

Perforce 2013.2 has a p4 status command, which is an alias for p4 reconcile -n

I don't know if it was available in earlier versions.

静赏你的温柔 2024-09-16 01:24:16

这是我对 p4 nothave 的快速实现。

#!/bin/bash
#
# List files present, but not in perforce.

tmpd="$(mktemp -d /tmp/nothave.XXXXXXXX)"
trap "rm -rf $tmpd" EXIT HUP INT QUIT TERM

p4 have | awk -F' - ' '{print $2}' | sort >$tmpd/have.txt

root=$(p4 info | awk -F': ' '$1=="Client root"{print $2}')
find $root -type f | sort >$tmpd/find.txt

comm -13 $tmpd/have.txt $tmpd/find.txt

这将生成一个文件列表,然后可以将其通过管道传输到 xargs rm 以便删除。不过,在删除之前请小心检查列表。你很可能会在那里发现你意想不到的东西。

This is my quick implementation of p4 nothave.

#!/bin/bash
#
# List files present, but not in perforce.

tmpd="$(mktemp -d /tmp/nothave.XXXXXXXX)"
trap "rm -rf $tmpd" EXIT HUP INT QUIT TERM

p4 have | awk -F' - ' '{print $2}' | sort >$tmpd/have.txt

root=$(p4 info | awk -F': ' '$1=="Client root"{print $2}')
find $root -type f | sort >$tmpd/find.txt

comm -13 $tmpd/have.txt $tmpd/find.txt

This will produce a list of files, which can then be piped into xargs rm in order to be deleted. Be careful to inspect the list before deleting though. You may well find things you didn't expect in there.

若水般的淡然安静女子 2024-09-16 01:24:16

您还可以使用 p4v 和 p4 中的“协调离线工作”选项来完成此任务,而无需任何脚本。在 p4v 中,右键单击 Depot 视图中的任意目录,然后选择“协调离线工作”。

中间窗格将显示“本地文件不在仓库中”。您可以选择其中任何一个或全部,右键单击并选择“删除本地文件”。

简单的!

You can also use the "Reconcile Offline Work" option in p4v and p4 to accomplish this without any scripting. In p4v, right click any directory in Depot view and select "Reconcile Offline Work".

The middle pane will have "Local files not in depot". You can select any or all of these, right click and choose "Delete Local file".

Easy!

溇涏 2024-09-16 01:24:16

如果使用 Linux/Unix,在 Bourne shell 系列中,您可以键入

find . -type f | p4 -x- files 2>&1| grep "no such file" | cut -f1 -d" " | xargs rm

类似地,对于符号链接,键入

find . -type l | p4 -x- files 2>&1| grep "no such file" | cut -f1 -d" " | xargs rm

上面是字母“el”,而不是“one”。

我不知道 Windows 中是否有等效的。

If using Linux/Unix, in the Bourne shell family, you can type

find . -type f | p4 -x- files 2>&1| grep "no such file" | cut -f1 -d" " | xargs rm

Similarly, for symbolic links, type

find . -type l | p4 -x- files 2>&1| grep "no such file" | cut -f1 -d" " | xargs rm

Above is letter 'el', not 'one'.

Whether there is an equivalent in Windows I do not know.

2024-09-16 01:24:16

您无法从 perforce 中修改/删除不属于您的工作空间的文件。您必须为此编写外部脚本。

You cannot modify/delete files that are not part of your workspace from within perforce. You will have to write external scripts for that.

仲春光 2024-09-16 01:24:16

这在 powershell 中有点尴尬,因为 p4 将“找不到文件”消息发送到错误流而不是 std 输出。

ps > $error.clear()
ps > dir | %{p4 fstat -T "haveRev" $_} 2>$null
ps > $error | %{$_.Exception.ToString().Split()[1]} | %{del $_}

第二行应该产生诸如“FILENAME.EXT - no such file(s)”之类的错误。如果错误流中除了这些异常之外还有其他任何异常,那么它可能会有点不稳定,所以要小心。

This is a little awkward in powershell, because p4 sends the can't-find-file message to the error stream rather than std out.

ps > $error.clear()
ps > dir | %{p4 fstat -T "haveRev" $_} 2>$null
ps > $error | %{$_.Exception.ToString().Split()[1]} | %{del $_}

The second line should produces errors such as "FILENAME.EXT - no such file(s)." It can be a bit flaky if you have anything other than these exceptions in the error stream, so beware.

双马尾 2024-09-16 01:24:16

您可以使用 p4 nothave 来确定不受 perforce 管理的文件。根据 p4 nothave 的输出,您也许可以执行 p4 nothave | xargs rm,但请务必在运行之前检查 p4 nothave 的结果(这样您就不会意外删除重要的内容)。

You can use p4 nothave to determine the files that are not managed by perforce. Depending on the output of p4 nothave you might be able to do p4 nothave | xargs rm, but be sure to check the result of p4 nothave before running that (so that you don't delete something important by accident).

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