Commit Graph

42 Commits

Author SHA1 Message Date
Florian Bruhin
b7de287e7b Move CommandError to api.cmdutils 2018-11-29 14:18:11 +01:00
Florian Bruhin
4ca8fc0cb7 Use a shared web_history fixture 2018-09-06 20:08:32 +02:00
Florian Bruhin
ab6c8dde9a Decrease minimum QProgressDialog duration
We already have a threshold before we use a QProgressDialog at all, so let's
show it quite quickly and not after 4 seconds.
2018-09-06 17:26:28 +02:00
Florian Bruhin
935d93d10e Add tests for HistoryProgress 2018-09-06 17:26:28 +02:00
Florian Bruhin
d4f16f88b6 Remove support for importing pre-v1.0.0 history 2018-09-06 17:26:28 +02:00
Florian Bruhin
ec774379bd Add tests for history progress 2018-09-06 17:13:46 +02:00
Florian Bruhin
e4b7786bcc Factor out GUI stuff to a HistoryProgress object 2018-09-06 17:04:26 +02:00
Florian Bruhin
b0185e3c8a Use config_stub.val instead of config_stub.set_obj in tests 2018-09-02 14:42:47 +02:00
Florian Bruhin
dbdeb6a9c7 Rename history.exclude to completion.web_history.exclude
If the blacklist is only valid for the completion, the setting should also be
under completion.

This also un-renames history.gap_interval and renames
completion.web_history_max_items.
2018-09-02 14:42:47 +02:00
Florian Bruhin
50ae2bf2f9 Redesign SQL error handling
Instead of having an environmental attribute on exceptions, we now have two
different exception classes.

Fixes #3341
See #3073
2018-09-01 22:25:22 +02:00
Florian Bruhin
71a2dad570 Add a history.exclude setting
This allows to exclude URL patterns from being displayed in the completion or
in qute://history.
2018-09-01 22:25:22 +02:00
Florian Bruhin
806d65be8e Add test for no-sql-history flag 2018-09-01 18:25:58 +02:00
Florian Bruhin
c2f8b6531d Reorganize test_history 2018-09-01 18:25:58 +02:00
Florian Bruhin
9fb794656b Make it possible to force a history rebuild
This adds a new CompletionMetaInfo table which is a simple key/value store.

Thanks to Python/sqlite duck typing, we can use that to store values of any
type, even new ones in the future.

Currently, the only allowed key is force_rebuild, which forces a rebuild of the
CompletionHistory table. This will be needed for a future change.
2018-09-01 18:25:58 +02:00
Florian Bruhin
6f028e9ad0 Update copyright years 2018-02-05 12:19:50 +01:00
Florian Bruhin
e65c0dd8a7 pylint: Re-enable bad-continuation
And lots and lots of whitespace changes.
2017-12-15 19:16:55 +01:00
Florian Bruhin
d6d13770a3 Add missing history tests 2017-10-09 16:17:55 +02:00
Ryan Roden-Corrent
888a1b8c57 Append multiple history backups on import.
Previously, a successful import of the text history into sqlite would
move 'history' to 'history.bak'. If history.bak already existed, this
would overwrite it on unix and fail on windows.

With this patch, the most recently imported history is appended to
history.bak to avoid data loss.

Resolves #3005.

A few other options I considered:

1. os.replace:
    - fast, simple, no error on Windows
    - potential data loss
2. numbered backups (.bak.1, .bak.2, ...):
    - fast, no data loss, but more complex
3. append each line to the backup as it is read:
    - more efficient than current patch (no need to read history twice)
    - potentially duplicate data if backup fails
2017-09-23 13:06:11 -04:00
Ryan Roden-Corrent
5cd00f699e Resolve KeyError when deleting URL with space.
Resolves #2963.
2017-09-20 07:15:59 -04:00
Florian Bruhin
62b30af12a Fix unit tests for end2end SQL change 2017-09-17 11:49:42 +02:00
Ryan Roden-Corrent
b89caf0458 Use REPLACE when rebuilding completion table.
When upgrading from an old table that used different url formatting, two
entries might map to the same key, so we'll need to replace the previous
entry to avoid a primary key conflict.
2017-08-23 21:26:27 -04:00
Ryan Roden-Corrent
d35b47c9d8 Regenerate history completion on version change.
Incrementing _USER_VERSION in the source will cause the
HistoryCompletion table to regenerate when users update.

