unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH v2 00/14] Implement and use database "features"
@ 2014-07-29 16:47 Austin Clements
  2014-07-29 16:47 ` [PATCH v2 01/14] test: Include generated dependencies for test sources Austin Clements
                   ` (13 more replies)
  0 siblings, 14 replies; 16+ messages in thread
From: Austin Clements @ 2014-07-29 16:47 UTC (permalink / raw)
  To: notmuch

This is version 2 of
id:1406433173-19169-1-git-send-email-amdragon@mit.edu.  It fixes a bug
pointed out by Mark [1] where the upgrade test would fail if the
prerequisites were not available (rather than cleanly skipping the
test like before).  It also makes feature names more user-friendly and
eliminates notmuch->needs_upgrade in favor of computing it on-the-fly
in notmuch_database_needs_upgrade.  The diff from v1 is below.

[1] id:871tt718xp.fsf@qmul.ac.uk

diff --git a/lib/database-private.h b/lib/database-private.h
index 323b9fe..2ffab33 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -41,7 +41,6 @@ struct _notmuch_database {
 
     char *path;
 
-    notmuch_bool_t needs_upgrade;
     notmuch_database_mode_t mode;
     int atomic_nesting;
     Xapian::Database *xapian_db;
diff --git a/lib/database.cc b/lib/database.cc
index f105e27..b323691 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -238,7 +238,6 @@ static prefix_t PROBABILISTIC_PREFIX[]= {
     { "subject",		"XSUBJECT"},
 };
 
-
 const char *
 _find_prefix (const char *name)
 {
@@ -275,12 +274,12 @@ static const struct
     /* Compatibility flags when this feature is declared. */
     const char *flags;
 } feature_names[] = {
-    {NOTMUCH_FEATURE_FILE_TERMS,             "file terms", "rw"},
-    {NOTMUCH_FEATURE_DIRECTORY_DOCS,         "directory documents", "rw"},
+    {NOTMUCH_FEATURE_FILE_TERMS,             "multiple paths per message", "rw"},
+    {NOTMUCH_FEATURE_DIRECTORY_DOCS,         "relative directory paths", "rw"},
     /* Header values are not required for reading a database because a
      * reader can just refer to the message file. */
-    {NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES, "from/subject/ID values", "w"},
-    {NOTMUCH_FEATURE_BOOL_FOLDER,            "boolean folder terms", "rw"},
+    {NOTMUCH_FEATURE_FROM_SUBJECT_ID_VALUES, "from/subject/message-ID in database", "w"},
+    {NOTMUCH_FEATURE_BOOL_FOLDER,            "exact folder:/path: search", "rw"},
 };
 
 const char *
@@ -790,7 +789,6 @@ notmuch_database_open (const char *path,
     if (notmuch->path[strlen (notmuch->path) - 1] == '/')
 	notmuch->path[strlen (notmuch->path) - 1] = '\0';
 
-    notmuch->needs_upgrade = FALSE;
     notmuch->mode = mode;
     notmuch->atomic_nesting = 0;
     try {
@@ -839,11 +837,6 @@ notmuch_database_open (const char *path,
 	    goto DONE;
 	}
 
-	/* Do we want an upgrade? */
-	if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&
-	    NOTMUCH_FEATURES_CURRENT & ~notmuch->features)
-	    notmuch->needs_upgrade = TRUE;
-
 	notmuch->last_doc_id = notmuch->xapian_db->get_lastdocid ();
 	last_thread_id = notmuch->xapian_db->get_metadata ("last_thread_id");
 	if (last_thread_id.empty ()) {
@@ -1173,7 +1166,8 @@ notmuch_database_get_version (notmuch_database_t *notmuch)
 notmuch_bool_t
 notmuch_database_needs_upgrade (notmuch_database_t *notmuch)
 {
-    return notmuch->needs_upgrade;
+    return notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&
+	(NOTMUCH_FEATURES_CURRENT & ~notmuch->features);
 }
 
 static volatile sig_atomic_t do_progress_notify = 0;
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index c88bbc7..c4c4ac8 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -3,52 +3,6 @@ test_description="database upgrade"
 
 . ./test-lib.sh
 
-test_begin_subtest "future database versions abort open"
-${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 9999 ""
-output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
-rm -rf ${MAIL_DIR}/.notmuch
-test_expect_equal "$output" "\
-Error: Notmuch database at FILENAME
-       has a newer database format version (9999) than supported by this
-       version of notmuch (3)."
-
-test_begin_subtest "unknown 'rw' feature aborts read/write open"
-${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\trw'
-output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
-rm -rf ${MAIL_DIR}/.notmuch
-test_expect_equal "$output" "\
-Error: Notmuch database at FILENAME
-       requires features (test feature)
-       not supported by this version of notmuch."
-
-test_begin_subtest "unknown 'rw' feature aborts read-only open"
-${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\trw'
-output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
-rm -rf ${MAIL_DIR}/.notmuch
-test_expect_equal "$output" "\
-Error: Notmuch database at FILENAME
-       requires features (test feature)
-       not supported by this version of notmuch."
-
-test_begin_subtest "unknown 'w' feature aborts read/write open"
-${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\tw'
-output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
-rm -rf ${MAIL_DIR}/.notmuch
-test_expect_equal "$output" "\
-Error: Notmuch database at FILENAME
-       requires features (test feature)
-       not supported by this version of notmuch."
-
-test_begin_subtest "unknown 'w' feature does not abort read-only open"
-${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\tw'
-output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
-rm -rf ${MAIL_DIR}/.notmuch
-test_expect_equal "$output" ""
-
-#
-# Database v1
-#
-
 dbtarball=database-v1.tar.xz
 
 # XXX: Accomplish the same with test lib helpers
diff --git a/test/T550-db-features.sh b/test/T550-db-features.sh
new file mode 100755
index 0000000..5569768
--- /dev/null
+++ b/test/T550-db-features.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+test_description="database version and feature compatibility"
+
+. ./test-lib.sh
+
+test_begin_subtest "future database versions abort open"
+${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 9999 ""
+output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+rm -rf ${MAIL_DIR}/.notmuch
+test_expect_equal "$output" "\
+Error: Notmuch database at FILENAME
+       has a newer database format version (9999) than supported by this
+       version of notmuch (3)."
+
+test_begin_subtest "unknown 'rw' feature aborts read/write open"
+${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\trw'
+output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+rm -rf ${MAIL_DIR}/.notmuch
+test_expect_equal "$output" "\
+Error: Notmuch database at FILENAME
+       requires features (test feature)
+       not supported by this version of notmuch."
+
+test_begin_subtest "unknown 'rw' feature aborts read-only open"
+${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\trw'
+output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+rm -rf ${MAIL_DIR}/.notmuch
+test_expect_equal "$output" "\
+Error: Notmuch database at FILENAME
+       requires features (test feature)
+       not supported by this version of notmuch."
+
+test_begin_subtest "unknown 'w' feature aborts read/write open"
+${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\tw'
+output=$(notmuch new 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+rm -rf ${MAIL_DIR}/.notmuch
+test_expect_equal "$output" "\
+Error: Notmuch database at FILENAME
+       requires features (test feature)
+       not supported by this version of notmuch."
+
+test_begin_subtest "unknown 'w' feature does not abort read-only open"
+${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 3 $'test feature\tw'
+output=$(notmuch search x 2>&1 | sed 's/\(database at\) .*/\1 FILENAME/')
+rm -rf ${MAIL_DIR}/.notmuch
+test_expect_equal "$output" ""
+
+test_done

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-07-31 10:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-29 16:47 [PATCH v2 00/14] Implement and use database "features" Austin Clements
2014-07-29 16:47 ` [PATCH v2 01/14] test: Include generated dependencies for test sources Austin Clements
2014-07-29 16:48 ` [PATCH v2 02/14] util: Make string-util.h C++-compatible Austin Clements
2014-07-31 10:17   ` David Bremner
2014-07-29 16:48 ` [PATCH v2 03/14] util: Const version of strtok_len Austin Clements
2014-07-29 16:48 ` [PATCH v2 04/14] new: Don't report version after upgrade Austin Clements
2014-07-29 16:48 ` [PATCH v2 05/14] lib: Database version 3: Introduce fine-grained "features" Austin Clements
2014-07-29 16:48 ` [PATCH v2 06/14] test: Tool to build DB with specific version and features Austin Clements
2014-07-29 16:48 ` [PATCH v2 07/14] test: Tests for future version and unknown feature handling Austin Clements
2014-07-29 16:48 ` [PATCH v2 08/14] lib: Simplify upgrade code using a transaction Austin Clements
2014-07-29 16:48 ` [PATCH v2 09/14] lib: Use database features to drive upgrade Austin Clements
2014-07-29 16:48 ` [PATCH v2 10/14] lib: Reorganize upgrade around document types Austin Clements
2014-07-29 16:48 ` [PATCH v2 11/14] lib: Report progress for combined upgrade operation Austin Clements
2014-07-29 16:48 ` [PATCH v2 12/14] lib: Support empty header values in database Austin Clements
2014-07-29 16:48 ` [PATCH v2 13/14] lib: Return an error from operations that require an upgrade Austin Clements
2014-07-29 16:48 ` [PATCH v2 14/14] lib: Update doc of notmuch_database_{needs_upgrade, upgrade} Austin Clements

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).