Can't merge in Perforce - perforce

I have a branch that I created using p4 integrate but now the merge isn't behaving how I expect. When I merge, I get the following:
$ p4 merge -n ISSUE-49/... trunk/...
...
//depot/products/theProduct/trunk/some/directory/somefile.conf#1 - sync/delete from //depot/products/theProduct/ISSUE-49/some/directory/somefile.conf#1
...
That file was added on the ISSUE-49 branch (not deleted) so I don't understand why it wants to delete it.
When I try and use p4 integrate, I get:
$ p4 integrate -n ISSUE-49/... trunk/...
...
//depot/products/theProduct/trunk/some/directory/somefile.conf#1 - branch/sync from //depot/products/theProduct/ISSUE-49/some/directory/somefile.conf#1
...
It looks like it's trying to do a branch instead of a merge. Is it? How can I safely merge my changes from ISSUE-49 back into trunk?
I am trying to do this from the command-line on Linux using p4 2012.1. I have p4v 2013.3 on my Windows machine. I could use that if it would be easier.

A "merge" operation doesn't necessary always result in an "integrate" revision -- it depends on the current state of the target file and the changes made in the source file.
A "branch" revision is the first revision of a new file that is created as a copy from some other file. A "delete" revision represents a file that does not actually exist (usually this is a placeholder for a file that previously existed and has been deleted, but it can also be a placeholder for a file that has never existed).
The difference between "p4 merge" and "p4 integrate" is that with "p4 integrate" the file is opened for "branch" immediately rather than scheduling a resolve. If you run "p4 merge" followed by "p4 resolve -am" the file will be opened for "branch" exactly as if you'd run "p4 integrate".
Summary: everything is fine. Since the file does not exist in the trunk yet, a normal merge from ISSUE-49 will create it in the trunk as a new file. Whether you run "p4 integrate"+"p4 resolve" or "p4 merge"+"p4 resolve", the file will be opened for "branch", which is the action that creates it as a new file that is identical to the ISSUE-49 file.

Related

How to switch to a change-list when using perforce command line (p4)

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.

How to do I get files I deleted locally but didn't commit the changes?

I have deleted some files/folders in my local machine but I did not commit the changes to repository.
How to get the deleted files back?
I am not getting the deleted files after performing the p4 sync -f. Why I am not getting the deleted files after the force sync?
If you haven't reverted the changes Perforce will still think you want to delete those files so won't restore them.
You need to go to the pending changelist and do a "revert" on those files to get them back.
Use the "p4 revert" command:
p4 revert -c default //...
This "revert[s] every file open in the default changelist to its pre-opened state."
Source
If you don't want to revert all the files, move the files you want to revert to a separate changelist and use the "-c" option.
If you only have a few files to revert you can specify the name of the file:
p4 revert lib/libopenssl.a include/openssl.h
for example, reverts exactly those two files (thanks to Bryan).

Perforce "p4 sync" not working properly

Totally confused with the strange behavior of "p4 sync". Tried running the following commands
Note: The filename is not present in workspace
p4 sync //depot/filename
--- shows that files are up-to-date
p4 have //depot/filename
--- shows files not on client
Thought may be the perforce server thinks the file is present in its client's have database. So deleted the file using
p4 sync //depot/filename#none
--- shows files up-to-date
p4 sync //depot/filename#head
--- shows files up-to-date
Finally when I say
p4 have //depot/filename
--- shows files not on client
Then I did
p4 sync -f //depot/filename#head
--- shows //depot/filename - deleted as c:/workspace/filename
and in the end
p4 have //depot/filename
--- shows file not on client.
Any idea what could be the issue here?
Run "p4 files //depot/filename" and you will see that it is a deleted file.
If an older version of the file were present on your client (i.e. "p4 have" said there was something there), "p4 sync" would remove it. Since the file is already not present on your client, you are already "up to date".
Running "p4 sync -f" forces the issue and attempts to delete the local file even though the have table says nothing is there. (If you'd added a brand new file in its place and hadn't done "p4 add" yet, that file is now lost forever -- be careful when using "p4 sync -f"!)

How to discard all uncommitted changes in Perforce?

What is the p4 command to throw away all my uncommitted change in my Perforce workarea?
When using Git, the analogous command is: git reset --hard
If you haven't checked out the files you've edited, first do
p4 reconcile ...
to get the changes tracked by Perforce.
You don't need this if the changes you want to undo are already in any changelist.
Then, from the root of your workspace,
p4 revert ...
(... is the Perforce wildcard for everything under a given directory, not something you have to fill in yourself).
If you also want to delete untracked files from the disk, then if you're using the 2013.2 release or later, you can pass -w to p4 revert to also delete newly added files. See this answer for some background on this option.
The reconcile step would first detect these files and mark them for add, and then the revert step would unmark them for add and delete them. If -w isn't available then there's no clean way to do this and the files will be left untracked and on the disk after the revert.
p4 revert is the command you're looking for.
Remember, if you want to revert a specified changelist just, you must specify its changelist number like:
p4 revert -c changelistnumber
Or, if you are not running it from the workspace root, specify the workspace/client name, like:
p4 revert //myWorkspace/...

perforce command to know the non versioned files

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.

Resources