Page MenuHomePhabricator

Use `PhabricatorAuditEditor` to write revert edges
ClosedPublic

Authored by joshuaspence on Jan 4 2015, 10:53 PM.
Tags
None
Referenced Files
F14356956: D11212.id26929.diff
Fri, Dec 20, 1:49 AM
Unknown Object (File)
Fri, Dec 13, 8:07 PM
Unknown Object (File)
Fri, Dec 13, 7:05 AM
Unknown Object (File)
Thu, Dec 12, 8:01 PM
Unknown Object (File)
Tue, Dec 10, 10:34 AM
Unknown Object (File)
Sat, Dec 7, 7:19 PM
Unknown Object (File)
Fri, Dec 6, 7:40 AM
Unknown Object (File)
Fri, Dec 6, 2:28 AM
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
Branch
master
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 3582
Build 3590: [Placeholder Plan] Wait for 30 Seconds

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.