use P4::test { SVR_OPTS => { case => 'insensitive' } }; use P4::TM { DATA_DIR => 'self' }; use Data::Dumper; use File::Copy; use File::Copy::Recursive 'dircopy'; use File::Path 'remove_tree'; P4::TM::add_mask_func sub { s/manuals\/v[0-9]{2}\.[0-9]{1}\/extensions/manuals\/vYY.H\/extensions/g; $_ }; `p4 configure set server.extensions.allow.unsigned=1`; `p4 user -o sampleExtensionsUser | p4 user -i -f`; dircopy $script_abspath =~ s/\.t$//r . '/*', 'checkCase'; tm `p4 extension --package checkCase`; remove_tree 'checkCase'; tm `p4 extension --install checkCase.p4-extension`; tm `p4 extension --install checkCase.p4-extension --yes`; unlink 'checkCase.p4-extension'; $stdin = `p4 extension --configure ExampleInc::checkCase -o`; tm `p4 extension --configure ExampleInc::checkCase -i`; $stdin = `p4 extension --configure ExampleInc::checkCase --name checkCase-instance -o`; $stdin =~ s/User that can.*/nobody/g; $stdin =~ s,\Q//depot/path/to/check/...,//depot/proj/...,g; tm `p4 extension --configure ExampleInc::checkCase --name checkCase-instance -i`; tm `p4 extension --list --type=configs`; `p4 client -o | p4 client -i`; `p4 depot -o toped | p4 depot -i`; write_file 'a', "a\n"; mkdir 'proj'; mkdir 'proj/DIR1'; mkdir 'proj/dir2'; write_file 'proj/file1', "file1\n"; write_file 'proj/FILE2', "file2\n"; write_file 'proj/DIR1/file1', "file1\n"; write_file 'proj/DIR1/FILE2', "file2\n"; write_file 'proj/dir2/FILE1', "file1\n"; write_file 'proj/dir2/file2', "file2\n"; write_file 'z', "z\n"; `p4 add -t binary+T ...`; #tm `p4 fstat -Ro -T depotFile,action -F ^headAction=delete -e default //...`; tm `p4 submit -d foo`; `p4 edit ...`; tm `p4 submit -d foo`; tm `p4 populate //depot/a //DEPOT/proj/b`; # bad depot case tm `p4 populate //depot/a //depot/proj/dir1`; # file as dir name tm `p4 populate //depot/a //DEPOT/proj/fILE1`; # file already exists #`p4 integ //depot/a //DEPOT/proj/fILE1`; #`p4 resolve -ay`; # todo: why is there no file here? #tm `p4 submit -d foo`; #`p4 revert //...`; unlink 'proj/file1'; write_file 'proj/FILE1'; `p4 add proj/FILE1`; tm `p4 submit -d foo`; `p4 integ //depot/a //depot/PROJ/dir1/file3`; `p4 resolve -at`; tm `p4 submit -d foo`; # filename collides with an existing file '//depot/PROJ/dir1'. `p4 revert //...`; `p4 obliterate -y //depot/proj/dir1`; `p4 integ //depot/a //depot/PROJ/dir1/file3`; # dir1 should be DIR1 `p4 resolve -at`; tm `p4 submit -d foo`; `p4 revert //...`; `p4 sync -fq`; # todo: hides proj/file1 missing? `p4 edit //...`; tm `p4 submit -d foo`; tm `p4 files //...`; # #diag 'stdout: '.Dumper $server->getSTDOUT; #diag 'stderr: '.Dumper $server->getSTDERR; __DATA__ [[17,19,20,23,28,29,46,48,50,51,52,63,67,73,78,80], [ 'p4 extension --package checkCase', 'Extension packaged successfully. ', 0, 'p4 extension --install checkCase.p4-extension', ' Would install Extension \'ExampleInc::checkCase\' Version: \'2019.1\' UUID: FDEA0A21-12CF-4D38-9D08-0063934FFD2F Developer: Perforce Software Inc. Description: [Example Extension, sample code] Example Extension to prevent submission of files that differ only by case to existing depot files. This is an approximate port of the following trigger: https://swarm.workshop.perforce.com/projects/perforce-software-sdp/files/dev/Server/Unix/p4/common/bin/triggers/CheckCaseTrigger.py. Note that this example does not implement the Python version\'s BYPASS_CASE_CHECK description option, Unicode normalization and rename detection. Note also that this version may have different performance characteristics, as it does not implement the same caching. License: BSD Homepage URL: https://p4-extensions.example.org/some_user_script Compatible products: p4d This was report mode. Use -y to perform the operation. ', 0, 'p4 extension --install checkCase.p4-extension --yes', ' Extension \'ExampleInc::checkCase\' version \'2019.1\' installed successfully. Perform the following steps to turn on the Extension: # Create a global configuration if one doesn\'t already exist. p4 extension --configure ExampleInc::checkCase # Create an instance configuration to enable the Extension. p4 extension --configure ExampleInc::checkCase --name ExampleInc::checkCase-instanceName For more information, visit: https://www.perforce.com/manuals/vYY.H/extensions/Content/Extensions/Home-extensions.html ', 0, 'p4 extension --configure ExampleInc::checkCase -i', 'Extension config checkCase saved. ', 0, 'p4 extension --configure ExampleInc::checkCase --name checkCase-instance -i', 'Extension config checkCase-instance saved. ', 0, 'p4 extension --list --type=configs', ' ... config checkCase ... extension ExampleInc::checkCase ... uuid FDEA0A21-12CF-4D38-9D08-0063934FFD2F ... revision 1 ... owner user ... type global-extcfg ... config checkCase-instance ... extension ExampleInc::checkCase ... uuid FDEA0A21-12CF-4D38-9D08-0063934FFD2F ... revision 1 ... owner user ... type change-content ... arg //depot/proj/... ... debugStatus none ... config checkCase-instance ... extension ExampleInc::checkCase ... uuid FDEA0A21-12CF-4D38-9D08-0063934FFD2F ... revision 1 ... owner user ... type change-submit ... arg //depot/proj/... ... debugStatus none ', 0, 'p4 submit -d foo', ' Submitting change 3. Locking 8 files ... add //depot/a#1 add //depot/proj/DIR1/file1#1 add //depot/proj/DIR1/FILE2#1 add //depot/proj/dir2/FILE1#1 add //depot/proj/dir2/file2#1 add //depot/proj/file1#1 add //depot/proj/FILE2#1 add //depot/z#1 Change 3 submitted. ', 0, 'p4 submit -d foo', ' Submitting change 4. Locking 8 files ... edit //depot/a#2 edit //depot/proj/DIR1/file1#2 edit //depot/proj/DIR1/FILE2#2 edit //depot/proj/dir2/FILE1#2 edit //depot/proj/dir2/file2#2 edit //depot/proj/file1#2 edit //depot/proj/FILE2#2 edit //depot/z#2 Change 4 submitted. ', 0, 'p4 populate //depot/a //DEPOT/proj/b`; # bad depot case', ' Populate aborted -- fix problems and retry. \'checkCase-instance\' validation failed: Your submission has been rejected because the following files are inconsistent in their use of case with respect to existing directories: Your file: \'//DEPOT/proj/b\' Existing file or directory: \'no such depot\' ', 1, 'p4 populate //depot/a //depot/proj/dir1`; # file as dir name', '1 files branched (change 6). ', 0, 'p4 populate //depot/a //DEPOT/proj/fILE1`; # file already exists', 'Can\'t populate target path when files already exist. ', 1, 'p4 submit -d foo', 'No files to submit from the default changelist. ', 1, 'p4 submit -d foo`; # filename collides with an existing file \'//depot/PROJ/dir1\'.', ' Submitting change 7. Locking 1 files ... Submit validation failed -- fix problems then use \'p4 submit -c 7\'. \'checkCase-instance\' validation failed: Your submission has been rejected because the following files are inconsistent in their use of case with respect to existing directories: Your file: \'//depot/PROJ/dir1/file3\' Existing file or directory: \'//depot/proj/DIR1/\' ', 1, 'p4 submit -d foo', ' Submitting change 8. Locking 1 files ... Submit validation failed -- fix problems then use \'p4 submit -c 8\'. \'checkCase-instance\' validation failed: Your submission has been rejected because the following files are inconsistent in their use of case with respect to existing directories: Your file: \'//depot/PROJ/dir1/file3\' Existing file or directory: \'//depot/proj/DIR1/\' ', 1, 'p4 submit -d foo', ' Submitting change 9. Locking 8 files ... edit //depot/a#3 edit //depot/proj/DIR1/file1#3 edit //depot/proj/DIR1/FILE2#3 edit //depot/proj/dir2/FILE1#3 edit //depot/proj/dir2/file2#3 edit //depot/proj/file1#3 edit //depot/proj/FILE2#3 edit //depot/z#3 Change 9 submitted. ', 0, 'p4 files //...', ' //.p4-extensions/.certs/C7-94-54-A9-C6-D7-2D-D8-09-12-47-FA-F9-BF-38-12-D5-8B-A0-FA#1 - add change 1 (text+F) //.p4-extensions/FDEA0A21-12CF-4D38-9D08-0063934FFD2F/checkCase.p4-extension#1 - add change 2 (binary+F) //depot/a#3 - edit change 9 (binary+T) //depot/proj/DIR1/file1#3 - edit change 9 (binary+T) //depot/proj/DIR1/FILE2#3 - edit change 9 (binary+T) //depot/proj/dir2/FILE1#3 - edit change 9 (binary+T) //depot/proj/dir2/file2#3 - edit change 9 (binary+T) //depot/proj/file1#3 - edit change 9 (binary+T) //depot/proj/FILE2#3 - edit change 9 (binary+T) //depot/z#3 - edit change 9 (binary+T) ', 0 ] ]
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 30809 | C. Thomas Tyler |
Code drop with newer versions of Extensions. Thanks to @jason_gibon. #review-30810 @jabson_gibson |