Perforce P4V Adding a new file to the depot - perforce

I'm new to Perforce but I was able to successfully create a depot with a whole directory tree. Now I'm trying to add a file to one of the folders within that tree and I'm having trouble finding how to do that. I can see the file in the Workspace tab when I navigate through my computer but when I right-click the file there's no option to add it to a Pending Changelist. Appreciate any suggestions. Thanks.
Tony
Edit: I feel like I'm making hash of this thing. So I created a new workspace and located the folder containing the file I wanted to add. Then I right-clicked the file and selected "Mark for Add". Then I went to submit and got this error:
//depot/main/SSRS/1 SQL Code/Voucher Query.docx - warning: cannot submit from non-stream client
No files to submit.
Submit failed -- fix problems above then use 'p4 submit -c 5'.

The previous answer shows how to add a file from the command line, but you were asking how to do it with P4V.
If you right click the file in your Workspace view you should see the option "Mark for Add". You can also use the toolbar button with a small red + sign, 4th from the left.

If the file is in the folder, run:
p4 add foldername/file
Then you can
p4 submit

Your depot is a stream depot (the icon should have "waves" in it...)
Set up a new depot, a "local" one, and use that one.

In my case it just worked by logging off, killing the task in Task Manager and finally re-starting my Perforce.

Related

Move all existing changes under a folder to desired changelist in Perforce

If changes for a folder already exist in the default changelist (or other changelists), I want to collect them all in one changelist. How can I accomplish this in perforce, preferably P4V?
From the command line:
p4 reopen -c CHANGE //depot/folder/...
In P4V, select the files and do Actions > Move Files to Another Changelist.
Perforce doesn't understand relative directories, so you have to type the full path name, which I hated doing each time. So I added the command from #sam-stafford's answer as a custom tool to P4V.
To add the command to the Perforce GUI:
To use, you can right click the depot folder and choose "Move all changes under folder to changelist.."
Note: The changelist should be an existing one. I don't know how you would create a new one from the custom tools.

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.

Add new folder to depot in P4V client

I want to create a private branch folder in a depot using perforce visual client. Can somebody tell me how to do it? I looked up on Google but there is so little help for a P4V user.
Restating the question:
I have created a local directory: c:/depot/abc/myfile.txt. My p4v is mapped with the central repository as //depot... c:/depot/...
How do I submit abc/myfile.txt to the repository?
After reading your question, it sounds like you don't have any files in your depot yet? If that's the case, then you just need to add the files to your depot, not integrate. Here's how to do that:
In the edit workspace dialog, set the root to c:/depot
Then, change your workspace mapping to //depot/... //<workspace-name>/... as leaving the slash off as it is in your question can cause problems.
In the P4V workspace view, find the file that you want to add to the depot.
Right click that file, and select "Mark for add..." which will add it to a pending changelist.
Repeat step 3 for all the files that you want added (you can also multi-select files and then mark them for add).
Once you've got everything marked for add in a pending changelist, right click that changelist and pick "Submit" to commit the files to the depot.
Right click on the branch you want to branch from, and select Integrate(if it's 2011.1 you would select "Merge/Integrate") Then in the box that pops up, type in the target.
Note that you must have submit permissions in order to create the branch in the new location. So
//depot1/main/...
//depot2/sandbox/...
If you have submit permissions to //depot1 but not to //depot2 you wont' be able to branch from //depot1 to //depot2, but you can branch from //depot1/main/... to //depot1/sandbox/... as long as you have permissions for all of //depot1
If you're just starting out with P4V, consider spending some time reading this: http://www.perforce.com/perforce/doc.current/manuals/p4v-gs/index.html and this: http://www.perforce.com/perforce/doc.current/manuals/intro/index.html
There are many more docs at the Perforce site, but these are a good place to start.

How can I instruct Perforce to merge instead of overwrite or revert when unshelving a file?

How can I instruct Perforce to merge changes into an existing, open, and modified file in the workspace when unshelving a file shelved in the depot? The only options that Perforce appears to offer the user is to overwrite or revert the existing file in the workspace, but this does not allow, for example, to unshelve and integrate changes to the same file from multiple change lists. Is there a way around this limitation?
What I typically do is right-click on the shelved file and select "Diff Against Workspace File". When you open up the Diff tool, you can select a button in the toolbar to "Edit file in right pane". This essentially starts a two-way merge. With each difference you can select the changes you want from the shelved file (differences are selected from the workspace file by default).
However, it would be nice if Perforce added a type of merge feature to do this more automatically.
Edit to add:
Perforce now has a built-in capability to merge files when unshelving. If the user unshelves a file that is also checked out, and "Revert checked out files before unshelving" is unchecked, Perforce will mark that file for resolve. I looked through the release notes and was not able to find in which version this capability was added, but based on this link (see near bottom of p4 unshelve description), it was added no later than 2012.1.
Edited again to add:
That feature was added in release 2011.1 of the server. Here's the release note:
#299614 (Bug #38221, #39099) **
Unshelving a file opened for edit over a file already opened
for edit in the workspace is now allowed. A resolve record is
created when unshelving, and the user must then run 'p4 resolve'
to resolve the workspace files with the shelved files.
If you checkout your file, and then try to submit it, it will give you the option of getting the latest revision without replacing your copy. Then it will subsequently will give you the ability to run a merge tool, where you must resolve any conflicts before submitting.

Resources