--- a/tests/test-revset.t Mon Jun 13 18:20:00 2016 +0100
+++ b/tests/test-revset.t Mon Jun 13 18:20:00 2016 +0100
@@ -1106,6 +1106,67 @@
0 b12 m111 u112 111 10800
2 b111 m11 u12 111 3600
+ toposort prioritises graph branches
+
+ $ hg up 2
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ touch a
+ $ hg addremove
+ adding a
+ $ hg ci -m 't1' -u 'tu' -d '130 0'
+ created new head
+ $ echo 'a' >> a
+ $ hg ci -m 't2' -u 'tu' -d '130 0'
+ $ hg book book1
+ $ hg up 4
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ (leaving bookmark book1)
+ $ touch a
+ $ hg addremove
+ adding a
+ $ hg ci -m 't3' -u 'tu' -d '130 0'
+
+ $ hg log -r 'sort(all(), topo)'
+ 7 b111 t3 tu 130 0
+ 4 b111 m112 u111 110 14400
+ 3 b112 m111 u11 120 0
+ 6 b111 t2 tu 130 0
+ 5 b111 t1 tu 130 0
+ 2 b111 m11 u12 111 3600
+ 1 b11 m12 u111 112 7200
+ 0 b12 m111 u112 111 10800
+
+ $ hg log -r 'sort(all(), -topo)'
+ 0 b12 m111 u112 111 10800
+ 1 b11 m12 u111 112 7200
+ 2 b111 m11 u12 111 3600
+ 5 b111 t1 tu 130 0
+ 6 b111 t2 tu 130 0
+ 3 b112 m111 u11 120 0
+ 4 b111 m112 u111 110 14400
+ 7 b111 t3 tu 130 0
+
+ $ hg log -r 'sort(all(), topo, topo.firstbranch=book1)'
+ 6 b111 t2 tu 130 0
+ 5 b111 t1 tu 130 0
+ 7 b111 t3 tu 130 0
+ 4 b111 m112 u111 110 14400
+ 3 b112 m111 u11 120 0
+ 2 b111 m11 u12 111 3600
+ 1 b11 m12 u111 112 7200
+ 0 b12 m111 u112 111 10800
+
+topographical sorting can't be combined with other sort keys, and you can't
+use the topo.firstbranch option when topo sort is not active:
+
+ $ hg log -r 'sort(all(), "topo user")'
+ hg: parse error: topo sort order cannot be combined with other sort keys
+ [255]
+
+ $ hg log -r 'sort(all(), user, topo.firstbranch=book1)'
+ hg: parse error: topo.firstbranch can only be used when using the topo sort key
+ [255]
+
$ cd ..
$ cd repo