P4V如何在同步时强制覆盖文件,但只有在文件未更改时才这样做

huangapple go评论46阅读模式
英文:

P4V How Clobber file during sync but only if it has not changed

问题

我使用P4V/Perforce。由于所有自动检出文件的解决方案都非常慢,我的工作流程如下:

我在Visual Studio中编辑我想要的文件,保存它,VS会自动清除文件的只读标志。然后我在P4V中进行“Reconcile Offline Changes”(如果我记得的话),最后同步到最新版本/提交等等。

这对于90%的情况都有效,问题在于我编辑但后来撤消更改的任何文件不被“Reconcile Offline Changes”识别,因此它永远不会找到它们,但它们的“只读”标志仍然被清除,因此同步会拒绝覆盖它们。

所以我的问题是:如何使Perforce在只有内容发生更改的情况下覆盖可写文件,但不对所有文件进行完整摘要?

理想情况下,它会这样工作:

在同步期间,对于需要更新的每个文件,它首先检查是否有只读标志,如果有,它只会更新该文件。如果文件是可写的,它才会执行摘要,如果摘要相同,它只会更新该文件,如果不同,它只会告诉我有文件它无法覆盖。

或者,如果“reconcile offline changes”标记了任何已清除只读标志但未检出的文件,也可以解决我的问题。

但根据我目前看到的工作空间和同步标志,我的唯一选择是工作空间上的“clobber”标志,这将覆盖所有可写文件,可能会破坏我的工作,或者使用“safe”同步,这将强制对所有更新的文件进行摘要,但由于我在一个相当大的仓库上工作,有数百人更新它,所以这非常慢。

所以我目前的唯一选择是浏览所有有关未覆盖文件的弹出窗口,逐个检出它们,然后再次同步。

这是否可能?也许我对“clobber”或“safe”标志的工作方式有误解?是否有一些标志的组合能够做到我想要的事情?

在此先感谢您的帮助!

英文:

I work with P4V/Perforce. Due to all of the automatic solutions to checking out files being just awfully slow my workflow looks like this:
I Edit the file I want in visual studio, save it, VS automatically clears the read-only flag on the file. Then I Reconcile Offline Changes in P4V (if I remember to do so) and finally sync to latest/commit/whatever.

This works for 90% of the cases, the problem is any files that I edited, but then undone the change are not recognized by the Reconcile Offline Changes, so it never finds them, but they still have the "read-only" flag cleared, so the sync refuses to clobber them.

So here's my question: How do I make perforce clobber writeable files but only if the contents have changed, but without doing a full digest on all of the files?

Ideally here's how it'd work:
During sync, for each file that it needs to update, it would first check if it has the read only flag, and if it does, it just updates that file. If the file is writeable only then does it do the digest, and if the digest is the same, it just updates that file, and if not, it just tells me there's files there it can't clobber.

Alternatively if the "reconcile offline changes" flagging up any file that has the read-only flag cleared but isn't checked out would also fix my issue.

But from the workspace and sync flags I've seen so far my only options are the "clobber" flag on the workspace, which would clobber ALL writeable files, potentially destroying my work, or using the "safe" sync which would force a digest on all updated files, which is horribly slow since I'm working on a pretty large repo with hundreds of people updating it.
So my only current option is to just go through all the popups about unclobbered files, check them out each one by one, and then sync again.

Is this possible? Am I maybe just misunderstanding how the "clobber" or "safe" flags work? Is there some combination of flags capable of doing what I want?

Thanks for the help in advance!

答案1

得分: 1

我的建议是获得一个IDE插件,可以在保存时执行p4 edit,而不仅仅是取消只读属性 - 这样你就不需要运行p4 reconcile,而且p4 revert -a将处理未修改的文件。我使用https://marketplace.visualstudio.com/items?itemName=callegustafsson.vscode-perforce-simple,而不是标准的Perforce插件;它没有更全功能的插件那样的性能问题,因为它只执行p4 edit

如果不能实现上述建议,我建议利用reconcile后工作区中不应该有未修改的文件没有标记为编辑的事实,这将保护这些文件免受sync的影响,无论clobber是否设置。考虑到在那个特定时刻,clobber是完全安全的(并且是您要在sync中的确切行为),你可以将所有这些放在一个简单的脚本中:

p4 reconcile ...
p4 client -o | sed s/noclobber/clobber/ | p4 client -i
p4 sync ...
p4 client -o | sed s/clobber/noclobber/ | p4 client -i

并在准备好将您的“离线”更改(包括可写但未修改的文件)与Perforce协调时运行它。

英文:

The ideal fix IMO would be getting an IDE plugin that does a p4 edit on save rather than just unsetting the read-only bit -- that way you don't need to run p4 reconcile, and a p4 revert -a will take care of unmodified files. I use https://marketplace.visualstudio.com/items?itemName=callegustafsson.vscode-perforce-simple rather than the standard Perforce plugin; it doesn't have the performance problems of the more full-featured plugins because all it does is the p4 edit.

Failing that, though, I suggest taking advantage of the fact that after a reconcile there should be no modified files in your workspace that aren't open for edit, which protects them from sync regardless of whether clobber is set. Given that at that particular moment clobber is perfectly safe (and is the exact behavior you want for your sync) you could put all this together in a simple script:

p4 reconcile ...
p4 client -o | sed s/noclobber/clobber/ | p4 client -i
p4 sync ...
p4 client -o | sed s/clobber/noclobber/ | p4 client -i

and run that whenever you're ready to reconcile your "offline" changes (including writable-but-unmodified files) with Perforce.

huangapple
  • 本文由 发表于 2023年4月4日 03:22:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923075.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定