是否可以使用一组变更列表创建补丁?
问题:2 个项目共享主干并正在更新一些相同的文件。现在需要发布一个项目,因此在项目启动之前从检查点创建了一个新分支。
我有一份来自主线的变更列表编号的列表。使用它,我可以使用带有一系列“p4描述#”命令的脚本生成更改文件列表和差异输出。
我可以重新格式化该输出并将其应用到新分支吗?
Problem: 2 projects shared trunk and were updating some of the same files. Now one project needs to be released, so a new branch was created from a checkpoint before the projects started.
I have a list of just my changelist numbers from the mainline. Using that I can generate a list changed files and diff output using a script with a series of 'p4 describe #' commands.
Can I reformat that output and apply it to the new branch somehow?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对标题的回应:“是否可以使用一组变更列表创建补丁?”
是的。
然后,您可以使用 /tmp/cln.patch 作为补丁实用程序的输入。这里,“cln”是您要为其创建补丁的已提交更改列表编号。
Response to the title: "Is it possible to create a patch using a set of changelists?"
Yes.
You can then use /tmp/cln.patch as input to the patch utility. Here, 'cln' is the submitted change list number that you want to create a patch for.
我刚刚花了两个小时来解决这个问题。使用 cygwin
patch
,我必须整理路径直到它们被识别。最后,神奇的咒语看起来像这样(跨行):
即:
p4 diff2
获取部分 depot 的统一 diff (-u
)在我关心的两个修订之间。第二个更改列表是我想要的第一个更改列表之前的列表,否则它不会包含在差异中。//depot/
更改为E:/Source/
,这是我的工作区所在的位置。patch
管道传输结果。Cygwin
patch
足够智能,可以从 Perforce 中检查文件,但我不确定如何让它默默地执行此操作。它会提示Get file 'e:\Source\foo\whatever' from Perforce with lock?
。这是
p4
版本 2010.1,这是 Cygwin 的最新安装,在 PowerShell 上运行。哦,在此之后,
patch
写出了 Unix 风格的行结尾,所以我使用u2d
来修复它们。I've just spent two hours struggling with this. Using cygwin
patch
, I had to munge the paths until they were recognised.In the end, the magic incantation looked like this (broken across lines):
That is:
p4 diff2
to get a unified diff (-u
) of part of the depot between the two revisions that I care about. The second changelist is the one before the first one I want, otherwise it's not included in the diff.sed
to change the//depot/
toE:/Source/
, which is where my workspace lives.patch
.Cygwin
patch
is smart enough to check files out of Perforce, but I'm not sure how to get it to do it silently. It prompts withGet file 'e:\Source\foo\whatever' from Perforce with lock?
.This is with
p4
version 2010.1, a fairly recent installation of Cygwin, running on PowerShell.Oh, and after this,
patch
wrote out Unix-style line endings, so I usedu2d
to fix those up.Perforce 将允许您挑选变更列表进行集成,这可能比尝试生成和应用补丁更容易。 Perforce 将跟踪您在何处集成了哪些修订,这可能会使未来的集成变得更容易。
假设您曾经有一个主干:
并且您在那里签入了所有更改。您在过去的某个时刻将主干分支到:
并且您在主干上有一个要合并的变更列表列表。从映射 rel 的客户端规范中,集成每个变更列表:
其中
1234
是变更列表编号。每次集成后解决。如果您能确定这样做的好处,您可能还希望在集成期间的各个检查点构建、测试和提交集成。 (Perforce 可以处理每次提交的多个集成,但是如果您犯了错误,您将需要恢复到最后签入的版本并重做中间集成和解析。)Perforce will let you cherry-pick changelists for integration, which may be easier than trying to generate and apply a patch. Perforce will keep track of what revisions you've integrated where, which may make future integrations easier.
Let's assume you used to have one trunk:
And you checked in all of your changes there. You branched trunk at some point in the past to:
And you have a list of changelists on trunk to merge. From a client spec that maps rel, integrate each changelist:
where
1234
is the changelist number. Resolve after each integration. You may also wish to build, test, and commit your integrations at various checkpoints during your integration, if you can identify good points to do so. (Perforce can handle multiple integrations per commit, but if you make a mistake you'll need to revert to the last version checked in and redo the intermediate integrations and resolves.)在我看来,
p4describe -S -du
是更短、最简洁的命令。
p4 describe -S -du <CL number>
is the shorter and most concise command, in my opinion.