Perforce——生成包含添加文件的差异?

发布于 2024-08-16 03:25:11 字数 59 浏览 2 评论 0原文

当我使用“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 技术交流群。

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

发布评论

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

评论(6

黯然 2024-08-23 03:25:11

考虑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)

﹎☆浅夏丿初晴 2024-08-23 03:25:11

这是 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.

放血 2024-08-23 03:25:11

我写这个是为了帮助我在 cygwin 上:

#!/bin/bash

if [ $# -ne 1 ]; then
        echo "usage: $0 <pathSpec>"
        exit 1
fi

pathSpec=$1

doIt () {
        p4 opened "$pathSpec" | egrep "#.* - add" | while read f; do
                # figure out the workspace path
                depotPath=${f%#*}
                clientFileLine=$(p4 fstat "$depotPath" | grep clientFile)
                workspacePathWin=${clientFileLine#... clientFile }

                # diff output
                echo ==== $depotPath#1 - $workspacePathWin ====
                workspacePath=$(cygpath "$workspacePathWin")
                lineCount=$(wc -l < "$workspacePath")
                echo @@ -0,0 +1,$lineCount @@

                # the actual diff contents
                sed -e 's/^/+/' "$workspacePath"
                echo
        done
}

doIt

I wrote this to help me on cygwin:

#!/bin/bash

if [ $# -ne 1 ]; then
        echo "usage: $0 <pathSpec>"
        exit 1
fi

pathSpec=$1

doIt () {
        p4 opened "$pathSpec" | egrep "#.* - add" | while read f; do
                # figure out the workspace path
                depotPath=${f%#*}
                clientFileLine=$(p4 fstat "$depotPath" | grep clientFile)
                workspacePathWin=${clientFileLine#... clientFile }

                # diff output
                echo ==== $depotPath#1 - $workspacePathWin ====
                workspacePath=$(cygpath "$workspacePathWin")
                lineCount=$(wc -l < "$workspacePath")
                echo @@ -0,0 +1,$lineCount @@

                # the actual diff contents
                sed -e 's/^/+/' "$workspacePath"
                echo
        done
}

doIt
随梦而飞# 2024-08-23 03:25:11

我刚刚解决了这个问题,并将我添加的文件包含在鱼眼预提交审查中。

我所做的是复制编辑后的文件的 diff hunk 描述符头。其中包括一行列出了软件仓库和本地路径 - 非常简单 - 另一行包含范围信息,其格式如下所述 这里

因此,我将每个附加文件的内容添加到 diff 中,每个文件的内容前面都有,其中

==== //path/to/depot/file#1 - /path/to/workspace/file ====
@@ -1,1 +1,LEN @@

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

==== //path/to/depot/file#1 - /path/to/workspace/file ====
@@ -1,1 +1,LEN @@

where LEN is the number of lines in the added file.

This worked for me; Your Mileage May Vary.

中性美 2024-08-23 03:25:11

我刚刚开始工作,从亚伦的答案中分支出来。 ====

//path/to/depot/file#1 - /path/to/workspace/file ====

我使用的是

--- //path/to/file [TIMESTAMP GENERATED BY NORMAL DIFF]
+++ //path/to/file [TIMESTAMP GENERATED BY NORMAL DIFF]
    @@ -1,1 +1,LEN @@

然后确保有一个 +< /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

--- //path/to/file [TIMESTAMP GENERATED BY NORMAL DIFF]
+++ //path/to/file [TIMESTAMP GENERATED BY NORMAL DIFF]
    @@ -1,1 +1,LEN @@

Then make sure to have a + at the beginning of each added line.

你丑哭了我 2024-08-23 03:25:11

只需 p4 打印添加的文件(我知道,这不太好) - 但这绝对是一种方法。

Just p4 print the added files (I know, that's not great) - but its definitely one way to go.

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