开发者

Is it possible to create a patch using a set of changelists?

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开发者_StackOverflow 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?


Response to the title: "Is it possible to create a patch using a set of changelists?" Yes.

p4 diff2 -u //path_to_your_sources/...@cln_minus_1 //path_to_your_sources/...@cln > /tmp/cln.patch.

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.


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):

p4 diff2 -u //depot/foo/main/...@100003 //depot/foo/main/...@100000 |
    sed 's@//depot/@E:/Source/@g' |
    sed '/^+++\|---/s@/@\\@g' |
    patch

That is:

  1. Use 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.
  2. Use sed to change the //depot/ to E:/Source/, which is where my workspace lives.
  3. Change forward slashes to double backslashes (this seems to make it work).
  4. Pipe the results through 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 with Get 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 used u2d to fix those up.


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:

//depot/mycode/trunk

And you checked in all of your changes there. You branched trunk at some point in the past to:

//depot/mycode/rel

And you have a list of changelists on trunk to merge. From a client spec that maps rel, integrate each changelist:

p4 integrate //depot/mycode/trunk/...@1234,1234 //depot/mycode/rel/...

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.)


p4 describe -S -du <CL number>

is the shorter and most concise command, in my opinion.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