c73b604073cf90818fdfafd1c711b9b508835e52
angie
  Thu Jun 19 12:42:01 2014 -0700
hdb's hGetParent wasn't working because it used hMaybeTrackInfo whichlooks up only one track, not its parent or children.  It was used in only
one place in the code, so I replaced it with a call to tdbForTrack.
fixes #13477 (Search results don't open super tracks)

diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c
index b684b2b..a0ccd69 100644
--- src/hg/lib/hgFind.c
+++ src/hg/lib/hgFind.c
@@ -2419,81 +2419,87 @@
 return(found);
 }
 
 static void hgPositionsHtml(char *db, struct hgPositions *hgp, FILE *f,
 		     boolean useWeb, char *hgAppName, struct cart *cart)
 /* Write out hgp table as HTML to file. */
 {
 struct hgPosTable *table;
 struct hgPos *pos;
 char *desc;
 char range[HGPOSRANGESIZE];
 char *ui = getUiUrl(cart);
 char *extraCgi = hgp->extraCgi;
 char hgAppCombiner = (strchr(hgAppName, '?')) ? '&' : '?';
 boolean containerDivPrinted = FALSE;
+struct trackDb *tdbList = NULL;
 
 if (useWeb)
     {
     webStart(cart, db, "Select Position");
     db = cartString(cart, "db");
     }
 
 for (table = hgp->tableList; table != NULL; table = table->next)
     {
     if (table->posList != NULL)
 	{
-	char *parent = hGetParent(db, table->name);
-	char *trackName = table->name;
-	// TODO: should be able to get this from settings hash for
-	// both hub tracks and normal tracks
-	if (!isHubTrack(table->name)) 
-	    trackName = hGetTrackForTable(db, table->name);
-        if (trackName == NULL)
-            errAbort("no track for table \"%s\" found via a findSpec", table->name); // wish we had searchName
+	char *tableName = table->name;
+	if (startsWith("all_", tableName))
+	    tableName += strlen("all_");
+	struct trackDb *tdb = tdbForTrack(db, tableName, &tdbList);
+	if (!tdb)
+            errAbort("no track for table \"%s\" found via a findSpec", tableName);
+	char *trackName = tdb->track;
 	char *vis = hCarefulTrackOpenVis(db, trackName);
 	boolean excludeTable = FALSE;
         if(!containerDivPrinted)
             {
             fprintf(f, "<div id='hgFindResults'>\n");
             containerDivPrinted = TRUE;
             }
 	if (table->htmlStart) 
 	    table->htmlStart(table, f);
 	else
 	    fprintf(f, "<H2>%s</H2><PRE>\n", table->description);
 	for (pos = table->posList; pos != NULL; pos = pos->next)
 	    {
 	    if (table->htmlOnePos)
 	        table->htmlOnePos(table, pos, f);
 	    else
 		{
 		char *matches = excludeTable ? "" : pos->browserName;
 		char *encMatches = cgiEncode(matches);
 		hgPosBrowserRange(pos, range);
 		fprintf(f, "<A HREF=\"%s%cposition=%s",
 			hgAppName, hgAppCombiner, range);
 		if (ui != NULL)
 		    fprintf(f, "&%s", ui);
 		fprintf(f, "%s&", extraCgi);
 		fprintf(f, "%s=%s&", trackName, vis);
 		// this is magic to tell the browser to make the 
 		// composite and this subTrack visible
-		if (parent)
+		if (tdb->parentName)
 		    {
+		    if (tdbIsSuperTrackChild(tdb))
+			fprintf(f, "%s=show&", tdb->parentName);
+		    else
+			{
+			// tdb is a subtrack of a composite or a view
 			fprintf(f, "%s_sel=1&", trackName);
-		    fprintf(f, "%s_sel=1&", parent);
+			fprintf(f, "%s_sel=1&", tdb->parentName);
+			}
 		    }
 		fprintf(f, "hgFind.matches=%s,\">", encMatches);
 		htmTextOut(f, pos->name);
 		fprintf(f, " at %s</A>", range);
 		desc = pos->description;
 		if (desc)
 		    {
 		    fprintf(f, " - ");
 		    htmTextOut(f, desc);
 		    }
 		fprintf(f, "\n");
 		freeMem(encMatches);
 		}
 	    }
 	if (table->htmlEnd)