Perforce——生成包含添加文件的差异?
当我使用“p4 diff”时,它会忽略我打开并添加的文件。是否可以生成包含添加的文件和更改的文件的差异?
When I use "p4 diff", it ignores files that I have open for add. Is it possible to generate a diff that includes added files as well as changed files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
考虑Perforce 中的差异比较客户端工作区到软件仓库中的修订,简短的答案是“否”。
没有记录的历史记录可供比较添加的文件(在提交之前未提交到软件仓库)
较长的答案将涉及一个脚本来完成与所添加文件的完整内容的差异。 (有点像这个 SO 问题)
Considering the diff in Perforce compare the files in the client workspace to revisions in the depot, the short answer is "no".
There is no recorded history to compare to for the added file (not committed to the depot before a submit)
The longer answer would involve a script to complete the diff with the full content of the added files. (kind of like in this SO question)
这是 p4 diff 的一个已知缺失功能,许多处理 Perforce 的工具都必须解决这个问题。
代码审查工具 Reviewboard 附带工具 后审。它用于为代码审查创建差异,但如果您愿意,它只会执行差异。
它是用 python 编写的,你可以提取 diff 部分供你自己使用。
This is a known missing feature of p4 diff that lots of tools dealing with Perforce have to work around.
The code review tool Reviewboard comes with the tool post-review. It is used to create diffs for a a codereview, but it will just do a diff if you want.
It's in python, you could pull out the diff section for your own use.
我写这个是为了帮助我在 cygwin 上:
I wrote this to help me on cygwin:
我刚刚解决了这个问题,并将我添加的文件包含在鱼眼预提交审查中。
我所做的是复制编辑后的文件的 diff hunk 描述符头。其中包括一行列出了软件仓库和本地路径 - 非常简单 - 另一行包含范围信息,其格式如下所述 这里。
因此,我将每个附加文件的内容添加到 diff 中,每个文件的内容前面都有,其中
LEN
是所添加文件中的行数。这对我有用;您的里程可能会有所不同。
I just worked around this issue and got my added files included in a Fisheye pre-commit review.
What I did was copy the edited files' diff hunk descriptor header. This includes one line which lists the depot and local paths - pretty straightforward - and another line with the range information, formatted as described here.
So, I added each appended each file's contents to the diff, each preceded by
where
LEN
is the number of lines in the added file.This worked for me; Your Mileage May Vary.
我刚刚开始工作,从亚伦的答案中分支出来。
====
//path/to/depot/file#1 - /path/to/workspace/file ====
我使用的是
然后确保有一个
+< /code> 在每个添加行的开头。
I just got this to work, branching off Aaron's answer. Instead of
==== //path/to/depot/file#1 - /path/to/workspace/file ====
I used
Then make sure to have a
+
at the beginning of each added line.只需 p4 打印添加的文件(我知道,这不太好) - 但这绝对是一种方法。
Just p4 print the added files (I know, that's not great) - but its definitely one way to go.