知道 Perforce 中文件的修订列表编号

Know the changelist number of a have revision of a file in Perforce

我有一个文件example.pl。它有 5 次修订。我使用命令 p4 sync example#3 将文件 sync 更新为第 3 次修订。 现在,我想知道那个版本的那个文件的版本号。

示例:- 我想知道 version of the file at#3 的变化。即它必须显示 10418

 p4 file log example.pl
    //dev/example.pl
    ... #5 change 10591 edit on 2015/01/27 by abc (ubinary) 'added verilog '
    ... #4 change 10468 edit on 2015/01/09 by abc (ubinary) 'added read me'
    ... #3 change 10418 edit on 2014/12/21 by abc (ubinary) 'added pdf and modified pdp'
    ... #2 change 9185 edit on 2014/11/27 by new user (ubinary) 'Added cells'
    ... #1 change 9170 add on 2014/11/26 by user100 (ubinary) 'Fixed the physicalDesign '

做:

p4 files file#have

这将为您提供如下输出:

//stream/main/file#2 - edit change 4 (text)

如果您只想要更改列表编号,请执行:

p4 -Ztag -F %change% files file#have

这会让你:

4
 p4 filelog filename#`p4 fstat filename | tail -n2 | awk '{print }' | sed -n 1p` | sed -n 2p | awk '{print }'

这对我有帮助。它将直接 return 与文件关联的版本

p4 fstat filename | tail -n2 | awk '{print }' | sed -n 1p

Returns p4 fstat filenamehaverev 文件的修订版。 然后这将传递给 p4 file log filename#<RevisionNumber> 。 return 是该文件 RevisionNumber 以下的所有修订。然后我 select 4th field from the second line return 就是我 version associated with the file 。 示例:-

p4 stat example.pl | tail -n2 | awk '{print }' | sed -n 1p   -> `2`

那么,

p4 filelog filename#2 | sed -n 2p | awk '{print }' -> `9185`