3c3734c184d9

Use revsets to find newer and older cset of the current changeset.

With obsolescence markers enabled, rev numbers are not linear
[view raw] [browse files]
author Christophe de Vienne <cdevienne@gmail.com>
date Mon, 27 Oct 2014 22:38:16 +0100
parents 3e5dfa8a94ef
children 9ee9ef21460c
branches/tags (none)
files review/web.py

Changes

--- a/review/web.py	Mon Oct 27 18:42:14 2014 +0100
+++ b/review/web.py	Mon Oct 27 22:38:16 2014 +0100
@@ -190,8 +190,12 @@
     cu_signoff = cu_signoffs[0] if cu_signoffs else None
 
     tip = g.datastore.target['tip'].rev()
-    newer = rcset.target[rev.rev() + 1] if rev.rev() < tip else None
-    older = rcset.target[rev.rev() - 1] if rev.rev() > 0 else None
+    newer = rcset.target[
+        rcset.target.revs('sort(first(%s:, 2), -rev)' % rev.rev())[0]
+    ] if rev.rev() < tip else None
+    older = rcset.target[
+        rcset.target.revs('sort(last(:%s, 2), rev)' % rev.rev())[0]
+    ] if rev.rev() > 0 else None
 
     return _render('changeset.html', rcset=rcset, rev=rev, cu_signoff=cu_signoff,
         newer=newer, older=older)