1

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.

2 Answers 2

2

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.

0

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).

3
  • What I want is --- when I do merging from src -> dest. Then, content of src and dest should appear exactly similar.
    – Jatin
    Commented Nov 6, 2017 at 11:12
  • Which means, if "dest" contains a new folder or file which was not in "src", then, it should get deleted.
    – Jatin
    Commented Nov 6, 2017 at 11:14
  • 2
    That missing piece is done by p4 copy -- see Bryan's answer. If you look at very old Perforce docs you can find a sequence of steps to do this manually with a combination of p4 integ -f and p4 delete, but p4 copy exists now and is easier. :)
    – Samwise
    Commented Nov 6, 2017 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.