Darcy
Darcy

Reputation: 5368

How to lock file without checking out in perforce

So I have some resource files I use for unit testing that I don't want changed (otherwise the unit tests will break).

Is there a way to lock these files using p4v without checking out the file?

I do not have admin rights btw.

Upvotes: 2

Views: 6746

Answers (2)

Dennis
Dennis

Reputation: 20571

There are two solutions that could work without needing to check the file out / locking it.

  1. Using P4 Permissions you can assign read access to the files or directory in the depot. Everyone will still be able read the files, which is essential for their work, however no-one without the correct permissions will be allowed to submit. Read more about the p4 protect command in manual.

  2. Write a P4 Trigger that checks for the files the files on pre-submit, if found reject the changelist. Read more about the p4 triggers command in the manual.

To do both of these, you will need help from your friendly superuser/administrator. Option 1 is by far the best solution as triggers can slow your server down if you have too many or them doing too much. It will up-to you administrator if they want to add the permission to the protect table.

Note: Permissions/Protect as synonymous, like Workspace/Client.

Upvotes: 0

Mike O'Connor
Mike O'Connor

Reputation: 3813

If you are willing to check the files out, it's pretty easy to solve. Just open the files for edit, and then lock them. As long as you keep them open and locked, they should be safe - though I believe an admin could forcibly unlock them.

You can always create a second workspace for locking them if you don't want to clutter up your main one.

Upvotes: 2

Related Questions