Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F119049059
ConduitAPI_diffusion_lastmodifiedquery_Method.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
Tue, Jun 24, 11:52
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Jun 26, 11:52 (1 d, 18 h)
Engine
blob
Format
Raw Data
Handle
26965436
Attached To
rPH Phabricator
ConduitAPI_diffusion_lastmodifiedquery_Method.php
View Options
<?php
final
class
ConduitAPI_diffusion_lastmodifiedquery_Method
extends
ConduitAPI_diffusion_abstractquery_Method
{
public
function
getMethodDescription
()
{
return
pht
(
'Get the commits at which paths were last modified.'
);
}
public
function
defineReturnType
()
{
return
'map<string, string>'
;
}
protected
function
defineCustomParamTypes
()
{
return
array
(
'paths'
=>
'required map<string, string>'
,
);
}
protected
function
getGitResult
(
ConduitAPIRequest
$request
)
{
$drequest
=
$this
->
getDiffusionRequest
();
$repository
=
$drequest
->
getRepository
();
$result
=
array
();
foreach
(
$request
->
getValue
(
'paths'
)
as
$path
=>
$commit
)
{
list
(
$hash
)
=
$repository
->
execxLocalCommand
(
'log -n1 --format=%%H %s -- %s'
,
$commit
,
$path
);
$result
[
$path
]
=
trim
(
$hash
);
}
return
$result
;
}
protected
function
getSVNResult
(
ConduitAPIRequest
$request
)
{
$drequest
=
$this
->
getDiffusionRequest
();
$repository
=
$drequest
->
getRepository
();
$result
=
array
();
foreach
(
$request
->
getValue
(
'paths'
)
as
$path
=>
$commit
)
{
$history_result
=
DiffusionQuery
::
callConduitWithDiffusionRequest
(
$request
->
getUser
(),
$drequest
,
'diffusion.historyquery'
,
array
(
'commit'
=>
$commit
,
'path'
=>
$path
,
'limit'
=>
1
,
'offset'
=>
0
,
'needDirectChanges'
=>
true
,
'needChildChanges'
=>
true
,
));
$history_array
=
DiffusionPathChange
::
newFromConduit
(
$history_result
[
'pathChanges'
]);
if
(
$history_array
)
{
$result
[
$path
]
=
head
(
$history_array
)
->
getCommit
()
->
getCommitIdentifier
();
}
}
return
$result
;
}
protected
function
getMercurialResult
(
ConduitAPIRequest
$request
)
{
$drequest
=
$this
->
getDiffusionRequest
();
$repository
=
$drequest
->
getRepository
();
$result
=
array
();
foreach
(
$request
->
getValue
(
'paths'
)
as
$path
=>
$commit
)
{
list
(
$hash
)
=
$repository
->
execxLocalCommand
(
'log --template %s --limit 1 --removed --rev %s -- %s'
,
'{node}'
,
hgsprintf
(
'reverse(ancestors(%s))'
,
$commit
),
nonempty
(
ltrim
(
$path
,
'/'
),
'.'
));
$result
[
$path
]
=
trim
(
$hash
);
}
return
$result
;
}
}
Event Timeline
Log In to Comment