How to open files in different ChangeList(s) into default change list? - perforce

Let's say I have few files under CL: 123 and few files under CL:456 . How do I open all the files together in one changelist or into a default changelist so that I can submit them together ?

In the P4 client:
p4 reopen -c <changelist#> //path/to/file
...will put it in your default changelist
In P4V, select all of the files you want to move to another changelist. You can either drag-n-drop them to the preferred changelist, or right-click and choose Move to Another Changelist...

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.

Add a file to shelved perforce changelist from another workspace

I have a changelist #1234 which I shelved from destop1. It has 5 files but I want to add another file to it say 6.c. The problem is when I do p4 edit -c 1234 6.c from desktop2, p4 errors out something like change 1234 belongs desktop1. desktop1 and desktop2 are different workspaces under same user.
How to release changelist 1234 and let me allow to do this?
One approach is to create a second changelist: using the desktop2 workspace, do 'p4 unshelve -s 1234' which will unshelve all the files into your second workspace in the default changelist. Then do 'p4 edit 6.c' on desktop2 and make your changes. Then do 'p4 shelve' and create a new shelved changelist (it will have a different changelist number).
The advantage of this approach is that you still have the first changelist in case you decide that you preferred the first version.
You can test the one changelist, then test the other, and decide which one you want to keep.
When you're all ready, you can submit the changelist you decided that you like, and delete the changelist that you decided not to keep.

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.

P4 shelve of committed files

Is there any option to shelve files that have been once committed? I need to expose them for a codereview. I've tried to fetch old versions and shelve them to produce something like back-diff, however it doesn't work for me: although files in shelve are old one, diff in P4V thinks they're identical to new ones.
You can diff a submitted changelist against the depot at a previous state. In your history tab, (View -> History in Menu Bar), select the changelist of interest. Drag the changelist onto the previous changelist number (be sure you have the top level of your depot/workspace selected, or at least a high enough point to include all your changes). This will open up a dialog which will be a type of directory diff which will show all the changed files. Use the arrows in the toolbar to move between changed files. Use the drag and drop and drag the old file onto the new one to see the changes between the files.
With the command line you can also do this: let's pretend your changelist is 1300
p4 diff2 ...#1299 ...#1300
but this uses the text-only 'diff'.
To produce the "back-diff" you wanted, you need to do the following:
Sync the relevant files to the revision you're interested in (p4 help sync)
Check out the relevant files into a new changelist (p4 help edit)
Sync the relevant files to the head revision (p4 help sync)
Resolve the files you have checked out by accepting target (p4 help resolve)
Shelve the files (p4 help shelve)
you can now provide the shelf as a diff of the changes that were made against head.
No. The files have been committed.
You want to back out the changelist, shelve that changelist, then back out the changelist again and submit to restore the depot to the state before you submitted.
How to do this
In P4V, select the 'Submitted Changelists' tab (View > Submitted Changelists) and find the changelist. Right-click the changelist and select 'Back Out Submitted Changelist ###'. It will prompt you create a new pending changelist.
In the 'Pending Changelist' tab (View > Pending Changelists), shelve the new changelist you just created.
Repeat step 1, creating a new pending changelist.
Submit.

Resources