Comment mentions
P4 Code Review allows users to reference users with @mentions and groups with @@mentions in comments, changelists, review descriptions, and reviewer lists.
On this page:
Administrators can control how mention auto-complete behaves and prevent specific users or groups from being suggested, added to reviews, or notified through mentions.
Notes on versions:
-
@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 as case-sensitive, exclude list entries are also case-sensitive.
Changes to the mentions configuration require a configuration cache reload. You must be an admin or super user to reload the configuration cache. To reload the configuration:
-
Open the user menu (top-right corner of P4 Code Review).
-
Select System Information.
-
Open the Cache Info tab.
-
Click Reload Configuration.
If changes to the config.php file cause the P4 Code Review web interface to become unresponsive, remove the problematic configuration changes and clear the configuration cache by running:
rm -f /opt/perforce/swarm/data/cache/module-config-cache.php
Configure comment mentions
By default, P4 Code Review displays all users and groups in mention-related auto-complete lists. This includes @mentions, @@mentions, review authors and reviewers.
Use the mentions configuration block in the SWARM_ROOT/data/config.php file to configure who to hide or display in the auto-complete dropdown.
The mentions configuration block controls:
-
The scope of mention auto-complete results.
-
Which users can be added to reviews through
@mentions. -
Which groups can be added to reviews through
@@mentions. -
Which users and groups can be excluded from mention suggestions, review membership, and notifications.
user_exclude_list and group_exclude_list settings to exclude multiple users or groups that match a pattern. To learn more, see Regular expressions in exclude lists.
For example:
<?php
'mentions' => array(
'mode' => 'global',
'user_exclude_list' => array('super', 'swarm-admin'),
'group_exclude_list' => array('testers', 'writers'),
),
The mentions configuration block contains the following settings:
mode
Controls the scope of the auto-complete dropdown displayed when a user starts typing an @mention or @@mention in a review comment.
-
global- Displays all users and groups in P4 Code Review. This is the default value. -
projects- Displays only project members (users and groups) in the auto-complete list. -
disabled- Disables the auto-complete dropdown.
user_exclude_list
Choose which users are displayed or hidden in the auto-complete dropdown. Users in the user_exclude_list:
-
Are not suggested when using
@mentionsin comments. -
Are not suggested when editing reviewers.
-
Are not suggested when changing the review author.
-
Are not added to a review if they are manually included as an
@mentionin a comment or review description. -
Are not added to a review if they are
@mentionedin a changelist description. -
Cannot be added to a review through the P4 Code Review API.
When a user is added to the exclude list:
-
The user is not removed from reviews they are already associated with.
-
The user stops receiving email notifications for those reviews.
group_exclude_list
Choose which user groups are displayed or hidden in the auto-complete dropdown. Groups in the group_exclude_list:
-
Are not suggested when using
@@mentionsin comments. -
Are not suggested when editing reviewers.
-
Are not added to a review if they are manually included as an
@@mentionin a comment or review description. -
Are not added to a review if they are
@@mentionedin a changelist description. -
Cannot be added to a review through the P4 Code Review API.
When a group is added to the exclude list:
-
The group is not removed from reviews it is already associated with.
-
Members of the group stop receiving email notifications for those reviews.
-
If a member of the excluded group is also on the review individually, or as a member of another group, that user continues to receive email notifications for the review.
Regular expressions in exclude lists
You can use regular expressions in the user_exclude_list and group_exclude_list settings to exclude multiple users or groups that match a pattern.
Use regular expressions carefully to avoid unintentionally excluding users or groups. Any valid PHP regular expression can be used, although not all regular expression patterns are useful for exclude lists.
P4 Code Review automatically adds ^ to the beginning and $ to the end of each pattern. For example: ^your-reg-ex-pattern$
Take this behavior into account when constructing 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
| Pattern | Matches | Example excluded users/groups |
|---|---|---|
|
|
Exact match only. |
|
|
|
Names beginning with |
|
|
|
Names ending with |
|
|
|
Names ending with one or more digits. |
|
|
|
Names containing |
|