Comment mentions

This section describes how to customize how P4 Code Review treats user @mentions and group @@mentions in auto-complete drop-downs, comments, changelists, and review descriptions.

  • @mentions for users is only available for P4 Code Review 2017.1 and later.
  • @@mentiions for groups is only available for P4 Code Review 2017.3 and later.
  • If your P4 Server is configured to be case sensitive this will also apply to the names specified in your exclude lists.

If you make a configuration change, P4 Code Review will not use it until the configuration cache has been reloaded, this forces P4 Code Review to use the new configuration. You must be an admin or super user to reload the P4 Code Review config cache. Navigate to the User id dropdown menu, select System Information, click the Cache Info tab, and click the Reload Configuration button.

By default:

  • When a user uses an @mention or @@mention in a comment, P4 Code Review will auto-complete for all P4 Code Review users or groups respectively.
  • When a user edits the reviewers on a review, P4 Code Review will auto-complete for all P4 Code Review users and groups.
  • When a user edits the author of a review, P4 Code Review will auto-complete for all P4 Code Review users.

This behavior can be fine tuned with the mentions configuration block in the SWARM_ROOT/data/config.php file. For example:

<?php
    'mentions' => array(
        'mode' => 'global',
        'user_exclude_list' => array('super', 'swarm-admin'),
        'group_exclude_list' => array('testers', 'writers'),
    ),
  • mode controls the scope of the auto-complete dropdown that is shown when the user starts typing an @mention or an @@mention in a review comment:

    • global displays all users/groups in P4 Code Review, this is the default value
    • projects: only displays project members (users and groups) in the auto-complete list
    • disabled disables the auto-complete drop down so that it is not displayed
  • user_exclude_list users in the exclude list:

    • are not suggested when you @mention them in a comment, edit reviewers, or edit the author in P4 Code Review.
    • are not added to the review if you manually add them as an @mention in a P4 Code Review comment or a review description.
    • are not added to the review if they are @mentioned in a changelist description.
    • cannot be added to the review with the P4 Code Review API.
    • When you add a user to the exclude list:

      • the user is not removed from any reviews that they are already on.
      • the user will stop receiving email notifications for those reviews.

  • group_exclude_list groups in the exclude list:

    • are not suggested when you @@mention them in a comment or edit reviewers in P4 Code Review.
    • are not added to the review if you manually add them as an @@mention in a P4 Code Review comment or review description.
    • are not added to the review if they are @@mentioned in a changelist description.
    • cannot be added to the review with the P4 Code Review API.
    • When you add a group to the exclude list:

      • the group is not removed from any reviews that it is already on.
      • the group members will stop receiving email notifications for those reviews.
      • if a member of an excluded group is also on the review as a user or as a member of another group, that user will continue to receive emails for the review.

Regular expressions in exclude lists

Regular expressions can be used in user and group exclude lists but they should be used with care to avoid accidentally excluding the wrong users or groups. P4 Code Review exclude lists can use any valid PHP regular expression but not all of them make sense for the exclude lists.

P4 Code Review adds a ^ character before your regular expression and a $ character after it. For example: ^your-reg-ex-pattern$ You must take this into account when constructing your regular expressions.

  • You can test the results of your regular expressions before using them, see regular expressions 101.
  • Case sensitivity for regular expressions in the exclude lists is determined by the case sensitivity setting of the P4 Server.

Regular expression examples

Useful regular expressions are shown below:

Exact match only:

'super' only users or groups named super are excluded.

Beginning with:

'admin.*' users or groups beginning with admin are excluded.

For example: the following would be excluded:

administrator, admin-group, and admin

Ending with:

'.*admin' users or groups ending with admin are excluded.

For example: the following would be excluded:

test-admin, buildadmin, and admin

Ending with digits

'.*[0-9]+' users or groups ending with digits are excluded.

For example: the following would be excluded:

test03, admin-10, tester_123456

Containing:

'.*admin.*' users or groups that contain admin are excluded.

For example: the following would be excluded:

test-admin, buildadmin, administrator, admin-group, and admin