MBS-7482: Merge ACs using swap functionality rather than UPDATE, to ensure already-extant ACs do not become duplicated on artist merge
MBS-7482: Add a test that string-equivalent ACs that will become duplicate upon merge are actually merged
Make the bubbles redraw less often in the release editor

The with binding causes all the HTML underneath it to redraw, as
explained by
http://www.knockmeout.net/2012/03/knockoutjs-performance-gotcha-1ifwith.html

This is bad because it makes to harder for userscripts to modify the
HTML. Anything added to the HTML is lost when a redraw occurs, because
knockout caches the original HTML for reuse.

I took the advice of the above article and made sure to "use the with
binding in smaller, targeted areas" where possible.

Most notably, the button sets in the AC editors no longer redraw.
Add a hook for filtering possible duplicates

Add a filter_duplicates hook to the CheckDuplicates role that can be
overridden by consumers and allows them to preprocess the list of
possible duplicates. This can be used to load additional data for
them, to remove entries from the list, and to order entries, among
others. The function may also decide whether a disambiguation comment
is required or not; this defaults to yes in order to retain the
previous behaviour.
Load area information for possible place duplicates
MBS-7411: Require place disambiguation only if necessary

Only require the user to enter a disambiguation comment for a place if
its area is not enough for disambiguation, i.e. if another place with
a similar place is in the same area or if no area is given.

In addition, possible duplicates are sorted, with the most unlikely
duplicates (e.g. in a different country) coming last.
Remove duplicate line
MBS-5897: Give access to raw edit data

Introduce a new /edit/:id/data endpoint that displays the raw data for
the given edit, for cases where the regular edit display fails or is
not sufficiently detailed for debugging purposes.

The link from the regular edit page is intentionally inconspicuous
since it is targetted at developers and near-developers, not at normal
users.
Display entities related to an edit

On the /edit/:id/data page introduced by the previous commit, list the
entities that have this edit in their edit history (edit_artist etc.
tables). This is particularly useful when entities have been merged
after the edit was entered, because the entity IDs referred to in the
edit data are not updated but the edit history is.
Display more information about edits on ISE page

When an internal server error occurs on a page that is supposed to
show edits, give more information about these edits on the ISE page.
In particular, list the edits by ID with a link both to their regular
page and to the raw edit data, and say whether the display data was
successfully loaded or not (which may give a hint as to which edit has
caused the error).

To achieve this, the hash containing the edits is stashed as soon as
possible in the relevant controllers, before loading any additional
data, so that it is accessible for the ISE template.
Factor out loading edit-related data

There are eight places where controllers load display data, votes,
edit notes, and editor data for a set of edits. Factor out this into a
helper function "load_everything_for_edits".
Include edit IDs in ISE emails

Catch any exceptions that may occur while loading data for displaying
edits and include the IDs of the relevant edits in the mail
notification that is sent for internal server errors.
Simplify relationship_target_links

Defer to descriptive_link for displaying the full "{entity} by
{artist}" text if the artist credit is not to be hidden, instead of
re-implementing this in relationship_target_links.
Use foreign keys for loading place merge edit data

Instead of explicitly calling the load functions before
build_display_data, load place types and area for place merge edits
via foreign_keys.
MBS-6886: Display area after place names

Generally display the area in which a place is located after its name,
and the containing areas after the name of an area, to help with
disambiguating names without requiring comments that repeat the area
information. E.g., instead of "premiered at: Royal Opera House", it
will now say "premiered at: Royal Opera House in London, England,
United Kingdom".
Replace link_area_with_containment in templates

Use descriptive_link instead of link_area_with_containment, now that
the former calls the latter for areas.
Add a special model for loading area containments

Add a special model AreaContainment that can be used in edit
foreign_keys to load the containment for an area.
Allow models to be chained in edit foreign_keys

Extend load_all to support a list of space-separated models to be
chain-loaded. E.g., an edit can now request in its foreign_keys a
post-load of "Area AreaContainment" for a place, meaning that the area
is to be loaded, then the containment not for the original place, but
for the area loaded in the first step.
Add infrastructure for auto-including models

Extend load_all with a new default_includes function that modifies the
data structure holding the objects to be loaded, automatically adding
post-load models according to a list of "if we load this model, we
also want that model" associations.

This commit only provides the infrastructure for that. The list
remains empty.
Show areas with containing areas in edit display

When displaying an edit, make sure that places and areas are shown
with their containing areas. This makes use of the infrastructure for
automatically including post-load models that was added in the
previous commit. In addition, a lot of templates are changed to use
descriptive_link instead of link_entity.