Perforce Customization To Revert Changelist
Attachech Python File: Download here Perforce Python script to revert Changelist
In Perforce if we check in any change list and in case if we want to revert the change list. Perforce does not have feature to Revert Change List.
We have to do it manually by using following steps.
1) Take a change list version which is predecessor of the current one which we want to revert
2) Do head sync to that change list revision.
3) Check out the files which we want to revert. Resolve them and check in
But we can very well eliminate the above three manual steps and automate the process of Reverting Change list by Customizing Perforce to have Revert Change List Feature.
This feature will be very useful if the Changelist which we want to revert have large number of files
There is no Risk with this feature because the changelist which we revert are not directly submitted. When we do a Revert Change List a new Change List will be created and we have the capability to resolve the conflict if there are more than one Revision for that file.
Required Software Version
Download Recent version of Python from http://www.python.org/download/ and Install Python and set the path for library files of python in the environment variables just like java.
Software Program Required for Customization
I have downloaded Python Program from the following URL which will help in Reverting Change List. (http://www.tilander.org/aurora/2007/06/reverting-a-perforce-changelis.html).
Perforce Client Side Changes for Customization
Following Customization needs to be done to add Revert ChangeList option in perforce.
1. Open Perforce
2. Go to Tools >> Customize
3. Click Add Button
4. Enter Name as RevertChangeList, Give the location of the Python Program
5. Give the argument as -c $c -p $p -u $u %c
C – Client
P – Port Number
Note : Make sure “Close window upon exit” is not checked initially for the first time. So that we can see the success message in console.
In case if it is checked. If the Python Program fails. Then we may not be able to see the message.
6. Once this is done then Click View Submitted Change List. Right click the change list which you want to revert and click RevertChangeList.
7. Once this is done all the files that were reverted will be available under Default Changelist.
8. Create New Changelist and move all from Default Changelist.
9. Check the whether they are reverted properly. If there are some version conflict then resolve them and checkin.
10. Using this feature I had reverted changelist Number : 163806
11. Outside Perforce also this utility can be run. We can also run the utility from windows prompt by giving following command
p4revert.py -c <Client> -p <Port> -u <User> <ChangeList>
p4revert.py -c Mramchandran -p 10.10.50.201:1666 -u jayesh 163806
This is not tested. It is also convenient to use through perforce.
1.If my Revert ChangeList contains file say A.java and that file is also part of another change list in the client machine. Then the file A.java will not be reverted.
2. Always check the number of files that are present in the changelist is same as same number of files that are present in the new change list once RevertChangeList is done.
1. The only limitation this tool has is the Revert ChangeList customization is written in Python. It will be good if we can understand the logic and convert to Java.
Contributed Made by: Ramchandran M
- Use of runtime variables to save into another variable using register in Ansible - September 6, 2018
- Ansible & Ansible Tower Variable Precedence Hierarchy - September 6, 2018
- How to use template in Ansible? - September 6, 2018