P4 shelve of committed files - perforce

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.

Related

In Perforce, what changelist is assigned to a file after a resolve -am?

Server version: P4D/LINUX26X86_64/2013.2/938876 (2014/09/23)
My question is about what the resulting version number of a file would be after a "p4 resolve -am". Let's say I have a workarea in which I unshelve changes to my.file resulting in my.file#8 but the workarea has my.file#10 and there are conflicts. I do a "p4 resolve -am". I'm seeing that my.file is still my.file#8. Is that correct? Is there a way to tell if this is really neither #8 or #10 but the result of the merge of the two ?
Thanks!
A resolve -am modifies the contents of your working file (the one in your workspace), but does not create a new revision until you p4 submit. It does not change the pending changelist that the file is open in, nor assign a new submitted changelist to it.
The way to see what merges have gone into the working file is the p4 resolved command.
The p4 diff command will show you the line-by-line diff between what's in your workspace and the corresponding depot version (so if you did an unshelve into an edited file followed by a merge, this will be a combination of whatever diffs are in the shelf and whatever diffs you may have introduced in your own workspace). You can also specify a version argument to p4 diff to diff against arbitrary revisions (e.g. the shelved revision, an older depot revision, etc).

Options to preserver state of file and continue working with it

Suppose I've made some changes to a bunch of files and sent the changelist for review. The review may take up to 24 hours. During that time I might need to edit some of the files in the changelist, but when review is over, I'll need to be able to get back to the version of the file in the approved changelist. What options do I currently have to do that in Perforce?
One option that comes to mind is stashing the files and then reverting when needed, but in this way I'll lose the changes done on top of the stashed versions.
I've read about using task streams, is it something that can help me handle that situation?
I assume that the files have been shelved in the changelist for review (as opposed to emailing them off or using some other review mechanism). If so, I'd move the open files to another changelist:
p4 change
p4 reopen -c (new change) (files)
and continue working on them. The shelved versions of the files will stay in the old changelist.
If you need to go back to the old changelist, shelve your new changelist:
p4 shelve -c (new change)
and then revert your open files (they should be safe in the new shelved changelist now) and unshelve the old changelist to keep working from that point:
p4 revert (files)
p4 unshelve -s (old change)
There are lots of variations on this you could do, such as reverting and starting over from scratch rather than building your newer changes on top of the changes that are currently under review. If you do that, you'll need to merge the changes later, but Perforce will track all of that automatically and prompt you when it's time (as long as you're using Perforce commands to sync/revert/unshelve/etc -- if you start making your own backups and restoring them manually all bets are off because Perforce doesn't know what your edits are based on any more and can't guide you through the merge process intelligently).

re-submit changelist with new changelist number

I have submitted one file in perforce, and changes submitted by other user got reverted in merge.
Changes were not conflicting.
Is their a way, I can get that user's changes back. Means revert the revert.
Also how to submit a changelist again with new changelist number?
In order to revert a file (fall back to its previous version) you simply sync the previous version and submit that again.
For a single file the procedure goes like this:
# sync file at old revision (#3 in this example)
p4 sync //depot/file#3
# mark the file for edit
p4 edit //depot/file
# make perforce aware that something has to be merged
p4 sync //depot/file
# resolve (i.e. throw away the head revision changes and save those from #3)
p4 resolve -ay
p4 submit
If you have a changelist with several files (and not only edits, but also deletes & adds) the rollback is a bit more difficult.
See also this question.
Here's a smart script for that purpose and more info.
The 2nd part of your question I did not understand.
Submitting a change again with a new changelist number doesn't make sense, since a changelist contains diffs. If it was submitted once, then the diffs are already in the depot, so you can't submit the same diffs again.

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.

Cannot see a perforce version controlled file in my workspace

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

Resources