samxiao
samxiao

Reputation: 2667

How to perform p4 submit operation ONLY on files which has diff?

I would like to know if there's a built-in function in P4 or a way to basically only allow the p4 submit to commit ONLY when the file has a diff. Let said I have rev 1, and I want to update the file with rev 2. But I should be only allow to make this change if rev 2 is actually diff from rev 1.

I checked P4 Manual on "p4 submit" , but I don't see much about this type of scenarios. The P4V GUI has one of these options, but how do we get this accomplish in command-line? Thanks.

p4 submit  -d "Update new drop $now" file.txt

Upvotes: 3

Views: 10987

Answers (3)

Dennis
Dennis

Reputation: 20571

There are a few options.

  1. Add either the -f revertunchanged or -f leaveunchanged options on the p4 submit command (p4 help submit).
  2. Perform a p4 revert -a command before submitting (p4 help revert)
  3. Change the SubmitOptions on your client (a.k.a your workspace) so that it will always revert unchanged files before submitting (p4 help client).

P4V can be considered a wrapper of the p4 command line, i.e. it performs the exact same commands.

Tips:

  • If you want to see what you commands P4V is performing, go to your preferences and change the log settings to output more detail.

  • Did you notice the way I formatted the help links? If you type that (e.g. p4 help submit) into your command prompt / terminal, it will display the help for that command. If you want to see what other commands are available type p4 help commands.

Upvotes: 13

borrible
borrible

Reputation: 17366

You need the -f reventunchanged or -f leaveunchanged options. See here under the options section for various options that are available to you. The former will automatically revert the unchanged files, the latter will leave them alone. In both cases changed files will be submitted.

Upvotes: 1

Bryan Pendleton
Bryan Pendleton

Reputation: 16359

I think 'p4 submit -f revertunchanged -d "my description" file.txt' might be useful to you.

Upvotes: 1

Related Questions