Page MenuHomePhabricator

Use `PhabricatorAuditEditor` to write revert edges
ClosedPublic

Authored by joshuaspence on Jan 4 2015, 10:53 PM.
Tags
None
Referenced Files
F14063677: D11212.diff
Mon, Nov 18, 7:44 PM
F14052344: D11212.diff
Fri, Nov 15, 8:15 AM
F14051160: D11212.id26927.diff
Thu, Nov 14, 10:41 PM
F14040108: D11212.id26925.diff
Mon, Nov 11, 7:28 AM
F14040004: D11212.diff
Mon, Nov 11, 7:03 AM
F14039916: D11212.id26918.diff
Mon, Nov 11, 6:43 AM
F14023809: D11212.id26934.diff
Thu, Nov 7, 3:49 AM
F14023036: D11212.diff
Wed, Nov 6, 9:59 PM
Subscribers

Details

Reviewers
epriestley
Group Reviewers
Blessed Reviewers
Commits
Restricted Diffusion Commit
rPdd42020ef3bc: Use `PhabricatorAuditEditor` to write revert edges
Summary

Use PhabricatorAuditEditor instead of PhabricatorEdgeEditor when writing reverts edges. This ensures that a transaction is created in addition to the edge.

Test Plan

Reverted a commit and pushed to remote. Saw a row created in phabricator_audit.audit_transaction_comment. Interestingly, I can't actually see the transaction at http://phabricator.local/r${CALLSIGN}${REVERTED_COMMIT_HASH}.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

joshuaspence retitled this revision from to Use `PhabricatorAuditEditor` to write revert edges.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)

I'm not sure why, but I am hitting this:

[05-Jan-2015 09:50:12 Australia/Sydney] [2015-01-05 09:50:12] EXCEPTION: (PhutilProxyException) Error while executing task ID 105944 from queue. {>} (PhabricatorDataNotAt
tachedException) Attempting to access attached data on PhabricatorRepositoryCommit (via getRepository()), but the data is not actually attached. Before accessing attachab
le data on an object, you must load and attach it.

Data is normally attached by calling the corresponding needX() method on the Query class when the object is loaded. You can also call the corresponding attachX() method e
xplicitly. at [<phabricator>/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:166]
[05-Jan-2015 09:50:12 Australia/Sydney]   #0 PhabricatorLiskDAO::assertAttached(string) called at [<phabricator>/src/applications/repository/storage/PhabricatorRepository
Commit.php:46]
[05-Jan-2015 09:50:12 Australia/Sydney]   #1 PhabricatorRepositoryCommit::getRepository() called at [<phabricator>/src/applications/audit/editor/PhabricatorAuditEditor.php:528]
[05-Jan-2015 09:50:12 Australia/Sydney]   #2 PhabricatorAuditEditor::shouldSendMail(PhabricatorRepositoryCommit, array) called at [<phabricator>/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php:796]
[05-Jan-2015 09:50:12 Australia/Sydney]   #3 PhabricatorApplicationTransactionEditor::applyTransactions(PhabricatorRepositoryCommit, array) called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php:141]
[05-Jan-2015 09:50:12 Australia/Sydney]   #4 PhabricatorRepositoryCommitMessageParserWorker::updateCommitData(DiffusionCommitRef) called at [<phabricator>/src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php:15]
[05-Jan-2015 09:50:12 Australia/Sydney]   #5 PhabricatorRepositoryGitCommitMessageParserWorker::parseCommit(PhabricatorRepository, PhabricatorRepositoryCommit) called at [<phabricator>/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php:44]
[05-Jan-2015 09:50:12 Australia/Sydney]   #6 PhabricatorRepositoryCommitParserWorker::doWork() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorWorker.php:91]
[05-Jan-2015 09:50:12 Australia/Sydney]   #7 PhabricatorWorker::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/storage/PhabricatorWorkerActiveTask.php:157]
[05-Jan-2015 09:50:12 Australia/Sydney]   #8 PhabricatorWorkerActiveTask::executeTask() called at [<phabricator>/src/infrastructure/daemon/workers/PhabricatorTaskmasterDaemon.php:19]
[05-Jan-2015 09:50:12 Australia/Sydney]   #9 PhabricatorTaskmasterDaemon::run() called at [<phutil>/src/daemon/PhutilDaemon.php:91]
[05-Jan-2015 09:50:12 Australia/Sydney]   #10 PhutilDaemon::execute() called at [<phutil>/scripts/daemon/exec/exec_daemon.php:111]
joshuaspence edited edge metadata.

Attach repository

Looks good so far. One inline.

src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
127

Use setContinueOnNoEffect(true) to prevent the Editor from throwing this.

But PhabricatorEdgeCycleException can still be raised.

Strangely, I'm not actually seeing a transaction comment on the reverted commit.

Oh, there is no phabricator_repository.repository_transaction_comment table?

Oh, there is no phabricator_repository.repository_transaction_comment table?

Nevermind, I see now... it's in phabricator_audit.

src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
111–114

Oh, you don't want to do this. Just implement all the getStringBlahBlahBlah() methods to say:

epriestley marked this commit as reverting rXabcdef.
epriestley marked rXabcdef as reverting this commit.

(Or find some more natural language.)

The table exists, but TYPE_EDGE transactions don't show comments, I think.

You could add a second transaction with TYPE_COMMENT, but I think it would be overkill to put the entire commit message on the reverted commit.

src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
111–114

I'm not sure how the get*String() methods would work here. '%s added %s blocking task(s): %s.' is an example of such a string, so perhaps '%s reverted %s commit(s): %s'? But then getTransactionRemoveString seems odd as '%s unreverted %s commit(s): %s'?

Don't write commit message as transaction comment

This is the best I can come up with offhand:

  • epriestley added reverted commits: rX, rY.
  • epriestley removed reverted commits: rX, rY.
  • epriestley edited reverted commits, added: rX, removed: rY.

And one of these on the other side:

  • epriestley added reverting commits: rX, rY.
  • epriestley removed reverting commits: rX, rY.
  • epriestley edited reverting commits, added: rX, removed: rY.

Realistically, since these will never be removed or edited and the singular case is the most common, we could maybe special case the inverse edge singular and just do:

  • epriestley reverted this commit in rX.

It would be OK for the relevant getString() methods to do logical tests against the number of affected objects, etc., if that seems significantly better.

joshuaspence edited edge metadata.
  • Add strings
  • Move to PhabricatorRepositoryCommitHeraldWorker
epriestley edited edge metadata.
epriestley added inline comments.
src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
92

In a totally ideal world, we should probably catch PhabricatorEdgeCycleException, then remove the revert transaction and re-apply just the "commit" transaction. We can wait until a user manages to hit this before doing the legwork to set it up and test it, though.

This revision is now accepted and ready to land.Jan 5 2015, 7:20 PM
This revision was automatically updated to reflect the committed changes.