Index: tracdarcs/repository.py
===================================================================
--- tracdarcs/repository.py	(revision 198)
+++ tracdarcs/repository.py	(revision 199)
@@ -617,18 +617,51 @@
         props = dict(Hashname=self.__hash)
 
+        # See if there are any "related repository", with a common "identity"
+        # property.
+
+        c = self.repos.db.cursor()
+        c.execute("SELECT rep2.id "
+                  "FROM repository rep, repository rep2 "
+                  "WHERE rep.id=%s"
+                  "  AND rep.name='identity'"
+                  "  AND rep2.id<>rep.id"
+                  "  AND rep2.name='identity'"
+                  "  AND rep2.value=rep.value", (self.repos.id,))
+        other_rids = [r[0] for r in c.fetchall()]
+
+        if not other_rids:
+            return props
+
         # Compute a list of "equivalent changesets", when the same
-        # changeset is present in other repositories.
-
-        c = self.repos.db.cursor()
-        c.execute('SELECT rep.value, dcs.rev '
-                  'FROM darcs_changesets dcs, darcs_changesets dcs2, repository rep '
-                  'WHERE dcs2.repo_id = %s AND dcs2.rev = %s '
-                  '  AND dcs.hash = dcs2.hash '
-                  '  AND dcs.repo_id <> dcs2.repo_id'
-                  '  AND rep.id = dcs.repo_id AND rep.name = \'name\''
-                  'ORDER BY rep.value', (self.repos.id, self.rev))
+        # changeset is present in other related repositories.
+
+        other_rids = ','.join(str(rid) for rid in other_rids),
+
+        c.execute("SELECT rep.value, dcs.rev "
+                  "FROM darcs_changesets dcs, repository rep "
+                  "WHERE dcs.hash = %%s"
+                  "  AND dcs.repo_id IN (%s)"
+                  "  AND rep.id = dcs.repo_id AND rep.name = 'name'"
+                  "ORDER BY rep.value" % other_rids,
+                  (self.__hash,))
         eqcsets = [(repo, rev) for repo,rev in c.fetchall()]
-        if eqcsets:
-            props['EqChangesets'] = eqcsets
+        props['PresentIn'] = eqcsets
+
+        # Compute the opposite list, that is the repositories where
+        # the changeset is missing.
+
+        c.execute("SELECT rep.value "
+                  "FROM repository rep "
+                  "WHERE rep.name='name'"
+                  "  AND rep.id IN (%s)"
+                  "  AND NOT EXISTS ("
+                  "SELECT dcs.rev "
+                  "FROM darcs_changesets dcs "
+                  "WHERE dcs.repo_id=rep.id"
+                  "  AND dcs.hash=%%s) "
+                  "ORDER BY rep.value" % other_rids,
+                  (self.__hash,))
+        mir = [r[0] for r in c.fetchall()]
+        props['MissingIn'] = mir
 
         return props
