p4 counter
Access, set, increment, or delete a persistent variable.
Syntax
p4 [g-opts] counter countername p4 [g-opts] counter [-f -v] countername value p4 [g-opts] counter [-f] -d countername p4 [g-opts] counter [-f -v] -i countername p4 [g-opts] counter [-f] -m [pair list] p4 [g-opts] counter --from oldvalue --to newvalue countername
Description
Counters provide long-term variable storage for scripts that access Helix Core Server. Counters can be assigned textual values as well as numeric ones.
The command includes the following variants:
-
The variant
p4 counter countername
returns the value of variable countername.If a counter does not exist, its value is returned as zero. Counter names are not stored in the database until set to a nonzero value.
- The variant
p4 counter countername value
sets the value of variable countername to value. If countername does not already exist, it is created. - The variant
p4 counter -d countername
deletes the counter countername. This has the same effect as setting the counter to zero. - The variant
p4 counter -i countername
increments the counter by one and returns the new value. Use this option instead of a value argument. -
The variant
p4 counter -m pair list
defines multiple operations to be performed. Each operation is defined by a value pair in the pair list. To set a counter, use a name and value. To delete a counter, use a-
(hyphen) followed by the name. See Examples.This variant is useful in multi-server environments where running individual commands is likely to introduce unwanted latency.
-
The final variant (
--from
…--to
) sets the specified counter to the new value only if the current value of the counter isoldvalue
. A counter that has never been set or that has been deleted cannot be set using this syntax variant.This variant provides a compare-and-set function that can be used as a building block for higher-level tools and process that use counters.
Helix Core Server uses a number of counters in the course of its regular operations. These might be useful to various tools. For example, review tools can keep track of which changes have been reviewed and which changes are still under review by writing such status information into counters.
For the list of
Helix Core Server
counters, see p4 counters. Superusers can use the -f
option to force changes
to counters. However, changes to counters do incur risk.
The last changelist number known to the
Perforce
service (the output of p4 counter change
) includes
pending changelists created by users, but not yet submitted to the depot.
It can be useful to know the changelist number of the last
submitted changelist, which is the second field of the output of
the command:
p4 changes -m 1 -s submitted
The last changelist number successfully submitted (that is, no
longer pending) is held in the maxCommitChange
counter.
Options
|
Delete variable countername. |
|
Increment variable countername by 1 and return the new value. This option can only be used with numeric counters. |
|
Set or delete counters that are reserved for use by
Helix Core Server
(listed in Never set the |
|
Specify a list of operations to be performed. Each operation is
defined by a value pair in the pair list. To set a counter, use a
name and value; to delete a counter use a |
|
Display the previous value of the specified counter after the counter has been set or incremented. |
|
See Global options. |
Usage notes
Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required |
---|---|---|
N/A |
N/A |
list to display a counter’s value review to set a new value super to use the available to an operator user |
Examples
|
Set the value of a counter Requires |
|
Display the value of Requires |
|
Set two counters. |
|
Delete two counters. |
|
Set one counter; delete one counter. |
Related commands
To configure the versioning service |
|
To list all configurables and their values |
|
To list all counters and their values |
|
List and track changelists |
|
List users who have subscribed to particular files |