Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

cmerge: add methods to get all conflicting keys #4515

Merged
merged 18 commits into from
Feb 6, 2023

Conversation

atmaxinger
Copy link
Contributor

@atmaxinger atmaxinger commented Oct 6, 2022

Fixes #4489

Basics

  • Short descriptions of your changes are in the release notes
    (added as entry in doc/news/_preparation_next_release.md which
    contains _(my name)_)
    Please always add something to the release notes.
  • Details of what you changed are in commit messages
    (first line should have module: short statement syntax)
  • References to issues, e.g. close #X, are in the commit messages.
  • The buildservers are happy. If not, fix in this order:
    • add a line in doc/news/_preparation_next_release.md
    • reformat the code with scripts/dev/reformat-all
    • make all unit tests pass
    • fix all memleaks
  • The PR is rebased with current master.

Checklist

  • I added unit tests for my code
  • I fully described what my PR does in the documentation
    (not in the PR description)
  • I fixed all affected documentation (see Documentation Guidelines)
  • I added code comments, logging, and assertions as appropriate (see Coding Guidelines)
  • I updated all meta data (e.g. README.md of plugins and METADATA.ini)
  • I mentioned every code not directly written by me in reuse syntax

Review

Labels

  • Add the "work in progress" label if you do not want the PR to be reviewed yet.
  • Add the "ready to merge" label if the basics are fulfilled and no further pushes are planned by you.

@atmaxinger
Copy link
Contributor Author

Currently, keys will still be marked as conflicting, even if the merge strategy (OURS, THEIRS) was able to automatically resolve the conflict. This is to be in line with the current implementation of elektraMergeGetConflicts.

@atmaxinger atmaxinger requested a review from markus2330 October 6, 2022 19:05
Copy link
Contributor

@markus2330 markus2330 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see this feature! 🚀

Please add more introduction material: examples how to use the (new) API, basic introduction of how to use the library etc. Please also improve the Doxygen docu, add examples etc. (Examples as full files, which get compiled and included via @snippet.

src/libs/merge/kdbmerge.c Outdated Show resolved Hide resolved
src/libs/merge/kdbmerge.c Show resolved Hide resolved
@@ -181,6 +189,147 @@ static int getTotalNonOverlaps (Key * informationKey)
getNonOverlapOnlyBaseConflicts (informationKey);
}

static void addConflictingKeys (Key * informationKey, KeySet * conflictingKeys, const char * metaName)
{
increaseStatisticalValue (informationKey, metaName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these statistics? Can you please document what they are for (if they are needed)? Please create src/libs/merge/README.md with a basic introduction of what this library can do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is how the implementation of the merge algorithm work.


- <<TODO>>
- Add methods to check which keys were causing a merge conflict _(Maximilian Irlinger @atmaxinger)_.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this method called? Please add links.

KeySet * meta = keyMeta (informationKey);

Key * conflictsRoot = keyNew (META_ELEKTRA_MERGE_CONFLICT, KEY_END);
for (elektraCursor end, it = ksFindHierarchy (meta, conflictsRoot, &end); it < end; ++it)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you are the first using ksFindHierarchy (and seemingly it fits perfectly for you here), can you please improve the docu of ksFindHierarchy? (At the moment it is not public. @kodebach is a strong supporter of getting it public.). Alternatively, please remove your uses of ksFindHierarchy and mark ksFindHierarchy as internal in Doxygen, as it actually should have been.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't know it was considered internal API. I think it's very handy so I'd be open to document it. Why would you keep it internal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly because it is poorly documented and tested, so if this fixed the function has very good potential to get public.

The only other problem might be overlap with other functions (is the API still minimal after adding it?). I didn't check this enough, though. @lawli3t did you look at ksFindHierarchy?

But even if it doesn't end up in elektra-core, we can still have it another lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I've read again through the doxygen documentation for ksFindHierarchy and I find it quite understandable. What do you think is missing @markus2330 ?

Testing-wise, there are quite a few automated unit tests for this function too. I'm not sure what you mean by it is poorly tested.

I support @kodebach in that it should be made public. It contains quite a few optimizations that would be hard to reimplement outside of the core code of Elektra, especially now with copy-on-write.

@@ -1,4 +1,3 @@

#include "kdbmerge.h"
#include "kdb.h"
#include "kdbassert.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document what you use from #include "kdbprivate.h"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, because of ksFindHierarchy

src/libs/merge/kdbmerge.c Show resolved Hide resolved
src/libs/merge/kdbmerge.c Outdated Show resolved Hide resolved
src/libs/merge/kdbmerge.c Outdated Show resolved Hide resolved
@@ -220,6 +369,35 @@ static char * strremove (char * string, const char * sub)
return string;
}

static Key * prependStringToKeyName (Key * key, const char * string, Key * informationKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have at least short docu also for internal stuff (e.g. why is /root special, preconditions, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but it will take some time. I didn't really write this function, just extracted it when I refactored another method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is difficult to get used to other code. You are doing a great job here.

@markus2330
Copy link
Contributor

@atmaxinger Can you rescue some stuff from #3260?

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

1 similar comment
@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

@markus2330 could you please re-review this? I think I have addressed all of your points. Merging this PR would be a big deal for #3131

@markus2330 markus2330 merged commit 3e43445 into ElektraInitiative:master Feb 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3-way merge: elektraGetConflicts should return conflicting keys
3 participants