-1

i have a file abc.txt checked in perforce. through python (using p4 python API) i want to have changelist number of latest revision of that file. please provide runnable code.

manish
  • 43
  • 2
  • 7
  • Please post the code that you have tried. – gaganso Jun 06 '16 at 11:50
  • 2
    `p4 changes -s submitted -m 1 ///abc.txt` is the CLI command that would provide the required changelist. Build on this and write a script. If you face any problems, edit the question. – gaganso Jun 06 '16 at 12:00

1 Answers1

2

You can see the changelist number in the output from the 'p4 fstat' command.

To run this using P4Python, use the code:

result = p4.run("fstat", "<FileName>")
print result

The output will look something like this:

[  
   {  
      'isMapped':'',
      'haveRev':'10',
      'headAction':'edit',
      'headModTime':'1465312503',
      'clientFile':'/users/jen/dvcs/usage/home/depot_create.rb',
      'headRev':'10',
      'headChange':'7666',
      'headTime':'1465312526',
      'depotFile':'//depot/scripts/depot_create.rb',
      'headType':'text'
   }
]

Hope this helps, Jen.

gaganso
  • 2,914
  • 2
  • 26
  • 43
P4Jen
  • 1,003
  • 6
  • 6
  • so this would provide all information about a file, right? Is there a specific API that would provide what OP wants to do. I am just curious. – gaganso Jun 07 '16 at 15:55