Perforce查看workspace sync到的changlist


 

 

一 查看workspace sync到的changelist 

perforce的workspace其實是一些特定版本的文件的結合,相比只將workspace對應到某個特定的changelist,此方法更靈活。changelist和文件間的關系為:每個changelist其實是某些特定版本文件的集合,但是並不是所有的版本的文件結合都對應到一個changelist。perforce允許用戶將workspace同步到文件的某些特定版本,不一定對應一個chagnelist。

 

使用如下三步來確定workspace的最新狀態
p4 changes 命令可以查看workspace中文件集合所對應的最高chagnelist:
p4 changes -m1 //...#have

 

可以使用如下命令查看workspace中是否所有的文件都被sync到了最高changelist:
p4 sync -n @<changelist retuned by p4 changes>
如果以上命令顯示所有的文件都已經是updated,則表示workspace當前被sync到了最高changelist。

 

同時使用如下命令來確保沒有文件被修改但是還沒有提交:
p4 opened

 

注意如下的depot語法是等價的:
//<workspace name>/...
//...@<workspace name>
//...#have
所以從perforce的官方的knowledgebase中看到的命令是p4 changes -m1 //...@<workspace name>

 

有的時候如果文件太多的話,會出現錯誤,可以使用如下方法:

$ 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 

#! /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


二 p4 cstat

cstat -- Dump change/sync status for current client  
p4 cstat [files...]
Lists changes that are needed, had or partially synced in the current client. The output is returned in tagged format, similar to the fstat command. The fields that cstat displays are:
change changelist number status 'have', 'need' or 'partial'

 

 

p4 changes的更多使用

Show the last five submitted changelists that include any file under the  project directory
Show the last five submitted changelists from client workspace  eds_elm.
Show the last five submitted changelists from user  edk.
Show any changelists that include file  file.c, as mapped to the depot through the client view, during the month of May 2000.
Output a single line showing the changelist number of the last submitted changelist.
Display all changelists submitted from April 1, 2001 to the present.
Display all changelists submitted  before April 1, 2000.

 

 

參考:
http://p4t3.lollotec.com/2008/01/what-changelist-is-my-workspace-synced.html 

http://www.perforce.com/perforce/doc.current/manuals/cmdref/changes.html 

 

 

完! 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM