Skip to content

Commit

Permalink
add repodata_translate_id to get rid of some "implement me" assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Apr 23, 2013
1 parent 7c91488 commit 772a525
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ext/repo_rpmdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1396,8 +1396,8 @@ copydir_complex(Pool *pool, Repodata *data, Repodata *fromdata, Id did, Id *cach
Id compid = dirpool_compid(&fromdata->dirpool, did);
if (parent)
parent = copydir(pool, data, fromdata, parent, cache);
if (fromdata->localpool)
compid = repodata_globalize_id(fromdata, compid, 1);
if (data->localpool || fromdata->localpool)
compid = repodata_translate_id(data, fromdata, compid, 1);
compid = dirpool_add_dir(&data->dirpool, parent, compid, 1);
if (cache)
{
Expand Down Expand Up @@ -1430,9 +1430,8 @@ solvable_copy_cb(void *vcbdata, Solvable *r, Repodata *fromdata, Repokey *key, K
case REPOKEY_TYPE_CONSTANTID:
case REPOKEY_TYPE_IDARRAY: /* used for triggers */
id = kv->id;
if (fromdata->localpool)
id = repodata_globalize_id(fromdata, id, 1);
assert(!data->localpool); /* implement me! */
if (data->localpool || fromdata->localpool)
id = repodata_translate_id(data, fromdata, id, 1);
if (key->type == REPOKEY_TYPE_ID)
repodata_set_id(data, handle, keyname, id);
else if (key->type == REPOKEY_TYPE_CONSTANTID)
Expand All @@ -1455,13 +1454,11 @@ solvable_copy_cb(void *vcbdata, Solvable *r, Repodata *fromdata, Repokey *key, K
case REPOKEY_TYPE_DIRNUMNUMARRAY:
id = kv->id;
id = copydir(pool, data, fromdata, id, cbdata->dircache);
assert(!data->localpool); /* implement me! */
repodata_add_dirnumnum(data, handle, keyname, id, kv->num, kv->num2);
break;
case REPOKEY_TYPE_DIRSTRARRAY:
id = kv->id;
id = copydir(pool, data, fromdata, id, cbdata->dircache);
assert(!data->localpool); /* implement me! */
repodata_add_dirstr(data, handle, keyname, id, kv->str);
break;
case REPOKEY_TYPE_FLEXARRAY:
Expand Down
1 change: 1 addition & 0 deletions src/libsolv.ver
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ SOLV_1.0 {
repodata_str2dir;
repodata_stringify;
repodata_swap_attrs;
repodata_translate_id;
repodata_unset;
repodata_unset_uninternalized;
repodata_write;
Expand Down
17 changes: 17 additions & 0 deletions src/repodata.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,23 @@ repodata_localize_id(Repodata *data, Id id, int create)
return stringpool_str2id(&data->spool, pool_id2str(data->repo->pool, id), create);
}

Id
repodata_translate_id(Repodata *data, Repodata *fromdata, Id id, int create)
{
if (!id || !data || !fromdata)
return id;
if (!data->localpool || !fromdata->localpool)
{
if (fromdata->localpool)
id = repodata_globalize_id(fromdata, id, create);
if (data->localpool)
id = repodata_localize_id(data, id, create);
return id;
}
/* localpool is set in both data and fromdata */
return stringpool_str2id(&data->spool, stringpool_id2str(&fromdata->spool, id), create);
}

Id
repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id voidid)
{
Expand Down
2 changes: 2 additions & 0 deletions src/repodata.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ void repodata_disable_paging(Repodata *data);
/* helper functions */
Id repodata_globalize_id(Repodata *data, Id id, int create);
Id repodata_localize_id(Repodata *data, Id id, int create);
Id repodata_translate_id(Repodata *data, Repodata *fromdata, Id id, int create);

Id repodata_str2dir(Repodata *data, const char *dir, int create);
const char *repodata_dir2str(Repodata *data, Id did, const char *suf);
const char *repodata_chk2str(Repodata *data, Id type, const unsigned char *buf);
Expand Down

0 comments on commit 772a525

Please sign in to comment.