This function can incorporate changes from two modified versions (our and their) into a common preceding version (base) of a key set.
This lets you merge the sets of changes represented by the two newer key sets. This is called a three-way merge between key sets.
#include <kdb.h>
#include <stdio.h>
static void print_results (KeySet * result, Key * resultRoot, Key * informationKey)
{
for (elektraCursor i = 0; i <
ksGetSize (conflictingKeys); i++)
{
}
printf ("Result:\n");
for (elektraCursor i = 0; i <
ksGetSize (result); i++)
{
}
if (result == NULL)
{
printf ("Aborted.\n");
}
}
{
Key * informationKey = keyDup (baseRoot,
KEY_CP_ALL);
printf ("Trying merge strategy ABORT\n");
print_results (result, resultRoot, informationKey);
printf ("\nTrying merge strategy OUR\n");
print_results (result, resultRoot, informationKey);
printf ("\nTrying merge strategy THEIR\n");
print_results (result, resultRoot, informationKey);
return 0;
}
int keyDel(Key *key)
A destructor for Key objects.
Definition: key.c:459
Key * keyNew(const char *name,...)
A practical way to fully create a Key object in one step.
Definition: key.c:144
@ KEY_END
Definition: kdbenum.c:95
@ KEY_VALUE
Definition: kdbenum.c:88
@ KEY_CP_ALL
Definition: kdbenum.c:110
const char * keyName(const Key *key)
Returns a pointer to the abbreviated real internal key name.
Definition: elektra/keyname.c:432
int ksDel(KeySet *ks)
A destructor for KeySet objects.
Definition: keyset.c:521
KeySet * ksNew(size_t alloc,...)
Allocate, initialize and return a new KeySet object.
Definition: keyset.c:282
ssize_t ksGetSize(const KeySet *ks)
Return the number of Keys that ks contains.
Definition: keyset.c:791
#define KS_END
End of a list of keys.
Definition: kdbenum.c:156
Key * ksAtCursor(const KeySet *ks, elektraCursor pos)
Return Key at given position pos.
Definition: keyset.c:1978
const char * keyString(const Key *key)
Get a pointer to the c-string representing the value.
Definition: keyvalue.c:208
@ MERGE_STRATEGY_OUR
Definition: kdbmerge.h:28
@ MERGE_STRATEGY_THEIR
Definition: kdbmerge.h:29
@ MERGE_STRATEGY_ABORT
Definition: kdbmerge.h:26
KeySet * elektraMerge(KeySet *our, Key *ourRoot, KeySet *their, Key *theirRoot, KeySet *base, Key *baseRoot, Key *resultKey, enum MergeStrategy strategy, Key *informationKey)
This function can incorporate changes from two modified versions (our and their) into a common preced...
Definition: kdbmerge.c:1177
KeySet * elektraMergeGetConflictingKeys(Key *informationKey, Key *root)
Returns a keyset with all conflicting keys under the specified root.
Definition: kdbmerge.c:318
int main(int argc, char **argv)
[kdbio testsuite main]
Definition: testio_doc.c:48