Ensure consistent ordering of filediffs for patch generation.

Review Request #14375 — Created March 19, 2025 and updated

Information

Review Board
release-7.1.x

Reviewers

When generating diffs from FileDiffs or results for the FileDiff
resource, we were using the database's default sort order. For MySQL and
MariaDB, this is going to be the primary key, but that's not guaranteed
for Postgres. For Postgres, we can get an entirely different order.

This can pose a problem for diffs that are sensitive to file orders,
namely Mercurial, which contains identifying information for the commit
in the first file. We need these to be in the insert order, as that's
the order in which we parse from the sourcediff.

We now explicitly sort these by the primary key in these cases. We're
not setting this as the default sort order at this time, in order to
avoid any surprises elsewhere, and to be explicit about the order we
know we need in these particular cases.

Unit tests pass.

Verified this fix with a customer who had previously encountered
this issue.

Summary ID
Ensure consistent ordering of filediffs for patch generation.
When generating diffs from FileDiffs or results for the FileDiff resource, we were using the database's default sort order. For MySQL and MariaDB, this is going to be the primary key, but that's not guaranteed for Postgres. For Postgres, we can get an entirely different order. This can pose a problem for diffs that are sensitive to file orders, namely Mercurial, which contains identifying information for the commit in the first file. We need these to be in the insert order, as that's the order in which we parse from the sourcediff. We now explicitly sort these by the primary key in these cases. We're not setting this as the default sort order at this time, in order to avoid any surprises elsewhere, and to be explicit about the order we know we need in these particular cases.
589f90b635cb1b572c267efe05d175848028d211
Checks run (2 succeeded)
flake8 passed.
JSHint passed.
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
Loading...