@title Diffusion User Guide: Autoclose
@group userguide

Explains when Diffusion will close tasks and revisions upon discovery of related
commits.

Overview
========

Diffusion can close tasks and revisions when related commits appear in a
repository. For example, if you make a commit with `Fixes T123` in the commit
message, Diffusion will close the task `T123`.

This document explains how autoclose works, how to configure it, and how to
troubleshoot it.

Troubleshooting Autoclose
=========================

You can check if a branch is currently configured to autoclose on the main
repository view, or in the branches list view. Hover over the {icon check} or
{icon times} icon and you should see one of these messages:

  - {icon check} **Autoclose Enabled** Autoclose is active for this branch.
  - {icon times} **Repository Importing** This repository is still importing.
    Autoclose does not activate until a repository finishes importing for the
    first time. This prevents situations where you import a repository and
    accidentally close hundreds of related objects during import. Autoclose
    will activate for new commits after the initial import completes.
  - {icon times} **Repository Autoclose Disabled** Autoclose is disabled for
    this entire repository. You can enable it in **Edit Repository**.
  - {icon times} **Branch Untracked** This branch is not tracked. Because it
    is not tracked, commits on it won't be seen and won't be discovered.
  - {icon times} **Branch Autoclose Disabled** Autoclose is not enabled for
    this branch. You can adjust which branches autoclose in **Edit Repository**.
    This option is only available in Git.

If a branch is in good shape, you can check a specific commit by viewing it
in the web UI and clicking **Edit Commit**. There should be an **Autoclose?**
field visible in the form, with possible values listed below.

Note that this field records the state of the world at the time the commit was
processed, and does not necessarily reflect the current state of the world.
For example, if a commit did not trigger autoclose because it was processed
during initial import, the field will still show **No, Repository Importing**
even after import completes. This means that the commit did not trigger
autoclose because the repository was importing at the time it was processed,
not necessarily that the repository is still importing.

  - **Yes** At the time the commit was imported, autoclose triggered and
    Phabricator attempted to close related objects.
  - **No, Repository Importing** At the time the commit was processed, the
    repository was still importing. Autoclose does not activate until a
    repository fully imports for the first time.
  - **No, Autoclose Disabled** At the time the commit was processed, the
    repository had autoclose disabled.
  - **No, Not On Autoclose Branch** At the time the commit was processed,
    no containing branch was configured to autoclose.
  - //Field Not Present// This commit was processed before we implemented
    this diagnostic feature, and no information is available.


Manually Closing Revisions
==========================

If autoclose didn't activate for some reason and you want to manually close
revisions, you can do so in several ways:

**Close Revision**: The revision author can use the "Close Revision" action
from the web UI, located in the action dropdown on the revision page (where
reviewers would "Accept Revision" or "Request Changes").

`differential.always-allow-close`: If you set this option in {nav Config},
any user can take the "Close Revision" action in the web UI.

`arc close-revision`: You can close revisions from the command line by using
`arc close-revision`.


Next Steps
==========

Continue by:

  - troubleshooting in greater depth with
    @{article:Troubleshooting Repository Imports}.
