Re: [p4] Anyone have a way to preview p4 protect updates outside of the P4V admin tool?

Sambwise <[email protected]> Mon, 2 Apr 2018 08:10:01 -0700
Newsgroups gmane.comp.version-control.perforce
Message-ID <[email protected]>
Posted on behalf of forum user 'Sambwise'.

The main thing is that additive protections lines are additive -- if you grant
someone "write" and "read" to the same file, the
"read" does not override the "write" even if it occurs
later.

The only way to override previously-granted protections is with a subtractive
line.  If you do not specify an exact permission level (with the =
syntax), a subtractive line removes ALL permission levels (so removing
"list" and removing "super" are equivalent and leave you
with zero access).

So in your example, if you want to grant write permissions as a general rule but
read permissions to one branch, in addition to the way you did it with =write,
you could do:

write user carl //depot/project/... write user carl -//depot/project/main/...
read user carl //depot/project/main/...   
If you want to model a protection table using the mapping API, figure out the
permission level you're looking for, and then read down it in order to build
a map containing the file specs for lines where:


  
-  The permission level includes the one you're looking for (e.g.
  "write" includes "read", and "=read" includes
  "read", but "=write" does not include "read")
    
-  The user or group specified matches the one you're querying for
    
-  The IP specified matches the IP you're querying for

At the end of it you have a map that includes some files and excludes some
files.  Doing a map check with a file path will tell you whether the
given user@IP has the specified level of permission to that file.

In the above example I did with Carl's protection table, Carl's map for
"read" access would look like this (because every line in the table
includes "read" access):

//depot/project/... -//depot/project/main/... //depot/project/main/...   
which in effect matches all files under //depot/project/... since the third line
completely overrides the second line.  Carl is therefore allowed to do
"read" level operations on everything in these path paths.

Carl's map for "write" access however looks like:

//depot/project/... -//depot/project/main/...   
since when building a map for "write" we ignore the last line (since
it does not include the "write" level of permission).  This
map of course excludes the mainline, and so Carl does not have "write"
access to the mainline.



--
Please click here to see the post in its original format:
  http://forums.perforce.com/index.php?/topic/5674-anyone-have-a-way-to-preview-p4-protect-updates-outside-of-the-p4v-admin-tool
_______________________________________________
perforce-user mailing list  -  [email protected]
http://maillist.perforce.com/mailman/listinfo/perforce-user