SetChangeRestricted.py #1

  • //
  • guest/
  • perforce_software/
  • sdp/
  • main/
  • Server/
  • Unix/
  • p4/
  • common/
  • bin/
  • triggers/
  • deprecated/
  • SetChangeRestricted.py
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/bin/env python
#==============================================================================
# Copyright and license info is available in the LICENSE file included with
# the Server Deployment Package (SDP), and also available online:
# https://swarm.workshop.perforce.com/projects/perforce-software-sdp/view/main/LICENSE
#------------------------------------------------------------------------------

"""
Usage:
        setchange form-in change "/p4/common/bin/triggers/SetChangeRestricted.py %formfile%"

This script is designed to run as a form-in trigger. It will add Type: restricted to the
change form if it isn't already there.
"""

from __future__ import print_function
import re
import sys

def set_changetype(formfile):
    with open(formfile) as f:
        content = f.read()

    if(not re.search("Type:\trestricted", content)):
        content = content + "\nType:\trestricted\n"

    with open(formfile, "w") as f:
        f.write(content)


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: SetLabelOptions.py <formfile>")
        sys.exit(0)
    set_changetype(sys.argv[1])

    sys.exit(0)

# Change User Description Committed
#2 27331 C. Thomas Tyler Released SDP 2020.1.27325 (2021/01/29).
Copy Up using 'p4 copy -r -b perforce_software-sdp-dev'.
#1 18961 C. Thomas Tyler Released: SDP/MultiArch/2016.1/18958 (2016/04/08).
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/deprecated/SetChangeRestricted.py
#1 18936 C. Thomas Tyler De-emphasizing changeType=restricted, including deprecating
associated triggers.
//guest/perforce_software/sdp/dev/Server/Unix/p4/common/bin/triggers/SetChangeRestricted.py
#1 18449 Russell C. Jackson (Rusty) New trigger to force change to be type restricted to avoid by-passing the
default type using p4 change -i < form_without_restricted_set

#review-18296