空のPerforce ChangeListの送信がエラーであることを防ぐにはどうすればよいですか。

StackOverflow https://stackoverflow.com/questions/5032688

質問

チェンジリストを送信しようとしたファイルは、Perforceによってエラーであると見なされます(p4 submit ...は終了コード1を返します)。これにより、プリデーションサーバーでは定期的な統合ビルドが失敗します( Zutubi's Pulse System )。 この場合、私はむしろビルドが成功することができます、おそらく警告で。

パルスには終了コードの再マッピング機能がありますが、Perforceは空のチェンジリストを送信した失敗とその他の送信失敗(このような検証トリガ障害、失敗したいのが失敗したい)との間で曖昧さを曖昧にしないようです。ビルド)。

すぐに明らかなように(しかし、私の心の中で、目立たれている)解決策は、p4 submitからの出力の行をカウントすることによってターゲットチェンジリストを空けるかどうかを最初にチェックするバッチファイル内のp4 openedの実行をラップすることです。または単に「ファイルなし」メッセージの場合はp4 submitの出力を解析し、バッチファイルから正常に戻します。

私が見ていないことをこれを処理するためのより良い技術はありますか?

役に立ちましたか?

解決

There are probably no good techniques just with Perforce, if I am understanding your problem correctly. The issue, as you have seen, is that the return codes from perforce command line runs are, well, ambiguous. Is a submission of an empty changelist really an error? Maybe, maybe not - might depend on who you ask.

It's is not really that advisable to look at return codes from 'p4' commands. Your best bet as you have suggested is to parse the output of the command and then do what you need to from there.

Most commands now support the -ztag option (see 'p4 help usage'), which will could make parsing the output a bit easier, depending on what you want to do. If your case, it is probably sufficient enough to just look for the text in the output and then decide what to do from there.

他のヒント

Before attempting to submit a changelist, you could first attempt to delete it.

p4 change -d ###

This operation will only succeed if the changelist is empty, so don't submit it (you have just deleted it). If it fails, there are files in the changelist, so go ahead and submit them.

However, if you use jobs, this won't work for you because you can't delete a changelist that has a job attached to it, even if it's empty.

I did ultimately end up parsing the output in a batch file, using something like this:

for /f "delims=" %%I in ('p4 submit -d "<message>" 2^>^&1 1^>NUL') do    
set SUBMIT_OUTPUT=%%I
if "%SUBMIT_OUTPUT%"=="No files to submit from the default changelist." exit /b 0

This is necessary since p4's "no files" message is actually writting to stderr normally. If the output is the message I consider "safe" I exit with a zero exit code, otherwise the script will continue with whatever error level was set by the p4 command.

Note that the "no files" message for a numbered changelist is slightly different, if you're using that.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top