Commit graph

316 commits

Author SHA1 Message Date
brian m. carlson
4a337e9a1d
Update version number to v5~pre0.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-23 23:46:43 +00:00
brian m. carlson
82c74d4e08
Update version number to version 4.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-23 23:43:59 +00:00
brian m. carlson
b6f3f49bf7
Document the DatabaseVersion methods.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-22 19:52:51 +00:00
brian m. carlson
f85219647d
Add tests for the Singleton metaclass.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-22 02:27:21 +00:00
brian m. carlson
5cb2c2dadf
Use a cleaner method to store additional files.
The git transactions had acquired a lot of in-depth knowledge about the
files that consisted of a database in order to store these additional files
in git as well.  Make the transaction code learn about a generic list of
additional files to be added and move the database-specific knowledge to the
database code, where it belongs.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-18 01:04:12 +00:00
brian m. carlson
ca72bdc562
filemanip: clone options hash before modifying.
If we want to change the contents of the option hash, we shouldn't modify
other users' copies of it.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-18 01:03:13 +00:00
brian m. carlson
df462e6c42
Switch newfol to use "hash" type instead of "sha256".
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 18:41:29 +00:00
brian m. carlson
94a0b685d4
Implement support for autodetecting hashes.
The appropriate hash to use for validating the data is automatically
detected, and if no hash type is specified, use SHA-512 on 64-bit systems
and SHA-256 on 32-bit systems, as this provides the best performance.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 18:37:40 +00:00
brian m. carlson
082fd07c62
Generate testcases on the fly.
Use hashlib to generate the testcases instead of relying on hard-coded
values.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 18:15:00 +00:00
brian m. carlson
2a8c8d2d2a
Support SHA-384 and SHA-512.
Turn the SHA256Transaction store into a HashTransactionStore and support
SHA-384 and SHA-512, which provide better performance on 64-bit systems.
Don't support SHA-224 since it is weaker and is only useful where the hash
would be truncated anyway.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 00:58:54 +00:00
brian m. carlson
810d33be99
Refactor transaction types into a list.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 00:44:44 +00:00
brian m. carlson
e7508bb172
Refactor backend selection.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-11 00:42:55 +00:00
brian m. carlson
17b3afb3cf
Avoid using print().
The print() notation makes syntax checkers go crazy for some reason (notably
when Syntastic tries to validate Python 3 code with /usr/bin/python), so
switch to a syntax that is slightly more Python 2-friendly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-10 00:24:50 +00:00
brian m. carlson
e514e62747
Add a RawFile object.
This provides support for storing raw data under the transactions
infrastructure.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-10 00:24:00 +00:00
brian m. carlson
b3b76c7a57
Add helpful comments to unit test.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-09 02:08:04 +00:00
brian m. carlson
09d0d11751
Add more SHA-256 tests.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-09 01:57:46 +00:00
brian m. carlson
450bf7ff6a
Properly report open mode to transaction stores.
The mode was always being reported as "w" (write), which resulted in SHA-256
checksums not being validated on load.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-08 03:34:54 +00:00
brian m. carlson
3d39ca84e6
Silence ResourceWarning in tests.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-08 03:28:01 +00:00
brian m. carlson
41fef74e9d
Add more tests for SHA256TransactionStore.
One of the tests is a known failure because of a bug, so mark it accordingly.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-08 03:27:20 +00:00
brian m. carlson
e509dacc9a
Add a basic test for the SHA-256 Transaction store.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-05 19:29:21 +00:00
brian m. carlson
9eafc61bda
newfol: make view in editor button work.
The keystroke for loading the search results in the editor worked, but the
button did not.  Fix this.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-04 00:03:46 +00:00
brian m. carlson
544fc064e9
filemanip: use reasonable committer ID for git.
We should not rely on the user setting up reasonable values for the committer
identification for git.  Use a committer name of newfol and an email address
consisting of the user's username and the FQDN of the machine.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-01 20:30:03 +00:00
brian m. carlson
a83ae0f348
database: add some tests for git transactions.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2014-01-01 20:02:21 +00:00
brian m. carlson
0d14ec597b
filemanip: add tests for YAML.
Since currently we can only serialize YAML, not load it, verify that it
serializes correctly twice.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 23:41:28 +00:00
brian m. carlson
cb17765453
Check that serialized data is stable.
Extend the filemanip tests to ensure that the data is serialized the same way
every time.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 23:38:25 +00:00
brian m. carlson
401266cd16
Remove unused functions.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 22:40:29 +00:00
brian m. carlson
32850781f0
newfol: Make next* keys work properly for browse-all.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 22:36:04 +00:00
brian m. carlson
08a7864b67
filemanip: call fsync before closing.
We really do want to make sure that the data is on disk before we close the
file, or at least try really hard.  Errors from the fsync are ignored because we
can write to a file object that doesn't support fsync, like sys.stdout, or we
could have a pseudo-file object that doesn't support the fileno method.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 21:55:43 +00:00
brian m. carlson
6b5ffa9e36
Remove trailing whitespace.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-12-31 21:50:14 +00:00
brian m. carlson
c203e09709
Use bool(x) instead of not not.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 23:15:38 +00:00
brian m. carlson
44c29ddfdd
Refactor transaction handling code.
Instead of duplicating the calling of the transaction methods in every
FileFormat, simply move those calls into the _open and _close methods in
FileFormat itself.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 23:12:19 +00:00
brian m. carlson
e560f273b0
Fix JSON round-tripping.
This also includes a unit test to ensure that round-tripping works properly for
those serializations where it's supported.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 23:08:13 +00:00
brian m. carlson
9f030febbf
Support YAML as an output format.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 21:42:17 +00:00
brian m. carlson
d21b309ca8
Add JSON as a file format for import and export.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 21:37:14 +00:00
brian m. carlson
8b476baf75
Fix import functionality.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 21:36:29 +00:00
brian m. carlson
b1f888cb45
Remove debugging info.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 21:36:13 +00:00
brian m. carlson
0d5a4798f2
Allow exporting to arbitrary formats.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 21:35:38 +00:00
brian m. carlson
5e59ca5a73
Use os.devnull instead of hard-coding path.
Not that newfol is likely to work especially well on non-Unix systems, but
using os.devnull adds a little bit of portability.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 20:11:42 +00:00
brian m. carlson
3566675bdb
Refactor file opening and closing.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 20:09:17 +00:00
brian m. carlson
8cbeb4a311
Fix ResourceWarning from tests.
This inverted test, besides being wrong (and potentially closing something
important like sys.stdout), caused a ResourceWarning in testgit.py.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 20:00:56 +00:00
brian m. carlson
9b2346fcae
Add a Makefile to run tests more easily.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 16:50:06 +00:00
brian m. carlson
0263792fde
Update database test for new record version.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 02:17:59 +00:00
brian m. carlson
629aba310b
Add a test to ensure git transactions work.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 02:16:19 +00:00
brian m. carlson
55b79864d8
Fix creation of new databases.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-16 00:15:58 +00:00
brian m. carlson
94625e2e6b
Ignore emacs backup files.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-15 00:55:24 +00:00
brian m. carlson
ff7d9a2223
Pass through the transaction types when saving.
The code had failed to pass through the transaction types, resulting in Git
transactions not working.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-11-15 00:52:00 +00:00
brian m. carlson
abf1e29faf
Make autofill work again.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-10-21 22:57:56 +00:00
brian m. carlson
862ac88720
Update database.py to use "table" instead of "dbname".
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-10-13 23:31:50 +00:00
brian m. carlson
fb3bcc285b
Fix repair code and improve error reporting.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-10-13 03:18:51 +00:00
brian m. carlson
251ec7215c
Disable strict validation by default.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
2013-10-13 03:16:54 +00:00