Page MenuHomePhabricator
Paste P2047


Authored by epriestley on May 4 2017, 7:59 PM.
final class DifferentialSetBaseCommitConduitAPIMethod
extends DifferentialConduitAPIMethod {
public function getAPIMethodName() {
return 'differential.hack.setbasecommit';
public function getMethodDescription() {
return pht('(Temporary Hack) Set the base commit of a diff.');
protected function defineParamTypes() {
return array(
'diffID' => 'required id',
'commit' => 'required string',
protected function defineReturnType() {
return 'null';
protected function execute(ConduitAPIRequest $request) {
$viewer = $request->getUser();
$diff_id = $request->getValue('diffID');
if (!strlen($diff_id)) {
throw new Exception(
'To select a diff to affect, provide a "diffID".'));
$diff = id(new DifferentialDiffQuery())
if (!$diff) {
throw new Exception(
'No diff exists with ID "%s".',
$commit = $request->getValue('commit');
if (!strlen($commit)) {
throw new Exception(
'Provide a "commit" to identify which commit to set as '.
'the base.'));
return null;

Event Timeline

NOTE: Anyone who can see a diff can call this method to mutate it. Diffs are normally immutable after creation, so they don't have an edit policy which we can check for.

Here's how I tested this locally. First, I patched normally:

$ arc patch D223
Created and checked out branch arcpatch-D223.
Checking patch environment...
Applied patch environment cleanly.
 OKAY  Successfully committed patch.

I used the new method to adjust the base commit:

$ echo '{"diffID": 730, "commit": "quack"}' | arc call-conduit differential.hack.setbasecommit

Then I patched again, and saw arc patch try to find commit quack to patch on top of:

epriestley@orbital ~/dev/scratch/lock-ssh $ arc patch D223
Created and checked out branch arcpatch-D223.

    This diff is against commit quack, but the commit is nowhere in the
    working copy. Try to apply it against the current working copy state?
    (e71424e6f177b9859dd77fcaaba4530dd1439f72) [Y/n]