void SG_dagquery__new_since(SG_context * pCtx, SG_repo* pRepo, SG_uint64 iDagNum, const char* pszOldNodeHid, const char* pszNewNodeHid, SG_rbtree** pprbNewNodeHids) { SG_dagquery_relationship rel; new_since_context cbCtx; cbCtx.dagnum = iDagNum; cbCtx.prbNewNodeHids = NULL; cbCtx.pszNewNodeHid = pszNewNodeHid; cbCtx.pszOldNodeHid = pszOldNodeHid; SG_ERR_CHECK( SG_dagquery__how_are_dagnodes_related(pCtx, pRepo, iDagNum, pszNewNodeHid, pszOldNodeHid, SG_FALSE, SG_FALSE, &rel) ); if (rel != SG_DAGQUERY_RELATIONSHIP__DESCENDANT) SG_ERR_THROW2_RETURN(SG_ERR_UNSPECIFIED, (pCtx, "pszNewNodeHid must be a descendant of pszOldNodeHid")); SG_ERR_CHECK( SG_RBTREE__ALLOC(pCtx, &cbCtx.prbNewNodeHids) ); SG_ERR_CHECK( SG_dagwalker__walk_dag_single(pCtx, pRepo, iDagNum, pszNewNodeHid, _dagquery__new_since__callback, (void*)&cbCtx) ); SG_RETURN_AND_NULL(cbCtx.prbNewNodeHids, pprbNewNodeHids); /* Fall through to common cleanup */ fail: SG_RBTREE_NULLFREE(pCtx, cbCtx.prbNewNodeHids); }
void SG_sync__add_n_generations(SG_context* pCtx, SG_repo* pRepo, const char* pszDagnodeHid, SG_rbtree* prbDagnodeHids, SG_uint32 generations) { _dagwalk_data dagWalkData; SG_dagnode* pStartNode = NULL; SG_int32 startGen; dagWalkData.pszStartNodeHid = pszDagnodeHid; SG_ERR_CHECK( SG_repo__fetch_dagnode(pCtx, pRepo, pszDagnodeHid, &pStartNode) ); SG_ERR_CHECK( SG_dagnode__get_generation(pCtx, pStartNode, &startGen) ); dagWalkData.genLimit = startGen - generations; dagWalkData.prbVisitedNodes = prbDagnodeHids; SG_ERR_CHECK( SG_dagwalker__walk_dag_single(pCtx, pRepo, pszDagnodeHid, _dagwalk_callback, &dagWalkData) ); /* fall through */ fail: SG_DAGNODE_NULLFREE(pCtx, pStartNode); }