P4PHP API - 如何使用 -f 标志保存 p4 客户端?
我正在使用 P4PHP API 构建一个 GUI,允许用户批量创建/更新客户端规范。只要客户端被解锁,这就可以很好地工作,但对于锁定的客户端,API 不会拾取 -f 标志(或者至少我不认为如此)。尝试保存锁定的客户端时,我收到以下错误消息。这很奇怪,因为我有一个 Python 脚本,它使用 Python p4 API 执行几乎相同的操作,并且它使用同一行来保存客户端,但它确实选择了 -f 标志。我不知道在这里做什么。
[错误]:锁定了“owner1”拥有的客户端“php_test_client”;使用 -f 来 强制更新。
这是我的 php 代码:
$p4 = new P4(); //instantiate p4 object
$p4->port = 'perforce:1666'; //set p4 port
$p4->user = $pUser; //set p4 user
try{
$p4->connect();
$p4->run_login($pPass); //login with provided p4 pass
$client = $p4->fetch_client($cNameSub);
echo "client fetched: " . $cNameSub ."\n";
$client['Client']= $cNameSub;
$client['Description']= $cDescrSub;
$client['Owner']= $cOwnerSub;
$client['Host']= $cHostSub;
$client['Root']= $cRootSub;
$client['View']= $cViewArraySub;
$client['Options']= $cOptSub;
$p4->save_client($client,"-f");
$p4->disconnect();
echo "client" . $cNameSub . " created successfully \n\n";
} catch (P4_Exception $e) {
// output errors
echo $e->getMessage() . "\n";
foreach ($p4->errors as $error) {
echo "Error: $error\n";
}
//TODO: log errors in db
}
我还尝试使用以下行保存客户端,但它也不起作用:
//try1
$p4->input = $client;
$p4->run("client", "-f");
//try2
$p4->run("client", "-f", $client);
//try3
$p4->input = $client;
$p4->run_client("-f");
I'm using the P4PHP API to build a GUI that allows users to mass create/update client specs. This works great as long as a client is unlocked, but for locked clients the API isn't picking up the -f flag (or at least I don't think it is). I get the below error message when trying to save a locked client. This is weird because I have a Python script that does pretty much the same thing using the Python p4 API and it uses the same line to save a client, but it does pick up the -f flag. I'm not sure what to do here.
[Error]: Locked client 'php_test_client' owned by 'owner1'; use -f to
force update.
Here is my php code:
$p4 = new P4(); //instantiate p4 object
$p4->port = 'perforce:1666'; //set p4 port
$p4->user = $pUser; //set p4 user
try{
$p4->connect();
$p4->run_login($pPass); //login with provided p4 pass
$client = $p4->fetch_client($cNameSub);
echo "client fetched: " . $cNameSub ."\n";
$client['Client']= $cNameSub;
$client['Description']= $cDescrSub;
$client['Owner']= $cOwnerSub;
$client['Host']= $cHostSub;
$client['Root']= $cRootSub;
$client['View']= $cViewArraySub;
$client['Options']= $cOptSub;
$p4->save_client($client,"-f");
$p4->disconnect();
echo "client" . $cNameSub . " created successfully \n\n";
} catch (P4_Exception $e) {
// output errors
echo $e->getMessage() . "\n";
foreach ($p4->errors as $error) {
echo "Error: $error\n";
}
//TODO: log errors in db
}
I've also tried saving the client with the following lines, but it doesn't work either:
//try1
$p4->input = $client;
$p4->run("client", "-f");
//try2
$p4->run("client", "-f", $client);
//try3
$p4->input = $client;
$p4->run_client("-f");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还需要 -i 标志!
这有效:
You need the -i flag also!
This works: