0

I am trying to create a patch between two changelist using p4python. I am not getting any success. Below is my attempt:

$ vi patchp4.py

from P4 import P4,P4Exception
p4 = p4()
#Performed P4 Connection
if p4.connected():

     p4.run('diff2','-u','//depot/ran/y/...@changelist1 //depot/ran/x/...@changelist2')
else:
     print("Not Connected")

I am getting the below error: $ python3 patchp4.py

[Error]: 'Usage: diff2 [-d<flags> -Od -q -t -u ] file file2'
Missing/wrong number of arguments

On command line same options are working fine, while with python script it is throwing wrong argument error.

On Command Line:

$p4 diff2 -u //depot/ran/y/...@changelist1 //depot/ran/x/...@changelist2

Help me out with better guidance.

1 Answer 1

1

Each argument to the p4 command needs to be a separate argument to p4.run. You're only passing a single file argument here (with a space in the middle):

p4.run('diff2', '-u', '//depot/ran/y/...@changelist1 //depot/ran/x/...@changelist2')

Instead do:

p4.run('diff2', '-u', '//depot/ran/y/...@changelist1', '//depot/ran/x/...@changelist2')

FWIW, while Perforce does make it possible to create patch files, most of the things you'd do with a patch file in other systems are much more easily accomplished natively in Perforce by either p4 integrate or p4 shelve.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.