Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save tenpn/1173044 to your computer and use it in GitHub Desktop.
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
Copy link
Author

tenpn 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