How to create a perforce empty changelist from command line

耗尽温柔 提交于 2019-12-19 03:13:20

问题


i'm trying to create an empty changelist from command line using the command p4 change -i but seems that this command does nothing, i don't get any error/success message, the command line simply return nothing and i have to kill it with ctrl+c.

My p4 client works, i'm able to see all my info and doing all other operations correctly, seems to have problem only to create a new pending changelist.

Anyone experienced the same issue?

P.s. I've checked the P4V way to create an empty changelist and it actually using the p4 change -i command without any issue, but if i try to use the same command from cli it will silently fail.


回答1:


If you're using the command line interactively, the regular "p4 change" command is the way to go:

p4 change

This opens the changelist spec in your editor so you can fill it out, and saves the changelist when you save the file in your editor and exit it.

If you're scripting, you can use "p4 change -i" but you need to make sure to feed it a valid changelist form via stdin. The "p4 change -o" command gives you the same form you get from "p4 change" (via stdout instead of your editor), so all that's left is to fill out the description and/or modify the list of files to be included. The --field option is useful here:

p4 --field "Description=My pending change" change -o | p4 change -i

If you want the new changelist to be empty rather than inheriting open files from the default changelist, blank the Files field:

p4 --field "Description=My pending change" --field "Files=" change -o | p4 change -i



回答2:


Just using "p4 change" will open up the change form in the editor and upon saving a numbered change is created




回答3:


My p4 doesn't understand --fields option. The following worked for me.

#Powershell commandlet
echo "Change: new`nClient: <client-name>`nUser: <user-name>`nStatus: new`nDescription: NewCL"|p4 change -i

Replace the items in <> brackets.

Here is the output of just the echo part.

#Powershell commandlet
PS C:\Users\sahil> echo "Change: new`nClient: <client-name>`nUser: <user-name>`nStatus: new`nDescription: NewCL"
Change: new
Client: <client-name>
User: <user-name>
Status: new
Description: NewCL

As you can see, the echo command just constructs a formatted string which p4 change -i accepts.

`n is used above for new line.

Note that I have excluded Files, as I wanted the change list to be empty.

Update - I updated my perforce installation and now p4 understands --fields option.



来源:https://stackoverflow.com/questions/38957155/how-to-create-a-perforce-empty-changelist-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!