Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F424978
PhabricatorGitGraphStream.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
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
);
}
$parents
=
$this
->
parents
[
$commit
];
// NOTE: In Git, it is possible for a commit to list the same parent more
// than once. See T5226. Discard duplicate parents.
return
array_unique
(
$parents
);
}
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
(
pht
(
"No such commit '%s' in repository!"
,
$commit
));
}
private
function
isParsed
(
$commit
)
{
return
isset
(
$this
->
dates
[
$commit
]);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, May 2, 11:00 PM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
57473
Default Alt Text
PhabricatorGitGraphStream.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment