开发者

Perforce: How do I p4 integrate a local uncommitted changelist?

Here's my scenario:

I have two projects projectA and projectB. A branchspec auto-integrates projectA to projectB. Now, I hav开发者_运维百科e a changelist which modifies some files in projectA -- I have not committed/submitted this changelist yet.

I'd like this changelist to go into projectB only.

Doing a p4 integrate -b branchspec -c changelistNumber

shows

"All revision(s) are integrated."

How can I integrate an uncommitted changelist?


Perforce has a much easier way of accomplishing this:

  1. Shelve your changelist on branchA (note the changelist #, we'll call it NUM for reference here)

  2. Create a branch mapping between branchA and branchB (we'll call it A_to_B)

  3. Run the following command:

    p4 unshelve -s NUM -b A_to_B
    


Hack-ish solution:

  1. Check out the files in project B
  2. Manually copy files from project A to project B (they're not write-protected due to step 1)
  3. Shelve changelist in project A
  4. Submit to B
  5. Integrate files from B to A and resolve
  6. Unshelve files from step 3. Resolve as needed accepting yours.
  7. Submit to A when ready

Another approach is to create a separate branch where you do your work and then integ to A or B as needed.

The general idea is that Perforce works in terms of submitted or shelved changelists. The idea of integrating an non-committed changelist seems to go against Perforce's natural grain which makes these workarounds cumbersome.


p4 diff -u your/branch/... | patch -p x -d your/otherbranch

Where x is an int, you should try from 0 until it's working, use --dry-run in patch to test. (-p is the number of directory to strip so that file path in your/branch and your/otherbranch matches, 2 in this example)


I just bumped into the same situation, here is my solution for it (very similar to Jeff's but there is no Submit in the process), maybe it will help someone someday:

  1. Integrate (and resolve) the related files from ProjectB to ProjectA while the edited but non-submitted files are there.
  2. Check-out the related files in ProjectB.
  3. Manually copy the related files from ProjectA to ProjectB.
  4. Revert files in ProjectA.


Knocked up a quick powershell 2 script to do this:

https://gist.github.com/1173044

param([int]$changelistNum, [string]$destBranch)
$regex = "^\s+//[^/]+(/\S+)\s"
$sourceFiles = p4 change -o $changelistNum | select-string $regex | %{$_.matches[0]}

$sourceFiles | %{
    $sourcePath = (p4 where $_.groups[0].value.trim()).split(' ')[2];
    $destPath = (p4 where ($destBranch + $_.groups[1].value)).split(' ')[2];
    p4 edit $destPath;
    copy $sourcePath $destPath;
    p4 add $destPath;
}

(not sure why indentation not working above - I've prefixed the inside of the script block by 8 spaces?)

The script pulls all files out of the changelist description, and for each one tries to find the corresponding path in the other branch. It brute-forces both a p4 edit for each file and a p4 add, rather than try to guess which one is right. It's quite verbose!

To copy changelist 443 to branch myBranch:

Copy-PendingChangelistToBranch.ps1 443 "//myBranch"


You can use P4_Shelve to move the changes to a new branch which you could then integrate to projectB.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