{"id":4577,"date":"2018-01-09T06:29:26","date_gmt":"2018-01-09T06:29:26","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=4577"},"modified":"2025-02-01T22:39:32","modified_gmt":"2025-02-01T22:39:32","slug":"perforce-customization-to-revert-changelist","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/perforce-customization-to-revert-changelist\/","title":{"rendered":"Perforce Customization To Revert Changelist"},"content":{"rendered":"<p><strong>Perforce Customization To Revert Changelist<\/strong><\/p>\n<p><strong>Attachech Python File: Download here<\/strong>\u00a0<a href=\"http:\/\/community.scmgalaxy.com\/pg\/file\/rajeshkumar\/read\/16737\/perforce-python-script-to-revert-changelist\" target=\"_blank\" rel=\"noopener\">Perforce Python script to revert Changelist<\/a><\/p>\n<p><strong>Purpose<\/strong><\/p>\n<p>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.<\/p>\n<p><strong>We have to do it manually by using following steps.<\/strong><\/p>\n<p>1) Take a change list version which is predecessor of the current one which we want to revert<br \/>\n2) Do head sync to that change list revision.<br \/>\n3) Check out the files which we want to revert. Resolve them and check in<\/p>\n<p>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.<br \/>\nThis feature will be very useful if the Changelist which we want to revert have large number of files<\/p>\n<p><strong>Risk<\/strong><br \/>\nThere 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.<\/p>\n<p><strong>Required Software Version<\/strong><br \/>\nDownload Recent version of Python from\u00a0<a href=\"http:\/\/www.python.org\/download\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.python.org\/download\/<\/a>\u00a0and\u00a0\u00a0 Install Python and set the path for library files of python in the environment variables just like java.<\/p>\n<p><strong>Software Program Required for Customization<\/strong><\/p>\n<p>I have downloaded Python Program from the following URL which will help in Reverting Change List. (<a href=\"http:\/\/www.tilander.org\/aurora\/2007\/06\/reverting-a-perforce-changelis.html\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.tilander.org\/aurora\/2007\/06\/reverting-a-perforce-changelis.html<\/a>).<\/p>\n<p><strong>Perforce Client Side Changes for Customization<\/strong><\/p>\n<p>Following Customization needs to be done to add Revert ChangeList option in\u00a0 perforce.<\/p>\n<p>1.\u00a0\u00a0\u00a0 Open Perforce<br \/>\n2.\u00a0\u00a0\u00a0 Go to Tools &gt;&gt; Customize<br \/>\n3.\u00a0\u00a0\u00a0 Click Add Button<br \/>\n4.\u00a0\u00a0\u00a0 Enter Name as RevertChangeList, Give the location of the Python Program<br \/>\n5.\u00a0\u00a0\u00a0 Give the argument as -c $c -p $p -u $u %c<br \/>\nC \u2013 Client<br \/>\nP &#8211;\u00a0 Port Number<br \/>\nU \u2013User<\/p>\n<p><a href=\"http:\/\/community.scmgalaxy.com\/mod\/file\/download.php?file_guid=16734\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/community.scmgalaxy.com\/mod\/file\/thumbnail.php?file_guid=16734&amp;size=large\" alt=\"image\" \/><\/a><\/p>\n<p>Note : Make sure \u201cClose window upon exit\u201d is not checked initially for the first time. So that we can see the success message in console.<br \/>\nIn case if it is checked. If the Python Program fails. Then we may not be able to see the message.<\/p>\n<p>6.\u00a0\u00a0\u00a0 Once this is done then Click View Submitted Change List. Right click the change list which you want to revert and click RevertChangeList.<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/community.scmgalaxy.com\/mod\/file\/download.php?file_guid=16735\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"http:\/\/community.scmgalaxy.com\/mod\/file\/thumbnail.php?file_guid=16735&amp;size=large\" alt=\"image\" \/><\/a><\/p>\n<p>7.\u00a0\u00a0\u00a0 Once this is done all the files that were reverted will be available under Default Changelist.<br \/>\n8.\u00a0\u00a0\u00a0 Create New Changelist and move all from Default Changelist.<br \/>\n9.\u00a0\u00a0\u00a0 Check the whether they are reverted properly. If there are some version conflict then resolve them and checkin.<br \/>\n10.\u00a0\u00a0\u00a0 Using this feature I had reverted changelist Number : 163806<br \/>\n11.\u00a0\u00a0\u00a0 Outside Perforce also this utility can be run. We can also run the utility from windows prompt by giving following command<\/p>\n<p><strong>Command :<\/strong><br \/>\np4revert.py -c &lt;Client&gt; -p &lt;Port&gt; -u &lt;User&gt; &lt;ChangeList&gt;<\/p>\n<p>Example:<br \/>\np4revert.py -c Mramchandran -p 10.10.50.201:1666 -u jayesh 163806<\/p>\n<p>This is not tested. It is also convenient to use through perforce.<\/p>\n<p><strong>Troubleshooting<\/strong><\/p>\n<p>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.<br \/>\n2. 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.<\/p>\n<p><strong>Limitations<\/strong><br \/>\n1. 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.<\/p>\n<p><strong>References<\/strong><\/p>\n<p>1.\u00a0<a href=\"http:\/\/www.tilander.org\/aurora\/2007\/06\/reverting-a-perforce-changelis.html\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.tilander.org\/aurora\/2007\/06\/reverting-a-perforce-changelis.html<\/a><br \/>\n2.\u00a0<a href=\"http:\/\/kb.perforce.com\/?article=014\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/kb.perforce.com\/?article=014<\/a><br \/>\n3.\u00a0<a href=\"http:\/\/www.python.org\/download\/\" rel=\"nofollow noopener\" target=\"_blank\">http:\/\/www.python.org\/download\/<\/a><\/p>\n<p>Contributed Made by: Ramchandran M<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Perforce Customization To Revert Changelist Attachech Python File: Download here\u00a0Perforce Python script to revert Changelist Purpose In Perforce if we check in any change list and in case if we&#8230; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[1960,4494,373,4493,375],"class_list":["post-4577","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-changelist","tag-customize-perforce","tag-perforce","tag-perforce-customization","tag-revert"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=4577"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4577\/revisions"}],"predecessor-version":[{"id":4578,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/4577\/revisions\/4578"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=4577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=4577"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=4577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}