{"id":1558,"date":"2017-12-04T12:09:58","date_gmt":"2017-12-04T12:09:58","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=1558"},"modified":"2025-02-01T22:39:40","modified_gmt":"2025-02-01T22:39:40","slug":"reopen-and-revert-files-in-perforce","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/reopen-and-revert-files-in-perforce\/","title":{"rendered":"Reopen and revert files in perforce."},"content":{"rendered":"<p><strong>rajeshkumar created the topic: Reopen and revert files in perforce.<\/strong><br \/>\nIf the perforce user access has been removed\/blocked from user table and they have so many files opened. There could be two ways to to revert the files.<\/p>\n<p>Problem:<br \/>\np4 -p server:port -u username -c clientname -H hostname revert \/\/&#8230;<br \/>\nAccess for user &#8216;username &#8216; has not been enabled by &#8216;p4 protect&#8217;.<br \/>\np4 -p server:port -u username1 -c clientname -H hostname revert -k \/\/&#8230; ( tried using differernt user &#8216;username&#8217;)<br \/>\n\/\/depot\/rajesh\/file1.txt#none &#8211; belongs to user username, not reverted<\/p>\n<p>Solution 1:<br \/>\nSo I found one solution for it<br \/>\nanother user could take ownership of the files. Here&#8217;s an example:<br \/>\nUsers &#8216;rajesh&#8217; and &#8216;kumar&#8217; have each opened a file in workspace &#8216;temporary&#8217;.<br \/>\n>p4 opened -a \/\/depot\/test&#8230;<br \/>\n\/\/depot\/test.js#3 &#8211; edit default change (xtext) by rajesh@temporary<br \/>\n\/\/depot\/test2.js#2 &#8211; edit default change (text) by kumar@temporary<\/p>\n<p>I use the &#8216;reopen&#8217; command to change the user:<br \/>\n>p4 -u kumar -c temporary reopen \/\/depot\/test&#8230;<br \/>\n\/\/depot\/test.js#3 &#8211; reopened; user kumar<br \/>\n\/\/depot\/test2.js#2 &#8211; reopened; user kumar<\/p>\n<p>As these changes are now &#8216;mine&#8217;, I can revert them (noting the &#8216;-k&#8217; flag here):<br \/>\n>p4 -u kumar -c temporary revert -k \/\/depot\/test&#8230;<br \/>\n\/\/depot\/test.js#3 &#8211; was edit, cleared<br \/>\n\/\/depot\/test2.js#2 &#8211; was edit, cleared<\/p>\n<p>Solution 2: Add the missing user for temporary and follow the steps as in problem statement<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @<a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\"> twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajeshkumar replied the topic: Re: Reopen and revert files in perforce.<\/strong><br \/>\nProblem<\/p>\n<p>Error message when you try to delete the clientspec of users<br \/>\nClient &#8216;rajesh-test-client&#8217; has files shelved; use &#8216;shelve -df&#8217; to remove them, and then try again.<\/p>\n<p>Solution:<\/p>\n<p>Some times you may not able to delete client spec and user due to many reason. if user has opened few files in another users clientspec. please follow the steps as given<\/p>\n<p>p4 -p server:port -u username users | grep username<br \/>\np4 -p server:port -u username clients | grep username<br \/>\np4 -p server:port -u username client -f -d clientname<br \/>\np4 -p server:port -u username user -d -f username<br \/>\np4 -p server:port -u username opened -C clientname \/\/&#8230;<br \/>\np4 -p server:port -u username client clientname<br \/>\np4 -p server:port -u username describe 662626<br \/>\np4 -p server:port -u username protect -o | grep jfung<br \/>\np4 -p server:port -u username protect<br \/>\np4 -p server:port -u username login jfung<br \/>\np4 -p server:port -u username -c clientname -H localhost.localdomain revert -k \/\/&#8230;<br \/>\np4 -p server:port -u username clients | grep username<br \/>\np4 -p server:port -u username opened -u username \/\/&#8230;<br \/>\np4 -p server:port -u username client -d -f clientanam<br \/>\np4 -p server:port -u username user -d -f username<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajeshkumar replied the topic: Re: Reopen and revert files in perforce<\/strong>.<br \/>\nProblem: One more very interesting scenario where there is no files pending but few files shelved in pending change list.<\/p>\n<p>Answer:<br \/>\np4 -p server:port -u username client -d -f worksapce_name<br \/>\nClient &#8216;worksapce_name&#8217; has files shelved; use &#8216;shelve -df&#8217; to remove them, and then try again.<\/p>\n<p>p4 -p server:port -u username opened -a \/\/&#8230; | grep worksapce_name<br \/>\nNONE<\/p>\n<p>p4 -p server:port -c clientname changes -s pending -c workspace_name \/\/&#8230;<br \/>\nChange 217927 on 2011\/07\/13 by username@workspace_name *pending* &#8216;<enter description here> <saved'\nChange 214935 on 2011\/06\/29 by username@workspace_name *pending* 'TootlTip Bug.. Got Deffered '\n \np4 -p server:port -c clientname changes -s pending -c workspace_name -s shelved -c workspace_name \/\/...\nChange 217927 on 2011\/07\/13 by username@workspace_name *pending* '<enter description here> <saved'\nChange 214935 on 2011\/06\/29 by username@workspace_name *pending* 'TootlTip Bug.. Got Deffered '\n \np4 -p server:port -u username change -d 217927\nChange 217927 belongs to client workspace_name.\n \np4 -p server:port -c workspace_name change -d 217927\nChange 217927 belongs to user username.\n \np4 -p server:port -u username -c workspace_name change -d 217927\n \np4 -p server:port -u username -c workspace_name change -d 217927\nChange 217927 has shelved files associated with it and can't be deleted.\n \np4 -p server:port -u username -c workspace_name shelve -r -d 217927\nChange 217927 has shelved files associated with it and can't be deleted.\n \np4 -p server:port -u username -c workspace_name shelve -c 217927 -d\n \np4 -p server:port -u username -c workspace_name shelve -c 214935 -d\n \np4 -p server:port -u username client -d -f workspace_name\nClient workspace_name deleted.\n \np4 -p server:port -u username user -d -f username\nRegards,\nRajesh Kumar\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n<p><strong>rajeshkumar replied the topic: Re: Reopen and revert files in perforce.<\/strong><br \/>\nHow to reverts file opened by Perforce user?<br \/>\nTo Revert these changes \u2013<br \/>\nThis will list down the files and client&#8217;s name where the file has been opened.<br \/>\np4 -p Server:port -u rajesh opened \u2013a | grep other_user<\/p>\n<p>Now get the host name of the client,<br \/>\np4 -p Server:port -u rajesh client -o admin-ols-dump | grep \u2013i host<\/p>\n<p>Login as user from super user account.<br \/>\np4 -p Server:port -u rajesh login other_user<\/p>\n<p>Frame the commands and run it in the given fashion.<br \/>\np4 -p Server:port -u other_user -c <clientname> -h <hostname> revert -k \/\/depot\/releases\/filename.txt<br \/>\nRegards,<br \/>\nRajesh Kumar<br \/>\nTwitt me @ <a href=\"http:\/\/twitter.com\/RajeshKumarIn\" target=\"_blank\" rel=\"noopener\">twitter.com\/RajeshKumarIn<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>rajeshkumar created the topic: Reopen and revert files in perforce. If the perforce user access has been removed\/blocked from user table and they have so many files opened. There could&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[370],"tags":[375],"class_list":["post-1558","post","type-post","status-publish","format-standard","hentry","category-perforce","tag-revert"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1558","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=1558"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1558\/revisions"}],"predecessor-version":[{"id":1559,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/1558\/revisions\/1559"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=1558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=1558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=1558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}