Created
August 26, 2011 09:22
-
-
Save tenpn/1173044 to your computer and use it in GitHub Desktop.
Copy-PendingChangelistToNewBranch.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!