How to revert an atomic changelist using perforce (p4)
If you are working in a professional IT company then it is must that your company must be using some repository software for developement purpose.
And most of these repository-softwares have started using softwares, which stores changes in form of atomic-changes (mean only change in group of files is stored as one single unit unlike CVS in which this happens only when you create tag after each and every checkin)
Perforce is one such software, widely used and by far the best. In this article, I am demonstrating the way to easily revert the changelist, if you need.
Say you have following changelist(CL) history :
2098989 : change 5
2097656 : fixed bug 67878
2034567 : made change into file1 for feature x
And depot path in which you want to revert CL is : //dvt/mti/dev/10.1/src/featureY/...
Say, you want to revert "CL#2097656 : fixed bug 67878"
Here are steps to perform that
1 cd /client/path/to/featureY/
move inside the client-directory, and make sure no file is opened inside it before you start reverting CL.
2. p4 sync ...@2034567 i.e. : just one CL below CL you want to revert.
this would sync your whole client featureY/... to CL#2034567
3. p4 sync -k ...@2097656 i.e. CL you want to remove
this command befools server that client is synced to 2097656
4. p4 edit <all files belonging to CL# 2097656> i.e. all files checked inside CL you want to revert.
5. p4 sync ... i.e. sync to the top CL
6. p4 resolve -duw -am ...
resolve any conflict, if there is any due to CL being reverted.
7. p4 submit -d"reverted CL#2097656" ...
make submission into repository and you are done. This generates a new CL# for this submission.
Interestingly you can revert this just-submitted CL using the above-method and have your original-changes back into action.