A file (opened for edit) is already on a shelf, I then made more local changes, and want to update the file on the shelf. What is the best way to do this via the GUI P4v?
Shelving the changelist again achieves the goal.
p4 shelve -c -f
Will force update the entire changelist. This will overwrite the previous version of the file.
Related
I have made several checkins using perforce. I have no realized that all of them are unnecessary. I would like to revert all the changes for the last x revisions in the working directory, update the version number, and check in.
I am familiar with Mercurial. The way that I would it for that would be:
$ hg revert -r last_good_changeset .
$ edit version-number.txt
$ hg ci
Is there a way to do something similar in perforce?
In Perforce, a revert refers to restoring a file to the state it was in before it was checked out. What you're looking to do is back out a submitted changelist. This Perforce KB article has a few methods to do what you're trying to do, depending on your particular circumstance.
For example, if you have revisions #1 - #6 of a particular file, and you want to roll back to revision #3, you'd do this:
p4 sync myfilename#3
p4 edit myfilename
p4 sync myfilename
You're telling Perforce to get revision #3 from the depot, check it out for edit, then try to sync it back up to #head (the latest version in the depot). Since the file is checked out from an earlier revision, Perforce schedules a resolve so you need to tell it what you want to do with the file: accept the version in the depot, accept your local changes, or try to merge the two. You'll want to tell Perforce to accept the local version (or in Perforce parlance "yours"):
p4 resolve -ay myfilename
Now that it's resolved, you can submit it with:
p4 submit
If you have a series of files you want to do this with (for example, you've edited a bunch of files in a given directory and have checked them all in together several times, and you want to back out all of those), you can use changelist syntax as well. For example, if you want to roll everything back in a given directory to changelist 123, you can do this:
p4 sync //depot/some/path/*#123
p4 edit //depot/some/path/*
p4 sync //depot/some/path/*
p4 resolve -ay //depot/some/path/*
p4 submit
This will work for any revision modifier (see p4 help revisions for alternate methods of specifying the version you want).
The rollback function is specifically designed to do this. It goes back to a certain date/time or change list # and reverts all changes in the window you give it.
Simply right click on the file in question (P4V obviously) and select rollback. It will bring up this box. Not sure how to execute from command line...Ill see if I can figure it out and add that info.
I accidentally submitted a wrong changelist to my perforce server. I then backed out that changelist using the "backout changelist" option. But, these two changes appear in the history of all those affected files that they were once deleted and then added back again.
I want to be able to delete the history from perforce server of these two changelists. Is it possible. Can it be done via some Perforce administrator command.
EDIT: I have seen p4 change -d -f which can delete a changelist but this requires to use p4 obliterate on the files which were there in the changelist. Does this mean that I have to obliterate all the files which were affected by the changelist. This doesnt seem a viable solution for me as I do not want to delete those files. Should I only obliterate those specific two revisions of the files due to the two submitted changelists?
Your perforce administrator could call p4 obliterate to completely wipe out files, revisions and history.
But I'd strongly advise not to do so. It's a perfectly normal thing to rollback files/changes and to see the history of it.
In case you still decide to use p4 obliterate make sure you call it without the "-y" option first (preview) and then (if the output of what perforce says will happen is ok) call the same command with the "-y" option (to actually perform the obliterate).
If you call p4 obliterate with a file revision (e.g. p4 obliterate //depot/dir/file#5) then only the changes and history of that revision will be removed leaving all previous revisions and history intact. You can also obliterate a revision range.
When I shelve a pending changelist, changes to existing files are reverted, but newly added files are not deleted from the filesystem. I need to manually delete these files every time I perform a shelve operation. Is there anyway to automatically delete newly added files when shelving?
in p4, if you're willing to make it two operations, you can do a normal shelve on the changelist, and then do p4 revert -w on the same changelist, which deletes added files. i'm not sure how to do this in p4v.
It looks like P4V added this in a recent release!
https://www.perforce.com/perforce/doc.current/user/p4vnotes.txt
#40757 (Changes #1619278, #1618572)
The Shelve Dialog has an option to remove the files from disk that are marked for
'Add'.
To do this in p4v, you can create a custom tool, say "revert-added-file-and-delete", adding it to applicable context menus, with application p4 and arguments revert -w %F.
Unless someone knows of a way to chain custom tools together (and I couldn't find a way to do it), to do a shelve/revert will require a separate shelve followed by a use of the custom command, revert-added-file-and-delete.
Sure, except that shelving work is a fundamentally different beast. If I create a new class that uses a new function in an existing class, and then shelve both files, the new class remains, and is now referencing a non-existent function in the existing class. Now I've got build errors and have to manually delete the new file in order to get back to a clean slate, which is exactly what shelving work should do for me.
p4 shelve -c changelist_number
p4 revert -w -c changelist_number //...
I don't think that there is a way to do this. This behavior is consistent with reverting files that have been added. If you 'p4 add' a file and then revert it, it will not be deleted on revert. Seems like it would be bad behavior if it did! Losing a file and the work that has gone into the file on a revert would be very bad. Consider this: you code up a file in your editor, you save diligently, and finally you are ready to 'p4 add' it to perforce. Then you decide you don't want to do this so you revert and then you lose your file???
So reverting adds won't delete the file.
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
I am trying to remove a pending changelist in perforce. All the files (20 old) are new but have not be committed/submitted yet. So in p4Win, they show a RED + cross. I am failing to remove these files from the change list. How do I go about getting rid of these files?
Thanks for the answers to right-click and revert. I have tried that but it fails with the example error strings below.
Operation: user-revert
Librarian digest source/.../foo.c failed.
RCS checkout 1.715484 failed!
RCS no such revision 1.715484!
//source/.../foo.c#1 - was add, reverted
I've also tried the p4 revert command but it fails with same error(s).
Fixed with "revert -k" by perforce support group. They suspect it may be due to overlay values in the client workspace but have not been very specific.
How are you trying to remove the files?
It's been a while since I used Perforce in anger but I seem to remember that you just had to right click and revert the file.
I've just tried this and it worked OK for me (the programmer's lament!). It uses the following p4 command:
p4 revert //depot/test.txt
Where test.txt is the name of the test file.
Update
Does the new file still exist locally on your hard drive?
Does the path where the file would be in the depot still exist? ie. what's in the "..." of your path.
Revert files, right-click on file in change list and select revert, this will remove added files.
Maybe try Perforce support at this stage.
To remove all added files in current and sub directories:
p4 revert ...
In my case this happened because the RCS files (the actual files with ,v extension in the depot that contain all the revision information) were literally missing the information for the revision in question. I was able to restore the files from backup.
I had the same problem, I had added the .exe files but wanted to exclude them afterwards. The perforce documentation helped:
http://www.perforce.com/perforce/doc.current/manuals/p4eclipse/topics/adding.html
Excluding Files from Source Control
Important: you cannot exclude files after you have placed them under
Perforce control. If you have files opened in a changelist and you
want to exclude them from Perforce control, revert them from the
changelist before excluding them.
Worked like a charm.