Skip to main content
 首页 » 编程设计

c#之Perforce api之如何命令 "Get Latest Revision"

2024年02月13日16fff_TT

我使用 Perforce Api (.net c#) 工作。

来源...

//--------Connect-------- 
Perforce.P4.Server server = new Perforce.P4.Server(new Perforce.P4.ServerAddress("111.222.333.444")); 
        Perforce.P4.Repository rep = new Perforce.P4.Repository(server); 
        Perforce.P4.Connection con = rep.Connection; 
 
        con.UserName = "PSY"; 
        string password = "gangnamstyle"; 
        con.Client = new Perforce.P4.Client(); 
 
        Perforce.P4.Options opconnect = new Perforce.P4.Options(); 
        opconnect.Add("-p", password); 
 
        con.Connect(opconnect); 
        con.Login(password); 
 
 
//--------How to ?-------- 
string ws_client = @"C:\ClientPath\"; 
string depot = "//depot/"; 
 
        Perforce.P4.P4Server p4Server = new Perforce.P4.P4Server(server.Address.Uri, con.UserName, password, ws_client); 
        Perforce.P4.P4Command com = new Perforce.P4.P4Command(p4Server); 
 
 
 
//--------Disconnect--------- 
con.Disconnect(); 

此“获取最新版本”的 Perforce 命令

请您参考如下方法:

如果您已经在您的机器上设置了 c:\clientPath 的工作区,并假设它的名称为 myWorkspace(如“p4v 中的“工作区”选项卡),然后:

client.Name = "myWorkspace"; 
client.Initialize(con); 
con.Client = client; // otherwise later things fail somewhat mysteriously 
con.CommandTimeout = new TimeSpan(0); // otherwise the sync is likely to time out 
 
client.SyncFiles(new Perforce.P4.Options()); // sync everything