Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121793977
DiffusionMercurialServeSSHWorkflow.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
Sun, Jul 13, 23:13
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jul 15, 23:13 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27392160
Attached To
rPH Phabricator
DiffusionMercurialServeSSHWorkflow.php
View Options
<?php
final
class
DiffusionMercurialServeSSHWorkflow
extends
DiffusionMercurialSSHWorkflow
{
protected
$didSeeWrite
;
protected
function
didConstruct
()
{
$this
->
setName
(
'hg'
);
$this
->
setArguments
(
array
(
array
(
'name'
=>
'repository'
,
'short'
=>
'R'
,
'param'
=>
'repo'
,
),
array
(
'name'
=>
'stdio'
,
),
array
(
'name'
=>
'command'
,
'wildcard'
=>
true
,
),
));
}
protected
function
identifyRepository
()
{
$args
=
$this
->
getArgs
();
$path
=
$args
->
getArg
(
'repository'
);
return
$this
->
loadRepositoryWithPath
(
$path
,
PhabricatorRepositoryType
::
REPOSITORY_TYPE_MERCURIAL
);
}
protected
function
executeRepositoryOperations
()
{
$repository
=
$this
->
getRepository
();
$args
=
$this
->
getArgs
();
if
(!
$args
->
getArg
(
'stdio'
))
{
throw
new
Exception
(
pht
(
'Expected `%s`!'
,
'hg ... --stdio'
));
}
if
(
$args
->
getArg
(
'command'
)
!==
array
(
'serve'
))
{
throw
new
Exception
(
pht
(
'Expected `%s`!'
,
'hg ... serve'
));
}
if
(
$this
->
shouldProxy
())
{
$command
=
$this
->
getProxyCommand
();
}
else
{
$command
=
csprintf
(
'hg -R %s serve --stdio'
,
$repository
->
getLocalPath
());
}
$command
=
PhabricatorDaemon
::
sudoCommandAsDaemonUser
(
$command
);
$future
=
id
(
new
ExecFuture
(
'%C'
,
$command
))
->
setEnv
(
$this
->
getEnvironment
());
$io_channel
=
$this
->
getIOChannel
();
$protocol_channel
=
new
DiffusionMercurialWireClientSSHProtocolChannel
(
$io_channel
);
$err
=
id
(
$this
->
newPassthruCommand
())
->
setIOChannel
(
$protocol_channel
)
->
setCommandChannelFromExecFuture
(
$future
)
->
setWillWriteCallback
(
array
(
$this
,
'willWriteMessageCallback'
))
->
execute
();
if
(!
$err
&&
$this
->
didSeeWrite
)
{
$repository
->
writeStatusMessage
(
PhabricatorRepositoryStatusMessage
::
TYPE_NEEDS_UPDATE
,
PhabricatorRepositoryStatusMessage
::
CODE_OKAY
);
}
return
$err
;
}
public
function
willWriteMessageCallback
(
PhabricatorSSHPassthruCommand
$command
,
$message
)
{
$command
=
$message
[
'command'
];
// Check if this is a readonly command.
$is_readonly
=
false
;
if
(
$command
==
'batch'
)
{
$cmds
=
idx
(
$message
[
'arguments'
],
'cmds'
);
if
(
DiffusionMercurialWireProtocol
::
isReadOnlyBatchCommand
(
$cmds
))
{
$is_readonly
=
true
;
}
}
else
if
(
DiffusionMercurialWireProtocol
::
isReadOnlyCommand
(
$command
))
{
$is_readonly
=
true
;
}
if
(!
$is_readonly
)
{
$this
->
requireWriteAccess
();
$this
->
didSeeWrite
=
true
;
}
return
$message
[
'raw'
];
}
protected
function
raiseWrongVCSException
(
PhabricatorRepository
$repository
)
{
throw
new
Exception
(
pht
(
'This repository ("%s") is not a Mercurial repository. Use "%s" to '
.
'interact with this repository.'
,
$repository
->
getDisplayName
(),
$repository
->
getVersionControlSystem
()));
}
}
Event Timeline
Log In to Comment