In Git, I can use add to mark a file as merged.
In SVN, I can use resolved to mark a file as merged.
But in perforce, I cannot find a command to do this job. Do anyone know if perforce has a command like this?
Update:
I'm trying to develop a SCC wrapper for perforce and it can merge files within its environment. But after the merge (not by perforce), how can I tell perforce that this file is already merged and remove the conflict flag?
First you must integrate one file (the source) into the other file (the target).
p4 integrate //depot1/mydir/myfile //depot2/mydir/myfile
To submit the resulting changelist, you must resolve.
If you don't want to change the target, resolve accepting the target (ignore source)
file.
If you want to overwrite the target with the source file, resolve
accepting the source file.
If you want to merge the two files, accept merged.
The command for each of these is:
Accept target: p4 resolve -ay //depot2/mydir/myfile
Accept source: p4 resolve -at //depot2/mydir/myfile
Accept merged: p4 resolve -am //depot2/mydir/myfile
Finally, submit your change:
p4 submit # for default changelist
p4 submit -c 12345 # submit changelist # 12345
(there are additional resolve options that are interactive, outlined here: http://www.perforce.com/perforce/doc.current/manuals/cmdref/resolve.html#1040665
Probably you are looking for 'p4 resolve -am'.
If you provide more information, that would help others give you advice.
Related
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
I opened a bunch of files using p4 edit in my workspace and after making some changes on each of them, I decided to put them up for review so I staged them using p4 change and I got a number to mark the changelist. Once I did that I am not able to see the actual changes made in the workspace. The files have gone to a version prior to my p4 edit.
How do I revert my workspace to a changes pointing to a change-list?
p4 undo -c 403767
p4 undo #403767
p4 switch #403767
p4 revert -c 403767
None of the above seems to work. Also when I do a p4 opened -u <author-name> I have a string that says integrate change 403767 (text) for all the files listed.
The integrate change 403767 indicates that these files are open for integrate, so these can't be the files that you opened with p4 edit.
Files can be opened for integrate by the p4 integrate, p4 copy, p4 merge, or p4 undo command.
Further, if a file is listed by p4 opened, its current working state is already in your workspace. If you had opened the file for edit and neither reverted nor submitted it, p4 opened would say edit change 403767 and your edits would be in your workspace.
I will hazard a guess that what you are actually trying to do is integrate changes from another branch, and you're confused because those changes do not yet appear in your workspace. Run:
p4 resolve -am
p4 resolve
That might get things into the state you're expecting.
I am trying to write a maven compile command and want it to work on my colleagues' machines as well, and since they have a different perforce depot path than mine, I need a unified way to find it.
I have tried p4 where but it didn't help.
When you run the p4 where command make sure that you're using the correct client workspace.
E.g.:
p4 set P4CLIENT=my_client_name
p4 where //depot/...
or:
p4 -c my_client_name where //depot/...
The example you describe of p4 where returning the wrong path indicates that it's giving the answer in terms of a different client workspace.
In Perforce, I'm trying to do the merge, it has some conflicts and and created pending change list. Pending has more than 10000 files. Because of the long list of files they are are not visible in GUI. How to see the conflict files in GUI or command line?
To resolve non-conflicting files from the command line, do:
p4 resolve -am
After you've done that, you can resolve remaining files with:
p4 resolve
Or just get a list of the remaining (conflicted) files with:
p4 resolve -n
http://forums.perforce.com/index.php?/topic/5125-how-to-see-the-conflits-on-pending-change-list-during-merge/#entry20967
I am new to perforce. i have client created in linux.
and synced all the files from the repository. previously we were using svn to add and delete files to a repository.
in svn we have a command to know the status of the tree by "svn st" which shows all the local modifications(with symbol M) and also the non versioned files(with symbol ?).
i want to know what is the equivalnet command for this in perforce which shows all the non versioned files also.
Could anyone please help me with th command in linux.
In Perforce changes that have been "opened" (using P4 terminology) are attached to changelists. To list the changelists use the changes command:
p4 changes
To see the changes attached to a specific changelist use the change command:
p4 change -o $CHANGELIST
The status command without any options will preview files that are added, deleted or modified but that haven't been opened (which really means haven't been attached to a changelist).
p4 status
The status command or the reconcile command can also be used to "open" the changes. Note that the status command will of course exclude files you have ignored. If you want to see them use the -I option.