Unshelved file needs resolve error - perforce

When i try to shelve a change
p4 shelve -r -c 1111111
it fails with errors:
<file x> - unshelved file for <user y> needs resolve
Shelve aborted -- fix problems then use 'p4 shelve -c 1111111'.
There used to be conflicts but they are resolved now, and p4 resolve says there are no files to resolve.

What this is telling you is that another user (user y) has a pending resolve from that shelved revision. Since you're replacing (or possibly removing?) that file from the shelf with the -r option, they might not be able to do their resolve and finish their unshelve operation.
Good lesson here is that if you do a p4 unshelve when you have local changes, make sure to follow it up with a p4 resolve quickly before the owner of the shelf deletes or changes it underneath you! :)

It turned out specifying the force option solved the problem:
p4 shelve -c 1111111 -f

Related

p4 unshelve doesn't bring new added files

It seems that p4 unshelve -s changelist doesn't bring the new source files that are added in the shelved changelist. Two questions:
Am I missing something?
Any workaround?
Thanks.
p4 unshelve should faithfully open every file that was shelved, for its corresponding action — add, edit, integrate, or delete. The opened file will be opened at the same working revision, with the same resolves (either pending or completed), and the same content.
To answer your two questions:
Yes, you missed something (but there's not enough information to know what).
To work around the problem, figure out what you missed and fix it.
Do the added files show up in p4 files #=SHELF? If not, they were never shelved in the first place. Go back and fix that.
Do you get an error message from p4 unshelve telling you that these files can’t be unshelved? If so, fix that.
Are the files already opened according to p4 opened? If so, either they did get unshelved or that’s the reason they couldn’t be unshelved.
I faced the same issue but for my case it's because of I have file(s) opened for add locally. Target shelved CL that I want to unshelve also has that file(s) opened for added as well. So if I try to unshelve target shelved CL, it will shout out similar to the following error message.
//depot/dir/file.h - can't unshelve (already opened for add)
So I have to do the following
p4 revert <file(s)> - revert all files opened for add. This won't remove the file(s), it will still be there. It will show message like //depot/dir/file.h#none - was add, abandoned
p4 unshelve -s <target-CL> - to unshelve target CL again, this time, there should be no error message. If you already unshelved previously but has error for those file(s) opened for added only, then you can do just p4 unshelve -s <target-CL> <file1> <file2> to unshelve only those file(s) opened for add only.
Done, now you can continue working.
p4 unshleve will open files for add if they existed in the changelist passed to -s.
There exists a case where added files specifically wouldn't be unshelved and that is when the files already exist and are writable. For such files, you should be seeing an error saying:
Can't clobber writable file /file/path
I used to run into this case when I do the following:
Shelve a changelist that has files opened for add on workspace1
Unshelve the changelist on workspace2
Revert all the unshelved files on workspace2, including the files opened for add
Now the files that were opened for add will exist in workspace2 and stay there in a writable state
Unshelve the changelist again on workspace2
If you inspect the output of p4 unshelve here you should see the error mentioned above
Run p4 opened on workspace2 and not find the files that were opened for add

Perforce: How to move unresolved files to a separate CL

I'm currently (and regularly) performing very large integrations (usually 50k+ files). In P4V, it is technically possible to display and manually work with those files, but it's slow and unwieldy.
Is there some way to move unresolved files to a separate CL without needing to write an application? I was taking a look at "p4 resolve -n" but I can't figure out how to use that output with p4 reopen (assuming this is even the best way of doing what I want.)
Any help would be appreciated.
You can use this:
p4 -F %localPath% resolve -n | p4 -x - reopen -c default
Explanation:
-F %localPath%: tells p4 to output paths in local format
resolve -n: means "list unresolved files without actually resolving them". (P4 Resolve)
-x -: Tells p4 we'll be working on a list of files, and '-' means that the list of files is coming from stdin (piped) (p4 Global options)
reopen -c default: reopen incoming specified files in given changelist ("default" can be replaced by an existing changelist number). (p4 reopen)
Update:
For very big changelists, sometimes the command gets stuck. You can do it in 2 steps to workaround the problem:
p4 -F %localPath% resolve –n > c:\p4_output.txt 2>c:\p4_errors.txt
p4 -x - reopen -c default < c:\p4_output.txt
Note: When reopening files that were moved, p4 reopen will only move "half" of the change (the add) and leave the delete in the previous changelist. I haven't found a solution other than moving those manually.
Something like:
p4 -F %localFile% resolve -n | p4 -x - reopen -c CHANGE
ought to do it. (Run "p4 -e resolve -n" to see the list of available variables in the output, I think localFile is the one you want.)
I had a similar problem sometime ago.
To move a Perforce changelist to another computer/workspace,
follow the steps given in the below link:
movng unresolved files/changelists

Deleting new files after a p4 revert

My workflow for testing my changes to our source code on a remote machine is the following:
1) On local machine: Shelve changes that I'd like to test
2) On remote machine (ssh):
$ p4 revert //...
$ p4 sync
$ p4 unshelve -s <changelist number>
$ ./run_test_scripts
This seems to work fine when I've only made changes to files that already exists. If I've added new files these will be created during p4 unshelve, but not deleted during p4 revert. The documentation says that this is what p4 revert does so it isn't unexpected, but causes some problems if I want to test the same files again:
$ p4 revert //...
<some file>#none - was add, abandoned
$ p4 sync
File(s) up-to-date.
$ p4 unshelve -s <changelist number>
Can't clobber writable file <some file>
Is there way I can delete the files abandoned Perforce?
I think what you're looking for is p4 revert -w. From the help:
The -w flag causes files that are open for add to be deleted from the workspace when they are reverted.
Note: I'm using the 2013.2/719516 client against a 2013.2/708877 server, in case that switch was added recently...
Edit: just reread your question - this is a workaround, perhaps not a full solution...
There is a setting in P4Win that allows you to overwrite files when unshelving:
Overwrite workspace files even if they are writeable
I normally use that in combination with another option (again in the gui):
Revert checked our files before unshelving
They solve my problem.
Looking in the console output while running this from the gui, it looks like it is the -f parameter in the unshelve command.
p4 unshelve -s <changelist> -f -c <changelist> <files>

