P4 Python描述搁置的文件更改

2024-05-14 18:26:51 发布

您现在位置:Python中文网/ 问答频道 /正文

当对搁置的文件使用以下p4命令时,diff也会附加在输出的末尾。在

> 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

但是,在P4Python中执行类似操作时,run('descripe-S')函数返回的数据不包含版本的差异。在

^{pr2}$

我能想到的唯一解决方法是使用这里的仓库路径来查找文件,然后将其与仓库中以前的版本进行比较。然而,我仍然认为应该有一种更简单的方法将这些信息嵌入到P4Python中。在

谢谢!在


Tags: 文件方法py命令版本diff仓库projects
3条回答

目前我想出的解决方案如下。我希望P4Python能很快提供一种自动化的方法,来可视化搁置更改的差异。 如果你有更好的解决方案,请随时告诉我。在

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)

你可以使输出无标记。在

这里有一个例子:

need equivalent python command for p4 describe

希望这有帮助, 珍。在

我同意你的看法。我相信这实际上不是P4Python的错,而是因为如果“describe”命令在“tagged”模式下运行,Perforce服务器本身不会返回文件差异。在

我认为另一种解决方法是从Python程序中执行“run-describe”,但不幸的是,您必须自己解析输出。在

我相信Perforce已经有一个改进请求在Perforce上得到了改进,但是您可以向Perforce提出这个请求,看看他们是否会改进它。https://swarm.workshop.perforce.com/docs/contact.html

相关问题 更多 >

    热门问题