你能“忽略"吗?P4V 中的目录? [英] Can you "ignore" a directory in P4V?

查看:89
本文介绍了你能“忽略"吗?P4V 中的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Visual Studio,它会生成很多 binobj 目录.当我使用 P4V 的协调离线工作"功能时,这些会出现在本地文件不在库中"列表中.

We use Visual Studio, which generates lots of bin and obj directories. When I use P4V's "Reconcile Offline Work" feature, these appear in the "Local files not in depot" list.

我想排除它们.我发现了这个问题,但那是关于文件的,当我尝试它的建议(将以下内容添加到我的工作区视图),它不起作用:

I'd like to exclude them. I found this question, but that talks about files, and when I try what it suggests (adding the following to my workspace view), it doesn't work:

//depot/Foo/... //Client/Foo/...
-//depot/Foo/.../*.user //Client/Foo/.../*.user
-//depot/Foo/.../bin/... //Client/Foo/.../bin/...
-//depot/Foo/.../obj/... //Client/Foo/.../obj/...

它实际上似乎也不适用于文件:foo.csproj.user 文件仍显示在列表中.

It doesn't actually seem to work for files, either: the foo.csproj.user files are still displayed in the list.

我可以从 P4V 中排除目录吗?如果是这样,如何?我做错了什么?

Can I exclude directories from P4V? If so, how? What am I doing wrong?

推荐答案

更新答案:这在过去有些棘手,因为没有内置方法可以从 Perforce 命令中排除目录.自 2012 年以来,这种情况发生了变化.您可以查看针对此问题的一篇不错的 perforce 文章.

Updated answer: This has been somewhat tricky in the past, because there was no built-in way to exclude a directory from a Perforce command. Since 2012 this has changed. You can have a look at a nice perforce article for this problem.

从 2012.1 开始,可以设置 P4IGNORE 环境变量来指定用于从 Perforce 中排除文件的文件.Perforce Server (p4d) 和客户端 (p4、P4V) 都需要是 2012.1 或更高版本.P4IGNORE 的目的是在将新文​​件添加到仓库和协调工作区时忽略文件.与其他版本控制系统中的类似功能一样,P4IGNORE 不能用于忽略存储库控制下的文件.

As of 2012.1, the P4IGNORE environment variable can be set to designate a file to be used to exclude files from Perforce. Both the Perforce Server (p4d) and client (p4, P4V) need to be 2012.1 or greater. P4IGNORE's purpose is to ignore files when adding new files to the depot and reconciling workspaces. Like comparable features in other version control systems, P4IGNORE cannot be used to ignore files already under the repository's control.

P4Eclipse 根据自己的条件管理 .p4ignore 文件.(请参阅关于这一点的手册此处)

P4Eclipse manages .p4ignore files on its own terms. (see the manual regarding this point here)

使用客户端视图排除文件和目录:

在 Perforce 中排除文件和目录的传统方法是使用排除客户端映射.有关完整文档,请参阅视图的命令参考.示例视图:

The traditional method for excluding files and directories in Perforce is to use exclusionary client mappings. See the command reference for Views for full documentation. Example view:

查看:

//depot/... //test_ws/depot/...
-//depot/dir/etc/... //test_ws/depot/dir/etc/...

此视图将阻止将 dir/etc 中的文件添加到库中.如果尝试从只读查询中排除目录,请使用客户端或相关语法.

This view will prevent files in dir/etc from being added to the depot. If trying to exclude the directory from read-only queries, use client or relative syntax.

$ p4 files //depot/dir/etc/...
//depot/dir/etc/foo#1 - add change 1186 (text)
//depot/dir/etc/bar#1 - add change 1186 (text) 


$ p4 files //test_ws/dir/etc/...
//test_ws/test_ignore/ignoredir/... - file(s) not in client view. 

$ cd dir/etc
$ p4 files ...
... - file(s) not in client view.

或者,您可以使用 shell 命令根据需要过滤输出.

Alternatively, you can use shell commands to filter your output as desired.

p4 files //depot/dir/... |
    awk -F# '{print $1}' |
    grep -v "//depot/dir/etc/" |
    p4 -x - fstat

//depot/dir/"下的所有文件运行 p4 fstat,//depot/dir/etc/"下的文件除外.这种目录排除是通过列出所有文件,然后使用 grep 删除要排除的目录下的那些文件来完成的.//depot/dir/etc/"中的尾部斜杠是必要的,以防止//depot/dir/"下以etc"开头的目录匹配(例如,//depot/dir/etc2009").

which runs p4 fstat on all files under "//depot/dir/", except for those files under "//depot/dir/etc/". This directory exclusion is accomplished by listing all of the files, and then using grep to remove those files under the directory to be excluded. The trailing slash in "//depot/dir/etc/" is necessary to prevent matching directories under "//depot/dir/" that start with "etc" (for example, "//depot/dir/etc2009").

注意:

awk 命令假定没有包含#"字符的文件名.grep 命令还可以从文件中读取其模式,这在您需要排除多个目录时非常有用.我们在 p4 命令中使用-x -"标志来将输入用作相应命令的参数;有关详细信息,请参阅 Perforce 命令行全局选项.

The awk command assumes there are no file names containing the "#" character. The grep command can also read its patterns from a file, which is useful if you need to exclude multiple directories. We use the '-x -' flags with the p4 command to use the input as arguments to the corresponding command; see the Perforce Command Line Global Options for more information.

这篇关于你能“忽略"吗?P4V 中的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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