1

I have a PowerShell script for nightly tests which look something like:

# Check out the result file
p4 edit result.txt

# Run tests (which write into results.txt)
RunTests

# Submit results (but only if changed from last test run)
p4 submit -f revertunchanged -d "Results from nightly tests" results.txt

This works great, except from every time results.txt is unchanged. At those times an empty changelist is left after the script is finished.

Is there any way to avoid this empty changelist?

1
  • I don't know Powershell I'm afraid, but I'd capture the output of p4 diff results.txt and test whether it contained any differences (something like is the output > 1 line). If it does, you need to submit, else you can just revert Feb 26, 2015 at 13:55

1 Answer 1

1

The empty changelist is no big deal; you can just delete it if you want.

But, you might instead change your script slightly: just before you do the submit, do 'p4 revert -a results.txt'. That will revert results.txt, but only if it is unchanged.

Only run the 'p4 submit' if the 'revert -a' did not revert result.txt, because that means you have actual changes in it. (Another way to check this is to run 'p4 opened results.txt' to see if 'revert -a' left it open or not.)

2
  • Thanks! Is there any way to check if the file was reverted, or do I need to parse the output from p4 revert?
    – HenrikL
    Feb 26, 2015 at 16:18
  • If it's no longer opened, it was reverted. So you could run 'p4 opened results.txt' to see if it was reverted. But it's probably just as easy to look at the output of 'revert -a' to see if it says 'reverted'. Feb 26, 2015 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.