This is currently necessary to support some recent formatting fixes, but
could be incremented again in the future for other changes.
2017-08-21 08:45:40 -04:00
Ryan Roden-Corrent
5f45b9b40e Fix pylint and coverage for history. 2017-08-20 20:59:48 -04:00
Ryan Roden-Corrent
8c6133e29d Regenerate history completion table if needed.
If the HistoryCompletion table is removed, regenerate it from the
History table. This allows users to manually edit History, then remove
HistoryCompletion to prompt regeneration.

See #2903.
2017-08-18 07:39:36 -04:00
Ryan Roden-Corrent
c607537319 Consistently format urls in history.
Encode urls that are inserted into the history, but do not encode urls
for completion (other than removing passwords).
Also ensure that urls read from the history text file are formatted
consistenly with those added while browsing.

Fixes #2903.
2017-08-14 21:37:43 -04:00
Florian Bruhin
49b858e359 Add more variants of fake apple URL to ignored ones 2017-08-01 16:00:53 +02:00
Ryan Roden-Corrent
1aed2470e5 SQL code review.
- Fix flake8
- history.clear should also clear completion table
- call _resize_columns in set_model, not set_pattern
- add more unit-testing for the history completion table
2017-07-12 22:14:27 -04:00
Ryan Roden-Corrent
ea459a1eca SQL code review fixes.
- Ignore invalid variable name in flake8 (pylint already checks this and
  we don't want to have to double-ignore)
- Fix and test completion bug with `:set asdf `
- Remove unused import
- Use `assert not func.called` instead of `func.assert_not_called` for
  backwards compatibility
2017-07-12 08:19:31 -04:00
Ryan Roden-Corrent
cf4ac1a5b7 SQL code review changes.
- use mocker.Mock instead of mock.Mock to avoid an extra import
- attach model to validator sooner so it can validate changes in the
  model during the test
2017-07-08 16:34:38 -04:00
Ryan Roden-Corrent
f9f8900fe9 More sql code review fixes.
- remove outdated comment
- fix sql init error message
- clean up history text import code
- fix test_history file path in coverage check
- use real web history, not stub, for completion model tests
- use qtmodeltester in sql/list_category tests
- test url encoding in history tests
- fix test_clear by using a callable mock
- remove test_debug_dump_history_oserror as the check is now the same as
  for the file not existing
- rename nonempty to data in test_completionmodel
- add more delete_cur_item tests
- test empty option/value completion
2017-07-08 09:57:32 -04:00
Ryan Roden-Corrent
1e1335aa5e Make various SQL code review changes.
- Fix outdated comments
- Use mock specs when possible
- More precise error message check in test_import_txt_invalid.
- Fix copyright message
- Tweak missing pyqt error message
- Dead code: remove group_by and where from sqlcategory.
  With the new separate completion table, these are no longer used.
- Move test_history out of webkit/. History is no longer purely webkit
  related, it could be webengine.
2017-07-03 09:45:08 -04:00
Florian Bruhin
4fccc89d7d Split browser into browser/browser.webkit 2016-06-13 11:18:21 +02:00
Florian Bruhin
66938ed44b Full redirect support for history
When a redirect occurs, the item is saved in history with a -r suffix
now. When opening qutebrowser that's picked up and the item is hidden
from completion.
2016-06-10 14:40:42 +02:00
Florian Bruhin
0a25bb508a Fix lint 2016-06-10 12:21:48 +02:00
Florian Bruhin
9298fa697b Allow to pass atime to WebHistory.add_url
This makes a lot of tests easier and/or more exact.
2016-06-10 12:12:29 +02:00
Florian Bruhin
7511bc1fe5 tests: 100% coverage for browser.history 2016-06-10 12:01:14 +02:00
Florian Bruhin
14a04f1535 Fix lint 2016-06-09 22:03:35 +02:00
Florian Bruhin
185b4bc18b Add more tests for browser.history 2016-06-09 21:14:04 +02:00
Florian Bruhin
d3dd6d2f77 Add hypothesis test for history.Entry.from_str 2016-06-09 21:14:04 +02:00
Florian Bruhin
33f01d8375 Fix lint 2016-06-09 21:14:03 +02:00
Florian Bruhin
9510af9912 Use QUrl with QWebHistory
Now that we have our own history implementation, we get the URLs as QUrl
and not as string - so no point in converting them to string and back.
2016-06-09 21:14:03 +02:00
Florian Bruhin
5f25ce69ec Add some tests for browser.history 2016-06-09 21:14:03 +02:00