Class RefUpdateContext

java.lang.Object
com.google.gerrit.server.update.context.RefUpdateContext
All Implemented Interfaces:
AutoCloseable

public class RefUpdateContext extends Object implements AutoCloseable
Passes additional information about an operation to the BatchRefUpdate#execute method.

To pass the additional information RefUpdateContext, wraps a code into an open RefUpdateContext, e.g.:


 try(RefUpdateContext ctx = RefUpdateContext.open(RefUpdateType.CHANGE_MODIFICATION)) {
   ...
   // some code which modifies a ref using BatchRefUpdate.execute method
 }
 
When the BatchRefUpdate#execute method is executed, it can get all opened contexts and use it for an additional actions, e.g. it can put it in the reflog.

The information provided by this class is used internally in google.

The InMemoryRepositoryManager file makes some validation to ensure that RefUpdateContext is used correctly within the code (see thee validateRefUpdateContext method).

The class includes only operations from open-source gerrit and can be extended (see TestActionRefUpdateContext for example how to extend it).