Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to check if file is added or in edit mode/checked out?

I’m looking for the commands for these things:

Does file exist in depo? And if so is it checked out?

Is local file added?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thanks!

(extra info)

I’ve figured out the commands for add and edit, but I want to check the state first before i run these:

p4.run_add("C:\myfile.txt")
p4.run("edit", "//depot/myfile.txt")

the logic would be:

if file exists in depo and is not checked out:
   check out file
else:
   if file is not added:
      add file

>Solution :

To achieve this you could use fstat.

Check that file exist:

fstat_result =p4.run("fstat","//depot/myfile.txt")
if fstat_result and "otherOpen" not in fstat_result[0]:
    p4.run("edit","//depot/myfile.txt")

Check that local file added:

fstat_result =p4.run("fstat","C:\myfile.txt")
if not fstat_result:
    p4.run_add("C:\\myfile.txt")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading