| 1 | package Net::Gnats::Command::LOCK; | ||||||||||
| 2 | 40 | ▶ | use parent 'Net::Gnats::Command'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 40 | ▶ | use strictures; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 40 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 40 | $Net::Gnats::Command::LOCK::VERSION = '0.22'; | |||||||||
| 6 | } | ||||||||||
| 7 | 40 | ▶ | use vars qw($VERSION); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 40 | ▶ | use Net::Gnats::Constants qw(CODE_CMD_ERROR CODE_PR_READY CODE_NONEXISTENT_PR CODE_LOCKED_PR); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | =head1 NAME | ||||||||||
| 12 | |||||||||||
| 13 | Net::Gnats::Command::LOCK | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | Locks the specified PR, marking the lock with the user name and the | ||||||||||
| 18 | optional pid. (No checking is done that the user or pid arguments | ||||||||||
| 19 | are valid or meaningful; they are simply treated as strings.) | ||||||||||
| 20 | |||||||||||
| 21 | The EDIT command requires that the PR be locked before it may be | ||||||||||
| 22 | successfully executed. However, it does not require that the lock is | ||||||||||
| 23 | owned by the editing session, so the usefulness of the lock is | ||||||||||
| 24 | simply as an advisory measure. | ||||||||||
| 25 | |||||||||||
| 26 | The APPN and REPL commands lock the PR as part of the editing | ||||||||||
| 27 | process, and they do not require that the PR be locked before they | ||||||||||
| 28 | are invoked. | ||||||||||
| 29 | |||||||||||
| 30 | =head1 PROTOCOL | ||||||||||
| 31 | |||||||||||
| 32 | LOCK <pr> <user> [pid] | ||||||||||
| 33 | |||||||||||
| 34 | =head1 RESPONSES | ||||||||||
| 35 | |||||||||||
| 36 | The possible responses are: | ||||||||||
| 37 | |||||||||||
| 38 | 440 (CODE_CMD_ERROR) | ||||||||||
| 39 | |||||||||||
| 40 | Insufficient or too many arguments were specified to the command. | ||||||||||
| 41 | |||||||||||
| 42 | 300 (CODE_PR_READY) | ||||||||||
| 43 | |||||||||||
| 44 | The lock was successfully obtained; the text of the PR (using the | ||||||||||
| 45 | standard quoting mechanism for PRs) follows. | ||||||||||
| 46 | |||||||||||
| 47 | 400 (CODE_NONEXISTENT_PR) | ||||||||||
| 48 | |||||||||||
| 49 | The PR specified does not exist. | ||||||||||
| 50 | |||||||||||
| 51 | 430 (CODE_LOCKED_PR) | ||||||||||
| 52 | |||||||||||
| 53 | The PR is already locked by another session. | ||||||||||
| 54 | |||||||||||
| 55 | 6xx (internal error) | ||||||||||
| 56 | |||||||||||
| 57 | The PR lock could not be created, usually because of permissions or | ||||||||||
| 58 | other filesystem-related issues. | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 40 | my $c = 'LOCK'; | |||||||||
| 63 | |||||||||||
| 64 | 9 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 65 | 9 | my ( $class, %options ) = @_; | |||||||||
| 66 | 9 | my $self = bless \%options, $class; | |||||||||
| 67 | 9 | return $self; | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 13 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 71 | 13 | my $self = shift; | |||||||||
| 72 | 13 | ▶ | return undef if not defined $self->{pr_number}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 9 | ▶ | return undef if not defined $self->{user}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 8 | my $command = $c . ' ' . $self->{pr_number} . ' ' . $self->{user}; | |||||||||
| 75 | 8 | ▶ | if (defined $self->{pid}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 76 | 2 | $command .= ' ' . $self->{pid}; | |||||||||
| 77 | } | ||||||||||
| 78 | 8 | return $command; | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 9 | ▶ | sub is_ok { | ||||||||
|
Subroutine
is_ok: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||
| 82 | 9 | my $self = shift; | |||||||||
| 83 | 9 | ▶ | return 0 if not defined $self->response; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 84 | 4 | ▶ | return 1 if $self->response->code == CODE_PR_READY; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | return 0; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 40 | 1; | |||||||||