偶尔会出现的一个问题是,确定上次在Perforce中同步到的更改列表的最佳方式是什么。对于自动构建系统将变更列表编号注入修订信息之类的事情,通常需要这样做。
发布于 2008-09-05 22:40:11
为了与Jeff的建议保持一致,我自己回答这个问题,他建议使用Stackoverflow作为保存技术片段的地方……
在命令行中使用:
p4 changes -m1 @<clientname>
只需替换为您的客户规范的名称。这将产生表单的输出:
Change 12345 on 2008/08/21 by joebloggs@mainline-client '....top line of description...'
其很容易被解析以提取变更列表编号。
发布于 2009-03-21 02:37:02
您可以尝试在"p4 files“命令的输出中查找最大更改数。但是,工作目录不应该包含同步后提交。这只比
p4 changes -m1 "./...#have"
因为后者似乎在服务器上运行,并且可能由于"MaxResults“限制而在大型源码树上失败。
$ p4 changes -m1 "./...#have"
Request too large (over 850000); see 'p4 help maxresults'.
$ p4 -G files "./...#have" | python c:/cygwin/usr/local/bin/p4lastchange.py
Files: 266948
2427657
其中p4lastchange.py基于2005年4月15日柯达信息网络/Ofoto的J.T.Goldstone的Using P4G.py From the Command Line演示文稿中的代码。
#! /usr/bin/env python
import sys, os, marshal
if os.name == "nt":
# Disable newline translation in Windows. Other operating systems do not
# translate file contents.
import msvcrt
msvcrt.setmode( sys.stdin.fileno(), os.O_BINARY )
lastcl = 0
num = 0
try:
while 1:
dict = marshal.load(sys.stdin)
num = num + 1
for key in dict.keys():
# print "%s: %s" % (key,dict[key])
if key == "change":
cl = int(dict[key])
if cl > lastcl:
lastcl = cl
except EOFError:
pass
print "Files: %s" % num
print lastcl
发布于 2015-10-12 04:14:21
对于我的客户来说,“推荐”使用p4 changes -m1 @clientname
大约需要10分钟。
这是我使用的:
p4 cstat ...#have | grep change | awk '$3 > x { x = $3 };END { print x }'
对于同一个客户端,需要2.1秒
https://stackoverflow.com/questions/47007
复制相似问题