Cannot see a perforce version controlled file in my workspace - perforce

I had made changes to a file and then shelved it.
Then I deleted the file.
Now I am not able to get it back to my workspace. I tried p4 sync -f and p4 unshelve ##.
What do I do ?

p4 unshelve is the correct command.
To figure out which shelf you need to unshelve, use p4 changes -s shelved and p4 describe -S
What's probably going wrong is that when you deleted the file, you still left it "opened" in Perforce (do p4 opened to see), so first do a p4 revert to revert the file, then you can successfully unshelve the shelf and you'll get your edited version back.

In p4v, go to the depot view, select the file, then hit ctrl-shift-s (pretty sure this works in linux too) this will open an explorer window which should be where the file is located. Maybe it's going to a different directory then the one you think?
If it's not there, right click the folder, and say get this revision, and check the force checkbox

Related

Why can't I delete this perforce changelist?

I'm new to perforce and somehow I've gotten myself into a weird state.
I have two files that I modified and somehow added to a change list (not the default changelist). I want to revert the changes and delete the changelist but I can't figure it out.
I have tried doing this:
p4 change -d 75697
Change 75697 has 2 open file(s) associated with it and can't be deleted.
So I tried to revert the files in the change list:
p4 revert package.json
package.json - file(s) not opened on this client.
Okay, so I guess I need to open the file?
p4 edit package.json
//a/b/c/package.json - can't edit (already opened on this client)
So I can't revert the file until I open it but I can't open it because it's already open? What's the deal?
You could be getting that error because your local package.json doesn't map to the actual depot path that's open (due to something tricky you've done with your client view since opening the file). It's hard to say without seeing more command output, but try just:
p4 revert -c 75697 //...
to revert all files in that changelist regardless of their paths.
If that doesn't work, check with your Perforce admin; either they've put you into some really weird permissions bind (i.e. they've revoked the access level to the files that you need in order to revert them) that they should undo, or they'll need to do a bit of light db maintenance (p4d -xf 925) to fix an inconsistency.

p4v doesn't delete new files added through `p4 add` after shelving

I've tried to shelve files today and checked the Revert checked out files after they are shelved option, and after shelving the files some files have been reverted, but some remained. It appeared that these were new files added through p4 add. Is it default behavior to not remove such files after shelving? Is there a way to remove them as part of shelving process?
What you did in P4V (shelve with reverting) is really a plain combination of two commands: shelve and revert. Behind the scenes, P4V will shelve your work (as it surely did) and then revert everything in your changelist.
Now, the revert command reverts p4 adds in such a way that they disappear from your changelist (the essence of reverting) but they remain on the local filesystem (to prevent inadvertent loss of code/data). Yes, you can argue that in this respect revert does not do a very good job of reverting your work completely, but obviously Perforce have decided to play it safe by not deleting your work.
As #Bryan Pendleton says, you can use p4 revert -w instead of plain p4 revert when you want to also delete your p4 adds from the filesystem. It's not a separate command, just a variant of p4 revert. However, there's no way to specify the -w flag (the -w behaviour) when running the "Shelve-and-Revert" combo action from P4V. (In fact, there's no way to specify -w even in the plain "Revert" action from P4V.)
I'm assuming you won't switch from P4V to the command-line (to run p4 shelve followed by p4 revert -w) just for this reason, so just remember that P4V has this little quirk and if needed, delete your local files after reverting them.

Recover deleted files from Perforce

I deleted a file from Perforce in the last month. Is there a way to retrieve it from P4?
If so, what command can I use?
Note: I'm not the admin for p4. And I don't want the file back in P4 but I just want it in my local workspace.
Also, I don't know the exact timeframe when I deleted it in last month...What command can I run?
I'm running P4 on windows. I'll appreciate if someone can provide equivalent command for windows
Thanks!
When you delete a file in Perforce, it creates a "deleted" revision, but the archive file is still there.
In the Perforce P4V GUI in the depot veiw, there is a filter symbol on top of the explore pane .
Click on this and select "Show Deleted Depot Files".
Find the file you want to restore and right-click on it. Select "Rollback..." and revert it to the previous revision of that file (before it was deleted.)
By default it will create a new changelist, be sure to select the one you want if you already have one.
On the command line:
p4 sync //depot/folder/subfolder/filename#changelist
You can use either the command line or the GUI, from the command line p4 sync -f forces the files to be resynchronized. For more information see the Perforce Knowledge Base.
If you haven't committed the change list of deleted files to the repository, right click on the folder containing the deleted files in p4v and choose Get Revision. Be sure to check Force Operation and then Click Get Revision. Then the deleted files will be restored from p4 server.
ref: https://forums.perforce.com/index.php?/topic/1479-how-to-restore-files-deleted-in-p4c-workspace/#entry4726

How to remove files from changelist in perforce without losing modifications?

I accidentally created a new changelist with files from WORKSPACE not from DEPOT and now under the changelist 4500 modified files are displayed (all dlls pdbs etc. alongside with the files i actually edited)
I'm using the p4v GUI. Is there anyway to undo this, without having to backup all the files then revert them using perforce, put them back and create a new changelist using DEPOT.
Thanks a lot, i hope there's a workaround :).
Not sure if this is what you're looking for, but to remove checked out files from your changelist without removing the edits:
p4 revert -k -c changelist# //...
If you haven't submitted the changelist, and all of the files are marked with '+' in the changelist in the Pending tab, you can click 'Revert' on the changelist. As long as the files were marked for add ('+') they'll be left intact in your workspace.
There's multiple ways.
Select View->Pending Changelists from the menu bar to view your pending changelist tab. You should see all of your checked out files grouped by changelist. Go to your desired changelist and expand into files.
You can Ctrl+left-click multiple files, then right-click on one of them and select Move to another changelist....
You can also choose to Submit... the files, and when the dialog box appears, their will be checkboxes next to each file. Uncheck the files you do not want to submit.
As another answerer mentioned, if you accidentally added files to Perforce that you did not intend to, you can indeed revert those files without actually deleting them (the only time a file will actually go away is when you do a p4 delete or p4 move.)
I encountered a similar issue, the solution i used is as follows:
1. Navigate to the workspace using p4v
2. Right click on one of the folders or files and click "Open Command window here"
3. run the following command to review dll or pdb respectively
p4 revert //....dll
p4 revert //....pdb
Thanks,
Lyon
If you right click on a pending changelist in p4v you should have the option to Revert unchanged files, which does exactly what it says on the tin.

"Actually, Perforce I don't want you tracking that file after all ..." how do I get Perforce to listen?

Sometimes I "Mark for Add" and add files to Perforce which I actually didn't want Perforce to worry about.
Is there a way to revert it so it just goes back to showing in P4V as an "untracked" item?
See my example:
I've added mil.ico and mil3.ico by mistake. I just want them to go back to looking like test.ico, ie. ignored by Perforce:
Even if I save a copy of the files, then delete, then put them back (all of which is a serious bore), P4V still knows they have a history and marks them as shown:
I just want Perforce to leave a file alone when I tell it to.
If you want to remove the last traces of the files from perforce, your only chance is through p4 obliterate. This will irreversibly remove file revisions or even file's complete history from perforce and will only work with administrator privileges. I don't know if obliterate is available through p4v, on the command line you would issue:
cd directory_of_accident
p4 obliterate accidentally_submitted_file
and if it looks like you and perforce agree on the file to forget
p4 obliterate -y accidentally_submitted_file
to seal the issue.
You can delete the items from the Perforce depot. Keep in mind Perforce will want to delete your local copy of that file so you should save it off in a different location, delete the file in Perforce and move the local version back.
Are you looking at your file structure through the Depot tab or the Workspace tab? It looks like it may be your Depot tab.
Try going to your Workspace tab then click on the Filter icon (looks more like a funnel) and ensure that "Show Files Not in Depot" is selected.
Hopefully looking through the Workspace tab, as opposed to Depot, will hide the deleted files, and selecting the appropriate filters will show your non-Perforce files.

Resources