Skip to content

Sort patches in a series based on patch number. - #5

Open
putnopvut wants to merge 1 commit into
igsilya:mainfrom
putnopvut:sorted_patches
Open

Sort patches in a series based on patch number.#5
putnopvut wants to merge 1 commit into
igsilya:mainfrom
putnopvut:sorted_patches

Conversation

@putnopvut

Copy link
Copy Markdown

When pressing space to expand a series, the patches are listed in an arbitrary order. This can make it difficult to view patches in order or notices on large series that patches are missing (usually due to patchwork errors).

This commit sorts the patches based on patch number. This solves the issues stated above.

@igsilya igsilya left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order is not random, it's the order in which the patches are in patchwork database, i.e. ordered by ID. May be good to re-word this in the commit / PR description. But I agree that not having them sorted by a patch number is annoying.

We'll need a small TestSeriesToRow* test for this though. Or at least a modification of the main TestSeriesToRow to minimally check the sorting behavior.

Also, LLMs point out that the comment in TestCompareStartsAtSelectedPatch about the patch order by ID is stale after this change, so will need an adjustment.

You should also use tui: as a subject prefix for the commit.
Thanks!

When pressing space to expand a series, the patches are listed in order
based on their patch ID. This does not always align with the ordering
of the patches in the series. This can make it difficult to view patches
in order or notice on large series that patches are missing (usually
due to patchwork errors).

This commit sorts the patches based on patch number. This solves the
issues stated above.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
@putnopvut

Copy link
Copy Markdown
Author

Hi Ilya, I noticed that I did not address the finding about the outdated comment in TestCompareStartsAtSelectedPatch. I looked through the test, and I'm assuming it's this comment:

    // Verify left patches are sorted by position, not date/ID.
    // Position order: [1/3]=402, [2/3]=400, [3/3]=401

This should instead say that patches are sorted by patch number. I also noticed this comment:

    // Expand series 60 and navigate to patch 402 "[1/3] Ipsum first".
    // In the table, patches are ordered by ID (from GetAllPatchesBatch),
    // so subrow order is: 400 [2/3], 401 [3/3], 402 [1/3].
    // Patch 402 is at subRowIdx=2 in the table.

However, I'm not going to update this since this patch does not affect how the patches are stored in the DB.

@igsilya

igsilya commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Hi Ilya, I noticed that I did not address the finding about the outdated comment in TestCompareStartsAtSelectedPatch. I looked through the test, and I'm assuming it's this comment:

    // Verify left patches are sorted by position, not date/ID.
    // Position order: [1/3]=402, [2/3]=400, [3/3]=401

This should instead say that patches are sorted by patch number. I also noticed this comment:

Word 'position' is used here instead of the 'patch number', but I suppose it's fine, it means the same thing in this context. Can keep as is.

    // Expand series 60 and navigate to patch 402 "[1/3] Ipsum first".
    // In the table, patches are ordered by ID (from GetAllPatchesBatch),
    // so subrow order is: 400 [2/3], 401 [3/3], 402 [1/3].
    // Patch 402 is at subRowIdx=2 in the table.

However, I'm not going to update this since this patch does not affect how the patches are stored in the DB.

You're right, this is about order in the database and not in the UI. The LLM hallucinated a lot on this run. Let's keep as is as well.

@igsilya igsilya left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the tests. Though you're trying to fix the UI in case the ID order doesn't match the actual patch order, but it seems like none of the tests are actually covering this scenario. Also, it may be better to define an array of test cases and then run them in a loop with a common logic, but diferent data, as we do in other tests. Will probbaly save some LOCs. The specific original order preserved message is probably not necessary, the tests are small enough to understand the intention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants