qaengine/src/ClientInterface.cxx
//--------------------------------------------------------------------------------
// Client hits to get list of hits
//--------------------------------------------------------------------------------
Client hits to get list of hits
Client hits to get list of hits
int ClientInterface::command_ListHits(string& reply,int socket, int id, ScopeSet scope) {
string query;
	reply = "";
    TaskDriver* newBuild    = m_Clients[socket]->getActiveProject();
	TaskDriver* oldBuild    = m_Clients[socket]->getActiveBaseLine();
	int mode = m_Clients[socket]->getMode();
	if(oldBuild!=NULL) {
		query = newBuild->getNodeProperty(id,scope,"Procedure");
	}
	HitsSet newHits;
	HitsSet oldHits;
    HitsSet::iterator i;
	if(oldBuild==NULL) {
        newHits = newBuild->getNodeHits(id,scope);
	    for(i=newHits.begin();i!=newHits.end();i++) {
		    Hit* hit = *i;
		    reply+=hit->toString();
		    reply+="\n";
		}
    } else {
        newHits = newBuild->getNodeHits(id,scope);
        oldHits = oldBuild->getNodeHits(id,scope);
	    for(i=newHits.begin();i!=newHits.end();i++) {
		    Hit* hit = *i;
			HitsSet matches = oldBuild->getHitsTablePtr()->compare(query,*hit);
			if(matches.size()==0) {
				if(mode==ALL_HITS || mode==NEW_HITS) {
		            reply+=hit->toString();
			        reply+="\t";
			        reply+="Delta";
			        reply+="\t";
			        reply+="New";
			        reply+="\n";
				}
			}
            if(matches.size()==1) {
				if(mode==ALL_HITS || mode==UNCHANGED_HITS) {
		            reply+=hit->toString();
			        reply+="\t";
			        reply+="Delta";
			        reply+="\t";
			        reply+="Unchanged";
			        reply+="\n";
				}
			}
			if(matches.size()>1) {
				HitsSet::iterator j;
				for(j=matches.begin();j!=matches.end();j++) {
				   Hit* oldHit = *j;
				   if((oldHit->getLine()==hit->getLine()) && (oldHit->getModule()==hit->getModule())) {
					   break;
				   }
				}
				if(j==matches.end()) {
				    if(mode==ALL_HITS || mode==NEW_HITS) {
		                reply+=hit->toString();
			            reply+="\t";
			            reply+="Delta";
			            reply+="\t";
			            reply+="New";
			            reply+="\n";
					}
				} else {
				    if(mode==ALL_HITS || mode==UNCHANGED_HITS) {
		                reply+=hit->toString();
			            reply+="\t";
			            reply+="Delta";
			            reply+="\t";
			            reply+="Unchanged";
			            reply+="\n";
					}
				}
			}
		}
	    for(i=oldHits.begin();i!=oldHits.end();i++) {
		    Hit* hit = *i;
			HitsSet matches = newBuild->getHitsTablePtr()->compare(query,*hit);
			if(matches.size()==0) {
				if(mode==ALL_HITS || mode==REMOVED_HITS) {
		            reply+=hit->toString();
			        reply+="\t";
			        reply+="Delta";
			        reply+="\t";
			        reply+="Removed";
			        reply+="\n";
				}
			}
			if(matches.size()>1) {
				HitsSet::iterator j;
				for(j=matches.begin();j!=matches.end();j++) {
				   Hit* oldHit = *j;
				   if((oldHit->getLine()==hit->getLine()) && (oldHit->getModule()==hit->getModule())) {
					   break;
				   }
				}
				if(j==matches.end()) {
				    if(mode==ALL_HITS || mode==REMOVED_HITS) {
				        reply+=hit->toString();
			            reply+="\t";
			            reply+="Delta";
			            reply+="\t";
			            reply+="Removed";
			            reply+="\n";
					}
				}
			}
		}
	}
	return 0;
}
int ClientInterface :: command_ListHits ( string & reply , int socket , int id , ScopeSet scope ) { string query ; reply = " " ; TaskDriver * newBuild = m_Clients [ socket ] -> getActiveProject ( ) ; TaskDriver * oldBuild = m_Clients [ socket ] -> getActiveBaseLine ( ) ; int mode = m_Clients [ socket ] -> getMode ( ) ; if ( oldBuild != NULL ) { query = newBuild -> getNodeProperty ( id , scope , " " ) ; } HitsSet newHits ; HitsSet oldHits ; HitsSet :: iterator i ; if ( oldBuild == NULL ) { newHits = newBuild -> getNodeHits ( id , scope ) ; for ( i = newHits . begin ( ) ; i != newHits . end ( ) ; i ++ ) { Hit * hit = * i ; reply += hit -> toString ( ) ; reply += " \n " ; } } else { newHits = newBuild -> getNodeHits ( id , scope ) ; oldHits = oldBuild -> getNodeHits ( id , scope ) ; for ( i = newHits . begin ( ) ; i != newHits . end ( ) ; i ++ ) { Hit * hit = * i ; HitsSet matches = oldBuild -> getHitsTablePtr ( ) -> compare ( query , * hit ) ; if ( matches . size ( ) == 0 ) { if ( mode == ALL_HITS || mode == NEW_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } if ( matches . size ( ) == 1 ) { if ( mode == ALL_HITS || mode == UNCHANGED_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } if ( matches . size ( ) > 1 ) { HitsSet :: iterator j ; for ( j = matches . begin ( ) ; j != matches . end ( ) ; j ++ ) { Hit * oldHit = * j ; if ( ( oldHit -> getLine ( ) == hit -> getLine ( ) ) && ( oldHit -> getModule ( ) == hit -> getModule ( ) ) ) { break ; } } if ( j == matches . end ( ) ) { if ( mode == ALL_HITS || mode == NEW_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } else { if ( mode == ALL_HITS || mode == UNCHANGED_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } } } for ( i = oldHits . begin ( ) ; i != oldHits . end ( ) ; i ++ ) { Hit * hit = * i ; HitsSet matches = newBuild -> getHitsTablePtr ( ) -> compare ( query , * hit ) ; if ( matches . size ( ) == 0 ) { if ( mode == ALL_HITS || mode == REMOVED_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } if ( matches . size ( ) > 1 ) { HitsSet :: iterator j ; for ( j = matches . begin ( ) ; j != matches . end ( ) ; j ++ ) { Hit * oldHit = * j ; if ( ( oldHit -> getLine ( ) == hit -> getLine ( ) ) && ( oldHit -> getModule ( ) == hit -> getModule ( ) ) ) { break ; } } if ( j == matches . end ( ) ) { if ( mode == ALL_HITS || mode == REMOVED_HITS ) { reply += hit -> toString ( ) ; reply += " \t " ; reply += " " ; reply += " \t " ; reply += " " ; reply += " \n " ; } } } } } return 0 ; }
Client hits to get list of hits
Client hits to get list of hits
// Check if we are in delta mode. // open command creates and assignes old build to the m_BuildBaseLines // if it runs with two arguments // We need procedure attribute as a static id of the query node. // We will use it to search for the matching hits while // creating delta // We are not in delta mode - so we will report hits as usual // We are in delta mode so two passes will be executed - first to // report only new hits , second to report removed hist. // Pass 1 - we will compare current hist against old reference table // to detect new hits. // No matching hit in the reference set - // assuming that the hit is new // Multiple matching hits in the reference set - // we will try to resolve it using line numbers // Trying to select hit using its line number // (will work if file was not modified) // No old hits with the same line number - // assuming this is new hit. // -- Pass 1 ends // Pass 2 - we will compare old hist against current hits // to detect removed hits // No matching hit in the reference set - // assuming that the hit is new // Multiple matching hits in the reference set - // we will try to resolve it using line numbers // Trying to select hit using its line number // (will work if file was not modified) // No old hits with the same line number - // assuming this is new hit. // -- Pass 2 ends