Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F105271857
PhabricatorGitGraphStream.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
Sat, Mar 15, 22:42
Size
1 KB
Mime Type
text/x-php
Expires
Mon, Mar 17, 22:42 (2 d)
Engine
blob
Format
Raw Data
Handle
24956542
Attached To
rPH Phabricator
PhabricatorGitGraphStream.php
View Options
<?php
final
class
PhabricatorGitGraphStream
extends
PhabricatorRepositoryGraphStream
{
private
$repository
;
private
$iterator
;
private
$parents
=
array
();
private
$dates
=
array
();
public
function
__construct
(
PhabricatorRepository
$repository
,
$start_commit
)
{
$this
->
repository
=
$repository
;
$future
=
$repository
->
getLocalCommandFuture
(
"log --format=%s %s --"
,
'%H%x01%P%x01%ct'
,
$start_commit
);
$this
->
iterator
=
new
LinesOfALargeExecFuture
(
$future
);
$this
->
iterator
->
setDelimiter
(
"
\n
"
);
$this
->
iterator
->
rewind
();
}
public
function
getParents
(
$commit
)
{
if
(!
isset
(
$this
->
parents
[
$commit
]))
{
$this
->
parseUntil
(
$commit
);
}
return
$this
->
parents
[
$commit
];
}
public
function
getCommitDate
(
$commit
)
{
if
(!
isset
(
$this
->
dates
[
$commit
]))
{
$this
->
parseUntil
(
$commit
);
}
return
$this
->
dates
[
$commit
];
}
private
function
parseUntil
(
$commit
)
{
if
(
$this
->
isParsed
(
$commit
))
{
return
;
}
$gitlog
=
$this
->
iterator
;
while
(
$gitlog
->
valid
())
{
$line
=
$gitlog
->
current
();
$gitlog
->
next
();
$line
=
trim
(
$line
);
if
(!
strlen
(
$line
))
{
break
;
}
list
(
$hash
,
$parents
,
$epoch
)
=
explode
(
"
\1
"
,
$line
);
if
(
$parents
)
{
$parents
=
explode
(
' '
,
$parents
);
}
else
{
// First commit.
$parents
=
array
();
}
$this
->
dates
[
$hash
]
=
$epoch
;
$this
->
parents
[
$hash
]
=
$parents
;
if
(
$this
->
isParsed
(
$commit
))
{
return
;
}
}
throw
new
Exception
(
"No such commit '{$commit}' in repository!"
);
}
private
function
isParsed
(
$commit
)
{
return
isset
(
$this
->
dates
[
$commit
]);
}
}
Event Timeline
Log In to Comment