Fork of patx/hglab.

fix list ordering

Commit 6b9ce73ed049 · Harrison Erd · 2026-05-04 18:05 -0400

Changeset
6b9ce73ed0499aab6d90145477fa201525deca73

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -1200,7 +1200,16 @@
 
 
 def ancestors_revset(node):
-    return f"ancestors({validate_revision_id(node, allow_null=False)})"
+    revision = validate_revision_id(node, allow_null=False)
+    return f"sort(ancestors({revision}), -rev)"
+
+
+def newest_revision_sort_key(item):
+    try:
+        revision = int(item["rev"])
+    except (KeyError, TypeError, ValueError):
+        revision = -1
+    return (revision, item.get("date", ""), item.get("name", ""))
 
 
 def commit_log(path, limit=50, revision=None):
@@ -1264,6 +1273,7 @@
                 "summary": parts[5],
             }
         )
+    tags.sort(key=newest_revision_sort_key, reverse=True)
     return tags
 
 
@@ -1361,6 +1371,7 @@
                 "is_default": False,
             }
         )
+    branches.sort(key=newest_revision_sort_key, reverse=True)
     return branches
 
 
@@ -1398,6 +1409,7 @@
                 "is_default": False,
             }
         )
+    bookmarks.sort(key=newest_revision_sort_key, reverse=True)
     return bookmarks
 
 
@@ -1707,7 +1719,7 @@
             FROM issues
             JOIN users ON users.id = issues.author_id
             {where}
-            ORDER BY issues.number DESC
+            ORDER BY issues.updated_at DESC, issues.number DESC
             """,
             params,
         ).fetchall()
@@ -1799,7 +1811,7 @@
         params.append(status)
     with db_connect() as conn:
         return conn.execute(
-            pull_request_select_sql(where) + " ORDER BY pull_requests.number DESC",
+            pull_request_select_sql(where) + " ORDER BY pull_requests.updated_at DESC, pull_requests.number DESC",
             params,
         ).fetchall()