Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge database tool #47

Merged
merged 20 commits into from
Nov 8, 2016
Merged

Merge database tool #47

merged 20 commits into from
Nov 8, 2016

Conversation

droidmonkey
Copy link
Member

@droidmonkey droidmonkey commented Oct 18, 2016

Description

This PR institutes a manner in which to merge an unopened database to the currently open and selected database. Fixes #22.

Motivation and Context

This is an oft-requested feature and has been coded and waiting in the KeePassX repository for several years.

How Has This Been Tested?

  • Travis CI

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ My code follows the code style of this project.
  • ✅ My change requires a change to the documentation.
  • ➖ I have updated the documentation accordingly.
  • ✅ I have read the CONTRIBUTING document.
  • ❌ I have added tests to cover my changes.
  • ✅ All new and existing tests passed.

:neckbeard:

monomon and others added 5 commits October 6, 2016 17:24
* Add a MergeMode for Groups, which determines what conflict resolution
will do
* Default to KeepNewer mode, to be in line with KeePass2
* MergeMode can be inherited
* Add tests

# Conflicts:
#	src/core/Group.cpp
@droidmonkey droidmonkey added this to the v2.1.0 milestone Oct 18, 2016
Copy link
Contributor

@TheZ3ro TheZ3ro left a comment

Choose a reason for hiding this comment

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

We must convert each Q_FOREACH to C++11 foreach.
And also check that all the UI fields have appropriate names and can be translated

Entry* Group::findEntry(const Uuid& uuid)
{
Q_ASSERT(!uuid.isNull());
Q_FOREACH (Entry* entry, m_entries) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to convert Q_FOREACH to C++11 foreach. (Q_FOREACH will be deprecated soon)

void Group::merge(const Group* other)
{
// merge entries
Q_FOREACH (Entry* entry, other->entries()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

}

// merge groups (recursively)
Q_FOREACH (Group* group, other->children()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same


Group* Group::findChildByName(const QString& name)
{
Q_FOREACH (Group* group, m_children) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

if (changedFiles.isEmpty())
return;

Q_FOREACH (DatabaseManagerStruct dbStruct, m_dbList) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

@@ -56,54 +56,80 @@
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of this widget is generic (label_2) should be something else with sense.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 19, 2016

I've proposed a fix for the bugs I've found.
IMO we can now merge.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 27, 2016

Any news about this?

@droidmonkey
Copy link
Member Author

droidmonkey commented Oct 27, 2016

I haven't actually compiled this and tried it out yet. I'll do that today and merge it in. Been really focused on the new search functionality 😉

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 27, 2016

Ok no problem 😉
Just asking because it was opened 9 days ago

@@ -271,7 +272,7 @@ void DatabaseTabWidget::checkReloadDatabases()
if (changedFiles.isEmpty())
return;

Q_FOREACH (DatabaseManagerStruct dbStruct, m_dbList) {
for (DatabaseManagerStruct dbStruct: asConst(m_dbList)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I get a crash here when I try to autoreload a database.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you test if with the Q_FOREACH works or crash as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

The Q_FOREACH does not crash.

@droidmonkey
Copy link
Member Author

droidmonkey commented Oct 27, 2016

I got a crash on autoreload, see comment above

Also, when it asks if I want to "discard my changes and load new database" if I hit NO it should taint the current database file (ie, add the asterisk) so that it prompts to save on close.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 27, 2016

@droidmonkey for me crash with the following message: 'src/keepassx test2.kdbx' terminated by signal SIGSEGV (Address boundary error)

Also you are right about the tainting.
A nice thing should be adding a button to merge database in the "discard my changes and load new database" dialog

* All gui tests are run on an unaltered starter database
* All gui tests are self contained
* Removed clearing of Search Widget text when hiding
* Searches are saved between databases
* Search is cleared when all databases are closed
* Implemented case sensitive and group searching
…ture/merge-db-#22

* Reframed gui test case for merging based on fixed tests
* Removed considerations for dbwidget search during merge with new search feature
@droidmonkey
Copy link
Member Author

droidmonkey commented Oct 30, 2016

I fixed all the issues noted, this is ready for a third set of eyes. I would still like to have tests written for the autoreload.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Oct 30, 2016

Do you have rebased the #67 in this PR? (I see commit related to Search)
If so we need to approve and merge that PR

@droidmonkey
Copy link
Member Author

Yah I merged the search changes in and there were several conflicts. We should approve search first then this one.

@droidmonkey
Copy link
Member Author

I intend to add the auto reload tests tonight and merge this in. Last call!

@droidmonkey
Copy link
Member Author

droidmonkey commented Nov 3, 2016

I am getting crashes all over the place with the autoreload feature. This needs a lot more work before it can be merged. It is a result of using the iterator to go over the db list... my fault

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Nov 3, 2016

Have you tried using for and removing the asConst from m_dbList ?

@droidmonkey
Copy link
Member Author

Based on my debugging of the autoreload, these crashes occurred prior to the C++ 11 transition. The whole autoreload process needs to be redone in a different manner because it leaves behind a mess in the inner workings of the app.

I'm going to excise the auto reload part of this PR and move that code to its own feature branch. There is likely going to need a bit of replumbing in the way databases are loaded and metadata (in the tab widget) moved into proper classes. A lot of information gets out of sync by maintaining it in two different places.

@TheZ3ro
Copy link
Contributor

TheZ3ro commented Nov 7, 2016

Nice to know. (Ironically)

@droidmonkey droidmonkey changed the title Merge database and Autoreload database Merge database tool Nov 8, 2016
@droidmonkey droidmonkey merged commit e25cd9b into develop Nov 8, 2016
@droidmonkey droidmonkey deleted the feature/merge-db-#22 branch November 8, 2016 03:37
@Germano0 Germano0 mentioned this pull request Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants