Page MenuHomePhabricator

Increase clarity when closing a revision in response to a commit
ClosedPublic

Authored by btrahan on Sep 12 2014, 7:08 PM.
Tags
None
Referenced Files
F13332278: D10489.diff
Mon, Jun 17, 9:36 AM
F13318628: D10489.diff
Thu, Jun 13, 11:19 AM
F13307954: D10489.id25694.diff
Sun, Jun 9, 11:27 PM
F13280744: D10489.diff
Sun, Jun 2, 9:14 AM
F13255605: D10489.id25693.diff
Sat, May 25, 6:23 AM
F13251080: D10489.id25694.diff
Fri, May 24, 7:54 PM
F13249603: D10489.id.diff
Fri, May 24, 9:38 AM
F13249602: D10489.id25694.diff
Fri, May 24, 9:38 AM
Subscribers

Details

Summary

I am not sure how valuable this is *as is* - I think it needs different explanations for what happened in mercurial or subversion? I do not know what those explanations are.

Made an error in D10485 - the $hashes that were saved is an array of objects, so it ends up turning into garbage via the wonders of serialization and de-serialization. Fix that by explicitly saving the tree hash.

I would like to make this work for the other VCS types we support, add the "undo / nope" button and call it fixed.

Ref T3686.

Test Plan

clicked "explan why" and saw why

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

btrahan added a task: Restricted Maniphest Task.
btrahan retitled this revision from to Increase clarity when closing a revision in response to a commit.
btrahan updated this object.
btrahan edited the test plan for this revision. (Show Details)
btrahan added a reviewer: epriestley.
epriestley edited edge metadata.

This looks good so far.

The possible reasons are:

Reason for CloseGitMercurialSubversion
Found "Differential Revision" in commit messageYESYESYES
Commit hash matchesYESYESNo: no hashes
Tree hash matchesYESNo: no tree hashesNo: no hashes
(Explicit close by user, not applicable here.)N/AN/AN/A

I think the cleanest approach might be to store the actual "reason" on the commit, in addition to the other data, then mostly just do string rendering at display time instead of trying to figure out the "why".

The reason happens in DiffusionLowLevelCommitFieldsQuery->executeQuery(). Either we find a revision ID in the commit message (near line 31) explicitly, as "Differential Revision: ...":

31     $revision_id = idx($fields, 'revisionID');

...or we find one by matching a hash (near line 44):

43        $revision = $this->pickBestRevision($revisions);
44        $fields['revisionID'] = $revision->getID();

In the first case, there's actually a sub-case in T5693, which is that we find "Differential Revision: ..." but choose not to use it. This is currently very difficult to undersatnd/debug, and I spent about an hour walking a user through it to discover that something was configured as http:// instead of https://.

So I think we probably want something like to export a pile more information from DiffusionLowLevelCommitFieldsQuery and/or reorganize that code to produce both a result and a reason, then store that on the commit data.

Ideally, the "reason" should store all the information we need in order to display it to the user later without having to figure anything out. I think that would be something like:

usedURI = true|false # Did we use "Differential Revision: ..." from the commit message?
foundURI = null|http://... # Value we found in "Differential revision: ..." field, if any.
expectURI = http://... # Domain we expected in the field.
matchHashType = null|gttr|gtcm|hgcm
matchHashValue = null|abcdef29832

The big reason to denormalize information that we can figure out later, like expectURI, is to keep the messages stable when users change configuration.

Then we could display a two-part message, with the first part being one of these:

We didn't find a "Differential Revision" field in the commit message.
We found a "Differential Revision" field with value "{$foundURI}" in the commit message, but the domain on this URI did not match the configured domain for this install, "{$expectURI}", so we ignored it under the assumption that it refers to some third-party revision.
We found a "Differential Revision" field with value "{$foundURI}" in the commit message, and the domain on the URI matches this install, so we linked this commit to D123.

And the second part being one of:

(Omit if we found a revision using the commit message.)
This commit and the active diff of D123 had the same commit hash (abcdef1234) so we linked this commit to D123.
This commit and the active diff of D123 had the same tree hash (abcdef1234) so we linked this commit to D123.

In particular, structuring things this way also lets us add an "Explain Why this was not linked" sort of link from the Diffusion side, which is about as confusing to users as why things were linked (putting the controller in Diffusion instead of Differential might make sense).

ends up turning into garbage via the wonders of serialization and de-serialization

Ah, yeah. We can't serialize PHP objects since the field stores as JSON, but it should be OK to save plain arrays with strings in them (e.g., put all that junk above in some closeReason thing if you want).

src/applications/differential/storage/DifferentialTransaction.php
274–282

You can use renderExtraInformationLink() to get a slightly cleaner version of this (and that we can more easily support with plain text rendering, etc), see PhabricatorApplicationTransaction::renderExtraInformationLink() for an example.

This revision now requires changes to proceed.Sep 14 2014, 2:37 PM

Screen_Shot_2014-10-13_at_12.59.09_PM.png (1×1 px, 524 KB)

Screen_Shot_2014-10-13_at_12.59.13_PM.png (1×1 px, 553 KB)

src/applications/differential/storage/DifferentialTransaction.php
309–324

This renders kind of ugly. See screenshot.

epriestley edited edge metadata.

It would be vaguely nice to get this on the commit data (instead of the transaction metadata) so we can offer a similar link from the Diffusion side easily, but I think this is like 95% of the way there. Rendering seems fine to me, this doesn't need to win any beauty contests.

src/applications/differential/storage/DifferentialTransaction.php
319

Prefer "Explain Why" (in title case) for consistency with "View Herald Rule" or whatever the other one is.

This revision is now accepted and ready to land.Oct 13 2014, 10:06 PM
btrahan edited edge metadata.
  • fix "Explain Why" casing
  • write revisionMatchData to commitData as well
    • similar to how something like "authorName" gets written in both places
This revision was automatically updated to reflect the committed changes.