1

When using the following p4 command for a shelved file, the diff is also appended at the end of the output.

> p4 describe -S 1529307
Change 1529307 by who@client on 2015/09/10 14:03:56 *pending*

Comment 

Shelved files ...
... //depot/projects/afile.py#4 edit

Differences ...

==== //depot/projects/afile.py#4 (text) ====
1c1
< testing1-2-3-4-5-6-7
---
> testing1-2-3-4-5-6-7-8-9-10

However when doing the similar in P4Python, the data returned from the run('describe -S') function does not contain the diff of the versions.

{
'status': 'pending', 
'code': 'stat', 
'depotFile0': '//depot/projects/afile.py', 
'changeType': 'public', 
'action0': 'edit', 
'fileSize0': '28', 
'shelved': '', 
'client': 'client', 
'user': 'who', 
'time': '144036', 
'rev0': '4', 
'digest0': '8C425B5CF', 
'data': '', 
'type0': 'text',
'change': '1529307', 
'desc': 'Comment\n'
}

The only workaround I could think of is to use the depot-path from here to find the file, and then diff it with its previous version in the depot. However I still think that there should be an easier way that this information is embedded in P4Python.

Thanks!

ilke444
  • 2,641
  • 1
  • 17
  • 31

3 Answers3

2

The current solution I came up with is below. I hope P4Python provides an automated way soon, to visualize the diff of shelved changes. Feel free to let me know if you have a better solution.

data = p4obj.run('describe -S ' + str(changelist))[0]

files = []
i = 0
while data.has_key('depotFile'+str(i)):
    files.append((data['depotFile'+str(i)],data['rev'+str(i)],data['action'+str(i)]))
    i += 1
for f in files:
    name = f[0]
    oldRev = str(int(f[1]))
    oldFile = tempfile.mktemp()
    oldFilespec = '%s#%s' % (name, oldRev)
    p4.runinteractive('print -q %s > %s' %(oldFilespec, oldFile))
    editedFile = tempfile.mktemp()
    editedFilespec = '%s@=%s'%(name, changelist)
    p4.runinteractive('print -q %s > %s' %(editedFilespec, editedFile))
    DiffTwoFiles(oldFile, editedFile, label1=oldFilespec, label2=editedFilespec)
ilke444
  • 2,641
  • 1
  • 17
  • 31
0

I agree with you. I believe this is not actually P4Python's fault, but is because the Perforce server itself does not return the file differences if the 'describe' command is run in 'tagged' mode.

I think an alternate workaround is to do a "run describe" from your Python program, but then you have to parse the output yourself, unfortunately.

I believe there is already an enhancement request on file at Perforce to improve this behavior, but you could certainly make this request to Perforce and see if they will improve it. https://swarm.workshop.perforce.com/docs/contact.html

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
0

You could make the output untagged.

There is an example here:

need equivalent python command for p4 describe

Hope this helps, Jen.

Community
  • 1
  • 1
P4Jen
  • 1,003
  • 6
  • 6
  • Thanks for the pointer, Jen. However, for `data = p4.run('describe -S 1529717')`, I get http://pastebin.com/UzMdcc0s For `p4.tagged = 0 data = p4.run('describe 1529717')`, I get http://pastebin.com/pWEXjYrV and for `p4.tagged = 0 data = p4.run('describe -S 1529717')`, I get the same output as the first one. Unfortunately none of them contains the diff I need. I don't know why we get different outputs, maybe our perforce versions are different. – ilke444 Sep 11 '15 at 20:17