--- /dev/null
+Return-Path: <david@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id D7056431FBC\r
+ for <notmuch@notmuchmail.org>; Mon, 7 Apr 2014 03:40:12 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id YkiKpMzYtA-b for <notmuch@notmuchmail.org>;\r
+ Mon, 7 Apr 2014 03:40:08 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224]) (using TLSv1 with cipher AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 13324431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 7 Apr 2014 03:40:08 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.72) (envelope-from <david@tethera.net>)\r
+ id 1WX6wJ-0007XK-Rx; Mon, 07 Apr 2014 10:38:07 +0000\r
+Received: (nullmailer pid 22010 invoked by uid 1000); Mon, 07 Apr 2014\r
+ 10:37:48 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] test: Test thread linking in all possible delivery orders\r
+In-Reply-To: <1395608456-9673-1-git-send-email-amdragon@mit.edu>\r
+References: <1395608456-9673-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.17+174~g4efbc9f (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 07 Apr 2014 07:37:48 -0300\r
+Message-ID: <87y4zhfmrn.fsf@maritornes.cs.unb.ca>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 07 Apr 2014 10:40:13 -0000\r
+\r
+Austin Clements <amdragon@MIT.EDU> writes:\r
+> +THREADS=$(python -c '\r
+> +def mkTrees(free, tree={}):\r
+> + if not free:\r
+\r
+I'm not sure if using not for an empty set is idiomatic python or not,\r
+but it did confuse me a moment.\r
+\r
+> + print(" ".join(map(str, [msg[1] for msg in sorted(tree.items())])))\r
+> + return\r
+> + # Attach each free message to each message in the tree (if there is\r
+> + # no tree, make the free message the root)\r
+> + for msg in sorted(free):\r
+> + parents = sorted(tree.keys()) if tree else ["none"]\r
+> + for parent in parents:\r
+> + ntree = tree.copy()\r
+> + ntree[msg] = parent\r
+> + mkTrees(free - set([msg]), ntree)\r
+> +mkTrees(set(range(4)))')\r
+\r
+FWIW, it took me a while to understand this. I might have twigged\r
+faster if the initial comment said something like "via backtracking".\r
+\r
+> +output=$(notmuch search '*' | notmuch_search_sanitize)\r
+\r
+> +expected=$(for ((i = 0; i < $nthreads; i++)); do\r
+> + echo "thread:XXX 2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)"\r
+> + done)\r
+> +test_expect_equal "$output" "$expected"\r
+\r
+It seems to me this summary line depends on the default search order.\r
+It might be worth specifying the search order in the "notmuch search"\r
+command just to make it a bit more robust.\r
+\r
+d\r