Reputation: 701
With the perforce GUI, it's possible to unshelve files from a pending changelist into a new changelist. I noticed in the log that the GUI program accomplishes this by first creating a new empty changelist and then unshelving into that new changelist.
How would one do this from a batch script? I have a list of shelved changelists and I would like to unshelve each of them into new pending changelists.
Upvotes: 1
Views: 2417
Reputation: 5558
Here is a PowerShell cmdlet to create a new numbered changelist:
function New-Changelist {
[CmdletBinding()]
param (
[Parameter(Mandatory=$false)]
[string]$Message
)
process {
$cl = p4 --field "Description=$Message" --field "Files=" change -o |
p4 change -i |
select-string "\b(\d+)" |
ForEach-Object {$_.matches[0].value}
Write-Output $cl
}
}
It outputs the changelist number, so you can easily add that to the unshelve command:
$cl = New-Changelist -Message "Changelist for unshelving"
p4 unshelve -s 99999 -c $cl
Upvotes: 0
Reputation: 12223
Here's a bash function version:
# Takes shelved changeset # as single argument and unshelves to a new changeset
p4unshelve() {
p4 change -i <<< "Change:new"$'\n'"Description:Unshelve $1" | awk '{ print $2 }' | p4 unshelve -s $1 -c $(cat)
}
Usage
p4unshelve 43245
This will not work as-is in a .bat file but could be used if you are using some form of Bash and could probably be modified to it's .bat counterpart.
Upvotes: 2
Reputation: 701
It's not pretty but if you have a shelved changelist number that you want to unshelve into a new changelist you can run the following:
(echo Change: new && echo Description: test) | p4 change -i | for /f "tokens=2" %i IN ('more') DO p4 unshelve -s 99999 -c %i
If you know of a cleaner solution, please post it.
Upvotes: -1
Reputation: 3813
You can use the changes command with the -s shelved
option to retrieve a list of all your shelved changes.
If you create a new changelist for each shelved change, the -c <changelist>
option of the unshelve command allows you to specify the destination changelist.
Upvotes: 0