问题描述
我有这个文件,似乎已进入怪异状态.Perforce声称它已被修改且未打开:
I have this file that seems to have gotten into a weird state. Perforce claims it's modified and unopened:
> p4 diff -se
data.xml
通常,在修改和打开文件后,我可以使用 sync -f
对其进行修复.但是,由于某种原因,这个特定文件确实很固执:
Normally, when a file is modified and unopened, I can use sync -f
to fix it. But, for some reason, this particular file is being really stubborn:
> p4 sync -f data.xml
//Depot/Stream/data.xml#19 - refreshing data.xml
> p4 diff -se
data.xml
像 sync -f
一样, clean
似乎可以工作,但仍声称已对其进行了修改:
Like with sync -f
, clean
appears to work, but it still claims it's modified:
> p4 clean data.xml
//Depot/Stream/data.xml#19 - refreshing data.xml
> p4 diff -se
data.xml
毫不奇怪,当我尝试和-w
时,会发生相同的事情:
Unsurprisingly, the same thing happens when I try to reconcile -w
:
> p4 reconcile -w data.xml
//Depot/Stream/data.xml#19 - refreshing data.xml
> p4 diff -se
data.xml
如果我使用 reconcile
(不使用 -w
),则会打开文件,但是P4Merge会显示文件相同,即使不忽略空格或行尾:
If I use reconcile
(without -w
), the file is opened, but P4Merge shows the files as identical even without ignoring whitespace or line endings:
> p4 reconcile data.xml
//Depot/Stream/data.xml#19 - opened for edit
> p4 diff -se
> p4 diff -sa
data.xml
使用 revert
会将其恢复为之前的状态:
Using revert
just puts it back into the state it was in before:
> p4 revert data.xml
//Depot/Stream/data.xml#19 - was edit, reverted
> p4 diff -sa
> p4 diff -se
data.xml
有什么作用?我以前已经复制了该文件,但没有偶然打开它进行编辑.是否使它进入了不可逆的状态,也许与Windows权限有关?
What gives? I had previously copied over this file without opening it for edit first by accident. Did that put it into an irreversible state, perhaps regarding Windows permissions?
我尝试删除文件( del data.xml
)并重新获取,但是Perforce创建的新副本也存在相同的问题.
I tried deleting the file (del data.xml
) and getting it again, but the new copy created by Perforce had the same problem.
推荐答案
我想到了两种可能性:
- 服务器的文件校验和与内容不匹配(这意味着diff将始终显示为不同).您的管理员可以使用
p4 verify
命令对此进行检查. - 文件中的行尾不一致,并且您具有
share
LineEnd选项,该选项实际上是在行上进行隐式的dos2unix
行尾转换从本地磁盘读取每个文件.如果dos2unix
是no-op,则文件将显示为相同;否则,文件将显示为相同.如果文件中有\ r
,则将其删除显示为diff.
- The server's checksum of the file doesn't match its contents (which means a diff will always show it as different). Your admin can check this with the
p4 verify
command. - The line endings in the file are inconsistent and you have the
share
LineEnd option, which essentially does an implicitdos2unix
line ending conversion on every file whenever it's read from local disk. If thedos2unix
is a no-op the file will show as identical; if there are\r
s in the file then their removal will show as a diff.
在任何一种情况下,提交都可能会通过创建一个具有与您的工作空间中的内容相符的校验和的修订版来修复"文件-但我建议您进行管理员检查 p4 verify
如果文件变质,则可能是更大问题(磁盘故障等)的症状.
In either case submitting is likely to "fix" the file by creating a revision with a checksum that matches whatever is in your workspace -- but I'd recommend having an admin check p4 verify
since if a file has gone bad it's likely to be a symptom of a larger problem (disk failure, etc).
这篇关于Perforce声明文件与其他文件不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!