Debajit
Debajit

Reputation: 47171

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 have 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?

Upvotes: 23

Views: 29330

Answers (7)

adrian_rzezniczak
adrian_rzezniczak

Reputation: 1

I use this approach in P4V:

  1. On source workspace create shelve of files you want to integrate into another branch, note the CL shelve number - we will use it later
  2. On target workspace hit Ctrl + G, type in remembered CL shelve number and accept
  3. Select all files (Ctrl + A) in Shelved files section
  4. Use Unshelve button from Shelved files section
  5. In next window you can set mapping and changelist into which you will unshelve those files - after inspecting click Unshelve

As a result you have new CL with files from shelve that you have to resolve now.

Upvotes: 0

Guy Danus
Guy Danus

Reputation: 786

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
    

Upvotes: 44

canatella
canatella

Reputation: 51

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)

Upvotes: 5

hege
hege

Reputation: 1017

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.

Upvotes: 3

tenpn
tenpn

Reputation: 4716

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"

Upvotes: 1

Douglas Leeder
Douglas Leeder

Reputation: 53285

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

Upvotes: 0

Jeff Moser
Jeff Moser

Reputation: 20053

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.

Upvotes: 12

Related Questions