Always provide revision-related headers for Mercurial diffs.
Review Request #11151 — Created Aug. 30, 2020 and submitted — Latest diff uploaded
Git-style Mercurial diffs lack any useful information for specifying the
revisions of files. This meant that Review Board couldn't normally
extract any useful identifying information for any file fetches. We had
worked around this in the past by utilizing the diff upload API's
base_commit_id
field, but that still meant that some information was
missing.This triggered a breakage whenever a change consisted of a moved file.
Since the revision information wasn't available, the original file
couldn't be fetched correctly, since thebase_commit_id
wasn't enough
to help look it up.Fortunately, Review Board does include support for extracting special
Mercurial headers containing this information. Those are only natively
generated in anhg export
(see
https://bz.mercurial-scm.org/show_bug.cgi?id=6400), but adding this to
RBTools-generated Mercurial diffs is trivial.This change implements these headers when generating diffs. We now
always generate a Git-style diff (which was effectively the behavior
for any modern version of Review Board anyway) and prepend these headers
to it.All diff-related unit tests have been rewritten to carefully ensure that
we're generating these diffs correctly and that they have the exact
output we expect.
Unit tests passed.
Verified that generated diffs contained revision information and that
Review Board successfully used that to locate files, even when modifying
changes moved in a parent diff.