-
Notifications
You must be signed in to change notification settings - Fork 123
cmerge: add methods to get all conflicting keys #4515
cmerge: add methods to get all conflicting keys #4515
Conversation
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 |
There was a problem hiding this 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
.
@@ -181,6 +189,147 @@ static int getTotalNonOverlaps (Key * informationKey) | |||
getNonOverlapOnlyBaseConflicts (informationKey); | |||
} | |||
|
|||
static void addConflictingKeys (Key * informationKey, KeySet * conflictingKeys, const char * metaName) | |||
{ | |||
increaseStatisticalValue (informationKey, metaName); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)_. |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
Outdated
@@ -220,6 +369,35 @@ static char * strremove (char * string, const char * sub) | |||
return string; | |||
} | |||
|
|||
static Key * prependStringToKeyName (Key * key, const char * string, Key * informationKey) |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@atmaxinger Can you rescue some stuff from #3260? |
356c4c3
to
5a0760e
Compare
9ad8bce
to
2be5871
Compare
Co-authored-by: Markus Raab <markus2330@users.noreply.github.com>
Co-authored-by: Markus Raab <markus2330@users.noreply.github.com>
9d81ed3
to
adb8158
Compare
jenkins build libelektra please |
1 similar comment
jenkins build libelektra please |
jenkins build libelektra please |
@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 |
Fixes #4489
Basics
(added as entry in
doc/news/_preparation_next_release.md
whichcontains
_(my name)_
)Please always add something to the release notes.
(first line should have
module: short statement
syntax)close #X
, are in the commit messages.doc/news/_preparation_next_release.md
scripts/dev/reformat-all
Checklist
(not in the PR description)
Review
Labels