16e0bcd4f854

Switch to the new hg spanset API

This api was introduced in 3.2, and the indexation is not supported anymore (probably since
3.4)

Patch provided by David Douard
(see https://bitbucket.org/sjl/hg-review/pull-requests/8/better-handling-of-obsolescence-markers/diff#comment-8174971)
[view raw] [browse files]
author Christophe de Vienne <christophe@cdevienne.info>
date Fri, 19 Aug 2016 18:21:28 +0200
parents d483f003d230
children acf857ef0abe
branches/tags (none)
files README.markdown review/web.py

Changes

--- a/README.markdown	Fri Nov 21 17:04:06 2014 +0100
+++ b/README.markdown	Fri Aug 19 18:21:28 2016 +0200
@@ -4,7 +4,7 @@
 Installing
 ==========
 
-`hg-review` requires Mercurial 2.3+ and Python 2.5+. It requires a few other
+`hg-review` requires Mercurial 3.2+ and Python 2.5+. It requires a few other
 things too, but they're bundled with the extension so you don't need to worry
 about them.
 
--- a/review/web.py	Fri Nov 21 17:04:06 2014 +0100
+++ b/review/web.py	Fri Aug 19 18:21:28 2016 +0200
@@ -130,15 +130,15 @@
     revs = g.datastore.target.revs('sort(last(:%s, %s), -rev)' % (
         rev_max, LOG_PAGE_LEN))
 
-    rev_max, rev_min = revs[0], revs[-1]
+    rev_max, rev_min = revs.first(), revs.last()
 
-    older = g.datastore.target.revs('first(last(:%s, 2))' % rev_min)[0]
+    older = g.datastore.target.revs('first(last(:%s, 2))' % rev_min).first()
 
     if rev_max == tip:
         newer = -1
     else:
         newer = g.datastore.target.revs('last(first(%s:, %s))' % (
-            rev_max, LOG_PAGE_LEN + 1))[0]
+            rev_max, LOG_PAGE_LEN + 1)).first()
 
     rcsets = [g.datastore[r] for r in revs]
     return _render('index.html', rcsets=rcsets, newer=newer, older=older)
@@ -202,10 +202,10 @@
 
     tip = g.datastore.target['tip'].rev()
     newer = rcset.target[
-        rcset.target.revs('sort(first(%s:, 2), -rev)' % rev.rev())[0]
+        rcset.target.revs('sort(first(%s:, 2), -rev)' % rev.rev()).first()
     ] if rev.rev() < tip else None
     older = rcset.target[
-        rcset.target.revs('sort(last(:%s, 2), rev)' % rev.rev())[0]
+        rcset.target.revs('sort(last(:%s, 2), rev)' % rev.rev()).first()
     ] if rev.rev() > 0 else None
 
     return _render('changeset.html', rcset=rcset, rev=rev, cu_signoff=cu_signoff,