how to list my shelved changes in perforce?

p4 shelve saved a lot of my effort to edit the same file with different changes.
The problem is after i shelved some changes, I start to forget what I've shelved.
Is there a way to list all the changes I've shelved?
I checked p4 help unshelve/shelve but could not find the option.
This should list all the shelved changes per user.
p4 changes -u <USERNAME> -s shelved
p4 changes -s shelved
My colleague find the answer for me, and I answer my own question here.
In the latest version of p4, you don't have to type out your username:
p4 changes --me -s shelved

How can I grab my local changelist and send it to someone else in Perforce?

How can I grab my local changelist and send it to someone else in Perforce? More specifically, I would like to send unsubmitted changes from a local pending changelist to another user's pending changelist.
set P4DIFF=C:\cygwin\bin\diff.exe
p4 diff -du -c 12345 > patch-to-head.diff
# On Other machine
patch -p1 < patch-to-head.diff
I may be wrong on the env var there, and you might have to do some fixups on the diff file, but the general idea is that you generate a GNU Unified Diff, that you can send to people that can use GNU patch to apply it.
P4 now has native support for the shelve operation in 2009.2. Both the client and server need to be at least 2009.2 to use this.
http://blog.perforce.com/blog/?p=1872
To shelve your pending changelist YOURCHANGE:
p4 shelve [-c YOURCHANGE]
The other user then does:
p4 unshelve -s YOURCHANGE [-c THEIRCHANGE]
In either case the "-c" arg can be omitted to use the default changelist instead. In the p4 shelve case it means a new changelist will be created and the files in your default changelist will be shelved into it; in the p4 unshelve case it means the shelved files from your changelist will be unshelved into the other user's default changelist.
Not sure exactly what you are trying to do, but you may also want to consider P4_Shelve. It allows you to put a load of pending changes away on a virtual shelf, and then grab them back again later. Depending on what exactly you want to achieve by sending a changelist to someone else, this could provide a part of the answer.
Linked from the P4Shelve site is P4Tar which may also be useful - this does all the packing on the client side so you just get left with a file you can send to someone else.
Perforce 2016, osx. Diff for pending changelist:
mac:src user$ cl=123456 && p4 diff -du $( p4 files #=$cl | sed s/#.*// ) > $cl.diff
output: 123456.diff
Applying patch:
mac:src user$ patch -p0 < 123456.diff

Resources