Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97789092
DifferentialLandingStrategy.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jan 6, 10:04
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Jan 8, 10:04 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23450504
Attached To
rPH Phabricator
DifferentialLandingStrategy.php
View Options
<?php
abstract
class
DifferentialLandingStrategy
{
public
abstract
function
processLandRequest
(
AphrontRequest
$request
,
DifferentialRevision
$revision
,
PhabricatorRepository
$repository
);
/**
* @return PhabricatorActionView or null.
*/
abstract
function
createMenuItem
(
PhabricatorUser
$viewer
,
DifferentialRevision
$revision
,
PhabricatorRepository
$repository
);
/**
* @return PhabricatorActionView which can be attached to the revision view.
*/
protected
function
createActionView
(
$revision
,
$name
)
{
$strategy
=
get_class
(
$this
);
$revision_id
=
$revision
->
getId
();
return
id
(
new
PhabricatorActionView
())
->
setRenderAsForm
(
true
)
->
setWorkflow
(
true
)
->
setName
(
$name
)
->
setHref
(
"/differential/revision/land/{$revision_id}/{$strategy}/"
);
}
/**
* Check if this action should be disabled, and explain why.
*
* By default, this method checks for push permissions, and for the
* revision being Accepted.
*
* @return False for "not disabled"; human-readable text explaining why, if
* it is disabled.
*/
public
function
isActionDisabled
(
PhabricatorUser
$viewer
,
DifferentialRevision
$revision
,
PhabricatorRepository
$repository
)
{
$status
=
$revision
->
getStatus
();
if
(
$status
!=
ArcanistDifferentialRevisionStatus
::
ACCEPTED
)
{
return
pht
(
'Only Accepted revisions can be landed.'
);
}
if
(!
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$repository
,
DiffusionPushCapability
::
CAPABILITY
))
{
return
pht
(
'You do not have permissions to push to this repository.'
);
}
return
false
;
}
/**
* Might break if repository is not Git.
*/
protected
function
getGitWorkspace
(
PhabricatorRepository
$repository
)
{
try
{
return
DifferentialGetWorkingCopy
::
getCleanGitWorkspace
(
$repository
);
}
catch
(
Exception
$e
)
{
throw
new
PhutilProxyException
(
'Failed to allocate a workspace'
,
$e
);
}
}
/**
* Might break if repository is not Mercurial.
*/
protected
function
getMercurialWorkspace
(
PhabricatorRepository
$repository
)
{
try
{
return
DifferentialGetWorkingCopy
::
getCleanMercurialWorkspace
(
$repository
);
}
catch
(
Exception
$e
)
{
throw
new
PhutilProxyException
(
'Failed to allocate a workspace'
,
$e
);
}
}
}
Event Timeline
Log In to Comment