Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copy-PendingChangelistToNewBranch.ps1
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;
}
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;
}
@tenpn

This comment has been minimized.

Copy link
Owner Author

commented Aug 26, 2011

Written to answer the corresponding stack overflow question:
http://stackoverflow.com/questions/2472541/perforce-how-do-i-p4-integrate-a-local-uncommited-changelist/7202662#7202662

The script pulls all files out of the changelist description for the passed changelist number, 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.