You can lock Perforce branch,depot or any other folder by using either
1) Protection table
2) Triggers
Using protection table:
You can lock a branch by just creating a new rule in Protection table. For example here, we are locking a branch called //dev/envision/esi/... by just providing only read permission to group xxx
read group xxx * -//dev/envision/esi/...
Here is a complex example.
The below protection table locks the branch //release/envision4.1sp1/... for every one else, except the user xxxats2. It locks for all the concerned groups release-xxx-4.0, xxx, yyy-group, yyy-all
=write group release-xxx-4.0 * -//release/envision4.1sp1/...
Points to remember:
Using triggers:
You can also lock a branch by writing a changelist submission trigger of type change-submit. Here the trigger logic work something like, when a changelist comes for submission, check for files under branch which you want to lock and also check for some .lock file created in a location accessible to server. If .lock file is present then cancel change submission.
Cons: This will definitely slowdown the CL submission time.
1) Protection table
2) Triggers
Using protection table:
You can lock a branch by just creating a new rule in Protection table. For example here, we are locking a branch called //dev/envision/esi/... by just providing only read permission to group xxx
read group xxx * -//dev/envision/esi/...
Here is a complex example.
The below protection table locks the branch //release/envision4.1sp1/... for every one else, except the user xxxats2. It locks for all the concerned groups release-xxx-4.0, xxx, yyy-group, yyy-all
=write group release-xxx-4.0 * -//release/envision4.1sp1/...
=write group xxx * -//release/envision4.1sp1/...
=write group yyy-group * -//release/envision4.1sp1/...
=write group yyy-all * -//release/envision4.1sp1/...
write user xxxats2 * //release/envision4.1sp1/...
=write group ddds * -//user_information/enVision/4.1_SP1/output/...
=write group uuuu-info * -//user_information/enVision/4.1_SP1/output/...
=write group yyy-all * -//user_information/enVision/4.1_SP1/output/...
write user xxxats2 * //user_information/enVision/4.1_SP1/output/...
Points to remember:
- The protection table order works from bottom to top. Hence place new locking rules below the existing rules in order for it be in effect.
- =write : means, provide all other privileges ( like read, open), except write
- Use "p4 protects //release/envision4.1SP1/..." command to find out which all groups/users already have write privileges. Remove write privileges from all the concerned groups
Using triggers:
You can also lock a branch by writing a changelist submission trigger of type change-submit. Here the trigger logic work something like, when a changelist comes for submission, check for files under branch which you want to lock and also check for some .lock file created in a location accessible to server. If .lock file is present then cancel change submission.
Cons: This will definitely slowdown the CL submission time.