The following is my folder structure
A
a1
a11
a12
a13
a2
i want to delete the entire tree of a1, including the files and subfolders in it.
how to do that using p4 delete. Is it possible to delete folders/ should i empty each and every file from the subfolders.
I have 3000 files in a1. New to perforce hence not sure of the command.
Note that "delete from the workspace" and "delete from the depot" are two different things!
Perforce lets you arbitrarily sync individual files and directories to different revisions, so you have a lot of flexibility over what's in your workspace at any given time -- you can have some files synced to the latest revision and others synced to earlier revisions, and Perforce will track the state of each file individually so that everything can be reconciled later if needed. To completely remove files from the workspace, just sync them to #none:
p4 sync A/a1/...#none
You can easily get these files back later with another sync operation. What you're synced to in your own workspace does not affect anyone else.
To open the files for delete (which lets you delete them for EVERYONE, not just you), use p4 delete:
p4 delete A/a1/...
Now the files are "open for delete". To complete the action of deleting them from the depot, do:
p4 submit
and now the files are deleted at the head revision -- the next time anyone else syncs these files, they'll be removed from that workspace.
Yes, you need to specify the path to a1 in you depot and follow with ... at the end.
Example:
p4 delete //depot/main/A/a1/...
Related
I have accidentally added a few folders to my default changelist that I don't want to submit to the server. How can I move these changes to another changelist, or remove them from the changelist without affecting the files on disk?
I have created a new changelist and moved some individual files / changes to this list but the folder contains many autogenerated files and this will take too long to do file by file.
I also looked at using the "revert" option but I think some of these files may have been previously added to the server in error. Reverting seems like it will change these files on disk to the previous server version.
You can specify the folder path in "Find File".
And use "*" to match all files in the contains filed.
Now you can select all the files in your folder by using "Ctrl+A"
From P4V you can multi-select the files in the pending changes window and then drag them into a new changelist. If they're all in the same directory they'll all be grouped together since it's sorted by depot path.
If you just want to have them not be open but also not modify them on disk, go to the command line and do:
p4 revert -k //depot/path/...
The -k option lets you keep your local files. This isn't available from P4V as far as I know (since it leaves your workspace out of sync with the depot state, it's usually a bad idea).
If you have generated files in your workspace that aren't supposed to go into the depot, you should exclude them from your client's View, e.g.:
View:
//depot/... //myclient/...
-//depot/path_to_generated_files/... //myclient/path_to_generated_files/...
This will essentially "hide" these files from all Perforce operations; you will never be able to add files from this workspace path, and if somebody else adds files to that depot path, you won't sync them down to your workspace. Two notes on this:
If you already have some of these files in the depot and they're currently synced, excluding them from your view and then syncing your client will remove them from your client. You can use sync -k, much like revert -k, to keep your local copies while telling the server that your client is properly up to date.
If you're using streams, you can do this for ALL clients of the stream by adding an Ignored path.
Hi I have two workspaces of different locations which have the same folder and file structures. Basically they are the forks of same workspaces.
I have some changes in my shelved files in 1st worksapce which i want to move to 2nd workspace. Using perfoce gui, i edited my 2nd workspace and mapped the 1st with it.
I then ran p4 command
p4 unshelve -s 100001 -c 1000002
where 100001 is shelved files in 1st workspace and 100002 is 2nd workspace pending changelist.
This put all those files into my 2nd workspace and it looks like it is done.
But i see files in pending changelist 100002 as //workspace//1stworksapce//.../abc.h and when i try to diff it keeps diffing with 1st workspace files.
Opening the files in pending changelist 100002 however, opens the files in 2nd workspace.
Un-mapping 1st workspace makes pending changelist angry and it says files are not mapped..
What do i need to do to make my pending changelist 100002 love its own workspace and not fiddle with 1st workspace anymore ?
Or is there any other way ?
My perforce version is 2014.2
My method of mapping the two workspace is using edit workspace by right clicking on workspace-list in gui and adding entry in workspace mappings. I noticed that whatever remains at bottom wins.. making me feel that it may not be a right way.
In Perforce, I deleted a number of files, which was recorded in an (unsubmitted) changelist. I then added replacement files in the filesystem, in the exact same locations as those that were deleted. As reverting them just fetches the old version back, how can I amend the changelist so that the files are as marked for edit with the new version?
You can run p4 revert -k to clear the files from the changelist without fetching the old copies back into your workspace. Then just run p4 edit on them.
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
I'm trying to open an existing Perforce application. I made some local changes, like deleting files, which I want to undo (that is, I want my local copy to exactly match the repository once more -- delete added files, restore deleted files, and undo changes).
When I try to revert using the p4v gui client, I see this error:
file(s) not opened on this client
What am I doing wrong?
I did manage to revert all the changed files, but not the added/removed files.
Edit: I did the following:
Connect to a Perforce server using p4v
Map a directory to my local file system (lets say C:\Perforce)
Get the latest version of the repository
Go to C:\Perforce in Windows Explorer
Delete some files and folders
Add some files and folders
I would like to get back to the "pristine" state, the copy of exactly what's on the server when I got the latest version of the repository for the first time.
By the looks of the edited description you added and deleted files directly on the filesystem and not through perforce. Therefore Perforce doesn't know anything about those changes so there is nothing to revert. Typically when you want to add a file you use 'p4 add" (or the equivalent p4v operation), and when you delete, you should use 'p4 delete' (or again, the equivalent p4v operation).
Really, the best option to get back to a pristine state is to nuke the local copy of the code in c:\perforce (in windows explorer), go to p4v, right click the area you want to sync, and choose "Get Revision..." and in the subsequent dialog, make sure that the "force operation" checkbox is checked. This will tell Perforce that you want a new copy of everything regardless of whether you had it synced or not.
You can also run "reconcile offline work" in p4v. Right click the depot area and choose that option. It will scan through the local folder structure and give you a report of what files have been added that don't exist in perforce, what files were deleted, and what files were modified. From that dialog, you can right click on local files that don't exist in perforce and delete them, or you can 'p4 add' them. You can also sync deleted files.
HTH.
Just an extra not to point out another cause for this.
If the file name contains an unusual character that cannot be translated correctly the name on the client will never match that on the server.
The solution in this case is to spot that character in the file name (it will be a question mark emblem on Linux) and use a wildcard to help identify the file to the server so it can delete it etc (p4 deleting the file is a way to go).
This answer may not be your case. This happened to me when I edited the files on my local disk without logging into p4.
A quick fix at commandline is:
p4 login # make sure you've logged in
p4 edit <filename> # let p4 know you've edited the file
p4 revert <filename> # revert to "pristine" state
You can use p4 reconcile -w to restore your client to the state of the server. There is an alias called clean, which is also available in P4V on the right-click context menu as Clean....
There are several additional flags to control whether added and deleted files are deleted or restored, respectively.
The -w flag forces the workspace files to be updated to match the
depot rather than opening them so that the depot can be updated to
match the workspace. The -a, -d, and -e flags when used with -w
update workspace files as follows:
-a Files with no corresponding depot file are deleted.
-d Depot files not in the workspace are added.
-e Modified files are restored to the last version synced.