I have a changelist with large number of files. I have to work on other request so I shelved the changes using p4 shelve -c 899. But when I do a p4 opened the files are still showing up in workspace.
Since the number is large I want to revert all files at once. I have tried p4 revert -c 899 * but this didn't work(by * it is taking all files in current directory rather than the changelist).
How can this be done?
From the root of your client, do:
p4 revert -c 899 .... This will revert all open files in the current directory and in all subdirectories that are in changeset 899.
Related
I shelved files from another branch and unshelved them in the current branch. The problem is that now I have around 1500 files in the changelist and I want to remove the files that are identical between the branches. I've tried with Revert Unchanged Files and it reverts 0 files, but when I individually diff them I get the message that they are identical.
So, how can I remove them from the changelist if they are identical to the current version.
I don't think P4V has an equivalent to this, but this is a one-liner at the command line:
p4 diff -sr | p4 -x - revert
In P4V you can "open command prompt" to get a command prompt that already has the P4 client settings configured correctly; then just copy and paste the above.
TL;DR: How do I sync an existing p4 workspace to a new label, so that all my previous changes are undone, and it is as good as a new sync?
Hi,
I have a perforce workspace synced to a label L1.
I added/deleted/edited a few files
I moved a few files inside a folder (mv a.txt b.txt new_folder/)
I want to cleanly sync this workspace to label L2 now.
I already removed all shelved and pending changelists, then tried
p4 reconcile -w ... && p4 revert -w ... && p4 sync ...#L2
Looks like it almost works, except that the files I moved inside a new folder do not get synced (p4 sync -f works though). But I do not want to use p4 sync -f on the entire workspace, as it would resync the unchanged files as well.
I am sorry if this question has been answered before, I am pretty new to perforce, so maybe could not find the correct terms to search for.
The ... path limits the scope of each operation to the current directory; if you ran those commands from a different directory than the one you moved the files to, that may be why they didn't get synced. I'd do:
p4 revert //...
p4 clean //...
p4 sync #L2
I have created a changelist for review by shelving some files. Now I want to implement the review comments. For that I tried unshelving the files but p4 opened still shows that the files are in the shelved changelist and not in the default changelist. I want to work on these files and again shelve the modified files in the same changelist. How to do this using p4 commands.
If you intend to update the same shelved changelist, it's actually best if the unshelved open files are open in the same changelist number, and not in the default changelist.
The overall process for updating one of your existing shelves (number NNN) is:
Make sure your workspace is empty of any work in progress: p4 opened should say "file(s) not opened on this client".
p4 unshelve -s NNN -c NNN
work on your files using your text editor, etc. If you open any new files, make sure you do: p4 edit -c NNN so that the new files, too, are in the same changelist number. You can also discard a file from this changelist number by doing p4 revert if that need should arise.
When you are ready to update your shelved changelist, do: p4 shelve -r -c NNN. This replaces all the files in the shelved changelist with the files that you have open in your workspace at that changelist number. If there is only one (or a couple) of files that you wish to replace in the shelved changelist, you can alternatively do: p4 shelve -f -c NNN //path/to/file to replace just that one file in the shelved changelist
p4 revert -w -c NNN //... to clean all those modified files out of your workspace and leave the changed versions only in the shelved changelist
You can repeat this sequence over and over to revise your shelved changelist through multiple code review cycles.
Note that this is not the only workflow that you can use with shelves. For example, it's also perfectly fine, and quite common, for developers to prefer to create multiple shelves, where each shelved changelist represents a point in time through the evolution of your work as you respond to review comments, etc.
But updating a shelved changelist in place is also a good workflow, and I use it regularly.
Watch out for one particular "gotcha", though, which is why the p4 revert -w is so important: files opened for add. If you have a file opened for add in your shelved changelist, and if you do a simple p4 revert, rather than a p4 revert -w, Perforce will leave the added file's data in your workspace on your laptop, whereas the -w flag tells Perforce to delete that file from your laptop entirely. When you do the p4 unshelve -s NNN -c NNN, if the shelved changelist contains a file opened for add, and if a file by that name is already present on your laptop, Perforce won't unshelve that file (because it doesn't want to clobber the data that's already present on your laptop), and so it won't re-open that file for add in your workspace. It will give you a "can't clobber writable file" message when it does so, but if you absent-mindedly overlook that message, then you'll not have the file open for add anymore, and when you do the p4 shelve -r -c NNN, Perforce will remove that file from the shelf, and you'll have accidentally deleted that file from your shelf. It's easy to avoid this problem if you always reliably use p4 revert -w (so put 'revert => revert -w' in your P4ALIASES file).
In perforce, I have several shelved changelists. I want to move the files from all of these shelved changelists to a new changelist.
I can do this with p4 reopen -c [new changelist no.] [file 1, file 2, etc], but it's laborious to copy and paste the names of each opened file from the previous changelists.
Is there a faster / better way to do this?
If you're looking to move the shelved files, you can use the unshelve command to do this. You could run p4 unshelve -s <shelved changelist> -c <target changelist> for each shelved changelist.
If the files are already open in the shelved changelist, I'm pretty sure you'd need to revert them first.
I need some help.
How do I get diff using p4 diff so that my patch contains
information about newly added files too ?
p4 add foo.cc
p4 diff > my.patch
my.patch should contain foo.cc
p4 diff compares files on your client with what's in the depot on the server. If you haven't submitted your changelist containing the new file to add, then the file isn't on the server, so there's nothing to compare.
To use p4 diff...
Mark the file for add, as above ('p4 add //myworkspace/myfile')
Submit the changelist to add the file to the P4 server ('p4 submit')
Checkout the new file locally with 'p4 edit //myworkspace/myfile'
run 'p4 diff //myworkspace/myfile'
If you haven't edited the file since step 3, it shouldn't show any differences. If you edit the file after checking it out (and save your changes locally), step 4 will show diffs.