Page MenuHomePhabricator

Revision substate CLOSED_FROM_ACCEPTED
ClosedPublic

Authored by avivey on Jan 22 2016, 3:07 AM.
Tags
None
Referenced Files
F14047193: D15085.id36596.diff
Thu, Nov 14, 2:38 AM
F14045577: D15085.id36559.diff
Wed, Nov 13, 6:40 AM
F14031556: D15085.id38929.diff
Sat, Nov 9, 11:21 AM
F14031555: D15085.id36596.diff
Sat, Nov 9, 11:21 AM
F14031554: D15085.id36559.diff
Sat, Nov 9, 11:21 AM
F14031553: D15085.id36424.diff
Sat, Nov 9, 11:19 AM
F14031552: D15085.id.diff
Sat, Nov 9, 11:19 AM
F14019449: D15085.diff
Tue, Nov 5, 10:11 PM
Subscribers

Details

Summary

Ref T9838.

Add a Properties field to Revision, and update a wasAcceptedBeforeClose when closing a revision.

Test Plan

A quick run through the obvious steps (Close with commit/manually, with or w/o accept) and calling differential.query shows the wasAcceptedBeforeClose property was setup correctly.

Pushing closed + accepted passes the relevant herald, which was my immediate issue; Pushing un-accepted is blocked.
Test the "commit" rule (Different from "pre-commit") by hacking the DB and running the "has accepted revision" rule in a test-console.

Diff Detail

Repository
rP Phabricator
Branch
rev-props
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 10438
Build 12756: Run Core Tests
Build 12755: arc lint + arc unit

Event Timeline

avivey retitled this revision from to Revision substate CLOSED_FROM_ACCEPTED (P).
avivey updated this object.
avivey edited the test plan for this revision. (Show Details)

Found an issue.

avivey edited edge metadata.

greped for ArcanistDifferentialRevisionStatus::CLOSED

avivey retitled this revision from Revision substate CLOSED_FROM_ACCEPTED (P) to Revision substate CLOSED_FROM_ACCEPTED (Phab-side).Jan 22 2016, 3:24 AM

@epriestley, can you take a look at this?

Alternatively, I'll be happy to copy the existing logic from DiffusionCommitRevisionAcceptedHeraldField to DiffusionPreCommitContentRevisionAcceptedHeraldField, and leave the sub-state implementation to some later day.

I think making this an entirely different state (i.e., "Closed" and "Closed from Accepted" being two different states) is probably a messier change than we need to make. What do you think about this instead?

  • Add a wasAcceptedBeforeClose flag to DifferentialRevision (but see below).
  • In DifferentialTransactionEditor->applyCustomInternalTransaction(), in the DifferentialTransaction::TYPE_ACTION block:
    • If the action is "CLOSE" and the current status is "ACCEPTED", set the wasAcceptedBeforeClose flag.
    • Otherwise, clear the wasAcceptedBeforeClose flag.

On adding the flag, it might be better to just add a properties JSON field for flexibility instead of a wasAcceptedBeforeClose column, since the cost of the SQL migration should be the same either way, and I suspect we'll have more of these in the future once stuff like --try ("don't submit for review until tests pass") gets implemented, and we don't have any cases in mind where we need to query by this flag.

I think that would make this a lot simpler and allow us to get away without D15084 or the pain of an arc soft version break (older versions of arc not understanding how to handle this status). I don't really see any downsides -- anything I'm missing?

I'll give it a go; I wasn't easy with the extent of this change.

Maybe instead of wasAcceptedBeforeClose property, use a substate property? Would that save another change later?

If you just add properties as a JSON field, the actual call would be setProperty('wasAcceptedBeforeClose', true) or whatever, and we have limitless power beyond that.

(I feel like most newer objects are getting properties fields or similar these days, since we almost always find something useful to do with them.)

Start re-writing with property instead of new state.

This is very broken, I'll dig in later this week to see why.

Re-implement as a property.

avivey retitled this revision from Revision substate CLOSED_FROM_ACCEPTED (Phab-side) to Revision substate CLOSED_FROM_ACCEPTED.Feb 1 2016, 11:59 PM
avivey updated this object.
avivey edited the test plan for this revision. (Show Details)
epriestley added a reviewer: epriestley.

Some inlines, including one likely (very minor) functional issue, but this looks reasonable to me overall.

resources/sql/autopatches/20160201.revision.properties.1.sql
2

This should be COLLATE {$COLLATE_TEXT}.

src/applications/differential/editor/DifferentialTransactionEditor.php
239

Maybe create a DifferentialRevision::PROPERTY_... constant or similar.

src/applications/diffusion/herald/DiffusionCommitRevisionAcceptedHeraldField.php
33

I'd expect this doesn't actually work, because this is like writing a series of if ($x == $y) clauses in PHP. Specifically:

$ cat test.php 
<?php

switch ('undefined') {
  case true:
    echo "Undefined is true!\n";
    break;
  default:
    echo "Undefined is not true.\n";
    break;
}

$ php -f test.php 
Undefined is true!

Consider $revision->hasRevisionProperty() or similar, maybe.

(Note that hasProperty() will conflict with the method of the same name on LiskDAO. It might be worthwhile to rename that to hasLiskProperty at some point, but it's vaguely nice to call these getSomethingProperty() so you can grep for them a little better.)

This revision is now accepted and ready to land.Jun 8 2016, 5:56 PM
avivey updated this object.
avivey edited edge metadata.
  • Add hasRevisionProperty()
  • Fix commit herald rule
  • Add const for property value
This revision was automatically updated to reflect the committed changes.