# HG changeset patch # User Jun Wu # Date 2017-04-03 01:12:47 # Node ID 8a0c47982ade05dd13720c12e5da8be0ab1d809a # Parent dff03f68ef11b7f30b8aac32e9adcc36ac64c370 test-revlog-raw: fix "genbits" implementation The "genbits" implementation is actually incorrect. This patch fixes it. A good "genbits" implementation should pass the below assertion: n = 3 # or other number l = list(genbits(n)) assert 2**(n*2) == len(set((l[i]<> 1) + reversegray = dict((gray(i), i) for i in range(m)) # Generate (n * 2) bit gray code, yield lower n bits as X, and look for # the next unused gray code where higher n bits equal to X. @@ -177,7 +178,9 @@ def genbits(n): x = 0 yield x for i in range(m * m): + x = reversegray[x] y = gray(a[x] + x * m) & (m - 1) + assert a[x] < m a[x] += 1 x = y yield x