Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112725852
DifferentialRawDiffRenderer.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, May 12, 15:21
Size
1 KB
Mime Type
text/x-php
Expires
Wed, May 14, 15:21 (2 d)
Engine
blob
Format
Raw Data
Handle
26122523
Attached To
rPH Phabricator
DifferentialRawDiffRenderer.php
View Options
<?php
final
class
DifferentialRawDiffRenderer
{
private
$changesets
;
private
$format
=
'unified'
;
private
$viewer
;
public
function
setFormat
(
$format
)
{
$this
->
format
=
$format
;
return
$this
;
}
public
function
getFormat
()
{
return
$this
->
format
;
}
public
function
setChangesets
(
array
$changesets
)
{
assert_instances_of
(
$changesets
,
'DifferentialChangeset'
);
$this
->
changesets
=
$changesets
;
return
$this
;
}
public
function
getChangesets
()
{
return
$this
->
changesets
;
}
public
function
setViewer
(
PhabricatorUser
$viewer
)
{
$this
->
viewer
=
$viewer
;
return
$this
;
}
public
function
getViewer
()
{
return
$this
->
viewer
;
}
public
function
buildPatch
()
{
$diff
=
new
DifferentialDiff
();
$diff
->
attachChangesets
(
$this
->
getChangesets
());
foreach
(
$diff
->
getChangesets
()
as
$changeset
)
{
$changeset
->
attachHunks
(
$changeset
->
loadRelatives
(
new
DifferentialHunk
(),
'changesetID'
));
}
$raw_changes
=
$diff
->
buildChangesList
();
$changes
=
array
();
foreach
(
$raw_changes
as
$changedict
)
{
$changes
[]
=
ArcanistDiffChange
::
newFromDictionary
(
$changedict
);
}
$viewer
=
$this
->
getViewer
();
$loader
=
id
(
new
PhabricatorFileBundleLoader
())
->
setViewer
(
$viewer
);
$bundle
=
ArcanistBundle
::
newFromChanges
(
$changes
);
$bundle
->
setLoadFileDataCallback
(
array
(
$loader
,
'loadFileData'
));
$format
=
$this
->
getFormat
();
switch
(
$format
)
{
case
'git'
:
return
$bundle
->
toGitPatch
();
break
;
case
'unified'
:
default
:
return
$bundle
->
toUnifiedDiff
();
break
;
}
}
}
Event Timeline
Log In to Comment