Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100924627
PhabricatorDifferentialRebuildChangesetsWorkflow.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, Feb 4, 00:15
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Feb 6, 00:15 (2 d)
Engine
blob
Format
Raw Data
Handle
24054705
Attached To
rPH Phabricator
PhabricatorDifferentialRebuildChangesetsWorkflow.php
View Options
<?php
final
class
PhabricatorDifferentialRebuildChangesetsWorkflow
extends
PhabricatorDifferentialManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'rebuild-changesets'
)
->
setExamples
(
'**rebuild-changesets** --revision __revision__'
)
->
setSynopsis
(
pht
(
'Rebuild changesets for a revision.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'revision'
,
'param'
=>
'revision'
,
'help'
=>
pht
(
'Revision to rebuild changesets for.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$viewer
=
$this
->
getViewer
();
$revision_identifier
=
$args
->
getArg
(
'revision'
);
if
(!
$revision_identifier
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify a revision to rebuild changesets for with "--revision".'
));
}
$revision
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withNames
(
array
(
$revision_identifier
))
->
executeOne
();
if
(
$revision
)
{
if
(!(
$revision
instanceof
DifferentialRevision
))
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Object "%s" specified by "--revision" must be a Differential '
.
'revision.'
));
}
}
else
{
$revision
=
id
(
new
DifferentialRevisionQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$revision_identifier
))
->
executeOne
();
}
if
(!
$revision
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'No revision "%s" exists.'
,
$revision_identifier
));
}
$diffs
=
id
(
new
DifferentialDiffQuery
())
->
setViewer
(
$viewer
)
->
withRevisionIDs
(
array
(
$revision
->
getID
()))
->
execute
();
$changesets
=
id
(
new
DifferentialChangesetQuery
())
->
setViewer
(
$viewer
)
->
withDiffs
(
$diffs
)
->
needHunks
(
true
)
->
execute
();
$changeset_groups
=
mgroup
(
$changesets
,
'getDiffID'
);
foreach
(
$changeset_groups
as
$diff_id
=>
$changesets
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Rebuilding %s changeset(s) for diff ID %d.'
,
phutil_count
(
$changesets
),
$diff_id
));
foreach
(
$changesets
as
$changeset
)
{
echo
tsprintf
(
" %s
\n
"
,
$changeset
->
getFilename
());
}
id
(
new
DifferentialChangesetEngine
())
->
rebuildChangesets
(
$changesets
);
foreach
(
$changesets
as
$changeset
)
{
$changeset
->
save
();
}
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Done.'
));
}
}
}
Event Timeline
Log In to Comment