P4Triggers.py #2

  • //
  • guest/
  • sven_erik_knop/
  • P4Pythonlib/
  • triggers/
  • P4Triggers.py
  • Commits
# Change User Description Committed
#9 23692 Sven Erik Knop Simple trigger that logs sizes of submitted changelists.

Invoke with

python3 SizeLogger.py <config> <change>

where config is the filename of a config file containing the following two sections:
--------------
[P4]
port=1666
user=tom
password=A154ABF11F094B5D288CA0BE9F6F1086

[Log]
logfile=mylogfile.log
--------------

The P4 connection will use the standard defaults for any parameters not defined (such P4PORT, P4USER)
The default log file is called 'sizes.log'

Since this trigger is based on the standard P4Triggers.py, it will also create a separate log file (p4triggers.log) for any errors
that occur from a connection failure or other exception thrown.

Install this trigger like this in the triggers table:

   SizeLogger change-commit   //depot/path/... "python3 SizeLogger.py configfile.name %change%"

You need to have P4Triggers.py in the same path as the SizeLogger.py file.

---------

This trigger uses 'p4 describe' to collect all files in the change, filters out any files that do not have 'add' or 'edit' action, and
then sums up the remaining file sizes - so branches and renames are ignored.
The output in the log file is in JSON format for easy parsing.

---------

I also updated P4Triggers.py to add size and digest to the internal stored change
#8 21316 Sven Erik Knop Enhanced error output to print the actual exception.

Should make debugging a bit easier.
#7 8357 Sven Erik Knop Fixed missing print -> print() function for Python 3
#6 8179 Sven Erik Knop Added filefilter to the CheckCaseTrigger.

A filefilter is added as an additional key on the command line:

filefilter=path-to-my-filter-file

It should contain valid Perforce depot syntax lines, which are treated as
exceptions. Changed files that match any of the lines in the filefilter will
be allowed to submit even if they break the case consistency.

This is for cases where some files are Unix-specific and need to be able to
store two files or directories that only differ by case - as an exception.

Also fixed a tabbing problem in the P4Triggers.py file.
#5 7428 Sven Erik Knop Error output from Perforce is now written to the log file instead of stderr.
#4 7379 Sven Erik Knop Added output to a log file.
The default is the send output to p4triggers.log in the P4ROOT directory, this can be overridden with the parameter log=<path>
Also, errors now cause the trigger to fail with sensible output first.
#3 7372 Sven Erik Knop Rollback Rename/move file(s).
To folder "perforce" is needed.
#2 7370 Sven Erik Knop Rename/move file(s) again - this time to the right location inside a perforce directory.
#1 7367 Sven Erik Knop New locations for the Python triggers.
//guest/sven_erik_knop/perforce/P4Pythonlib/triggers/P4Triggers.py
#1 7370 Sven Erik Knop Rename/move file(s) again - this time to the right location inside a perforce directory.
# Change User Description Committed
#1 7367 Sven Erik Knop New locations for the Python triggers.
//guest/sven_erik_knop/triggers/P4Triggers.py
#1 6413 Sven Erik Knop Added some P4Python-based Perforce triggers.

P4Triggers.py is the based class for change trigger in Python modelled on
Tony Smith's Ruby trigger with the same name.

CheckCaseTrigger.py is a trigger that ensures that no-one enters a file
or directory with a name only differing by case from an existing file. This
trigger is Unicode aware and uses Unicode-comparison of file names, so it
can be used on nocase-Unicode based Perforce servers, which cannot catch
the difference between, say, "�re" and "�re" at the moment.

clienttrigger.py is a simple trigger that modifies the option "normdir" to
"rmdir" for new client specs only. It is meant as a template to create more
complex default settings like standard views.