Jatin
Jatin

Reputation: 1987

How to do p4 (perforce) merge using command line?

I am writing a batch script on windows for p4 merging.

In p4, I have a source and destination folder as follows:

source : //depot/a/b/c/src/

destination: //depot/a/b/c/dest/

All I want is to replace the entire content of "dest" with "src".

So, before merging if source looks like this:

src/Folder1/1.txt (content is 1111)

src/Folder1/2.txt (content is 2222)

src/Folder2/1.txt (content is 3333)

src/Folder2/2.txt (content is 4444)

and before merging, dest looks like this:

dest/Folder1/1.txt (content is 5555)

dest/Folder1/3.txt (content is 6666)

dest/Folder4/1.txt (content is 7777)

dest/Folder4/2.txt (content is 8888)

Then, after merging, "dest" should look like this:

dest/Folder1/1.txt (content is 1111)

dest/Folder1/2.txt (content is 2222)

dest/Folder2/1.txt (content is 3333)

dest/Folder2/2.txt (content is 4444)

Notice:

Folder4 gets deleted from dest because it was not there in src.

Folder2 gets added into dest because it was there in src.

What I am doing is:

  1. p4 integrate //depot/a/b/c/src/... //depot/a/b/c/dest/...
  2. p4 resolve -at
  3. p4 submit -d "merging content from src to dest"

But, it's not giving me desired behavior. Please help.

Upvotes: 1

Views: 747

Answers (2)

Bryan Pendleton
Bryan Pendleton

Reputation: 16349

Since you say

All I want is to replace the entire content of "dest" with "src"

you should use p4 copy, as in:

p4 copy //depot/a/b/c/src/... //depot/a/b/c/dest/...

See the docs, and don't forget to p4 submit afterwards.

Upvotes: 2

jamesdlin
jamesdlin

Reputation: 89965

One problem is that p4 integrate will integrate only previously unintegrated changes. If some changes were previously integrated (and altered due to merge conflicts), your p4 integrate //depot/a/b/c/src/... //depot/a/b/c/dest/... command will not redo them.

To clobber dest from src, I think you need to add the -f flag when using p4 integrate to ignore previous integration history (and then follow it with p4 resolve -at as before).

Upvotes: 0

Related Questions