Re: [PATCH v2 2/3] database: add n_d_index_file (deprecates n_d_add_message)

2017-09-18 Thread David Bremner
Daniel Kahn Gillmor  writes:

> On Wed 2017-08-23 08:01:22 -0300, David Bremner wrote:
>> Pushed 2 and 3, but with both amended to fix whitespace errors. Please
>> _do_ adjust your settings, this is not a test ;).
>
> thanks for this push, bremner.
>
> if there are settings that need to be adjusted, i believe .dir-locals.el
> is the place to adjust them for those of us who use emacs as their text
> editor, right?  i'm happy to pick them up from there.
>
> any suggestions on what specific settings need adjustment?
>
>  --dkg

I'm not sure about an emacs-specific fix; I just rename
.git/hooks/pre-commit.sample to .git/hooks/pre-commit to enable checking
for whitespace issues before committing.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 2/3] database: add n_d_index_file (deprecates n_d_add_message)

2017-09-17 Thread Daniel Kahn Gillmor
On Wed 2017-08-23 08:01:22 -0300, David Bremner wrote:
> Pushed 2 and 3, but with both amended to fix whitespace errors. Please
> _do_ adjust your settings, this is not a test ;).

thanks for this push, bremner.

if there are settings that need to be adjusted, i believe .dir-locals.el
is the place to adjust them for those of us who use emacs as their text
editor, right?  i'm happy to pick them up from there.

any suggestions on what specific settings need adjustment?

 --dkg


signature.asc
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 2/3] database: add n_d_index_file (deprecates n_d_add_message)

2017-08-23 Thread David Bremner
Daniel Kahn Gillmor  writes:

> We need a way to pass parameters to the indexing functionality on the
> first index, not just on reindexing.  The obvious place is in
> notmuch_database_add_message.  But since modifying the argument list
> would break both API and ABI, we needed a new name.
>

Pushed 2 and 3, but with both amended to fix whitespace errors. Please
_do_ adjust your settings, this is not a test ;).

d

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 2/3] database: add n_d_index_file (deprecates n_d_add_message)

2017-08-17 Thread Daniel Kahn Gillmor
We need a way to pass parameters to the indexing functionality on the
first index, not just on reindexing.  The obvious place is in
notmuch_database_add_message.  But since modifying the argument list
would break both API and ABI, we needed a new name.

I considered notmuch_database_add_message_with_params(), but the
functionality we're talking about doesn't always add a message.  It
tries to index a specific file, possibly adding a message, but
possibly doing other things, like adding terms to an existing message,
or failing to deal with message objects entirely (e.g. because the
file didn't contain a message).

So i chose the function name notmuch_database_index_file.

I confess i'm a little concerned about confusing future notmuch
developers with the new name, since we already have a private
_notmuch_message_index_file function, and the two do rather different
things.  But i think the added clarity for people linking against the
future libnotmuch and the capacity for using index parameters makes
this a worthwhile tradeoff.  (that said, if anyone has another name
that they strongly prefer, i'd be happy to go with it)

This changeset also adjusts the tests so that we test whether the new,
preferred function returns bad values (since the deprecated function
just calls the new one).

We can keep the deprecated n_d_add_message function around as long as
we like, but at the next place where we're forced to break API or ABI
we can probably choose to drop the name relatively safely.

NOTE: there is probably more cleanup to do in the ruby and go bindings
to complete the deprecation directly.  I don't know those languages
well enough to attempt a fix; i don't know how to test them; and i
don't know the culture around those languages about API additions or
deprecations.
---
 bindings/python/docs/source/database.rst |  2 +-
 bindings/python/notmuch/database.py  | 18 --
 bindings/python/notmuch/directory.py |  2 +-
 bindings/python/notmuch/message.py   |  2 +-
 bindings/ruby/database.c |  2 +-
 contrib/go/src/notmuch/notmuch.go|  2 +-
 lib/add-message.cc   | 18 +++---
 lib/notmuch.h| 29 +
 notmuch-insert.c |  2 +-
 notmuch-new.c|  2 +-
 test/T070-insert.sh  | 10 +-
 test/T560-lib-error.sh   |  4 ++--
 12 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/bindings/python/docs/source/database.rst 
b/bindings/python/docs/source/database.rst
index 5f1cdc14..079dc754 100644
--- a/bindings/python/docs/source/database.rst
+++ b/bindings/python/docs/source/database.rst
@@ -25,7 +25,7 @@
 
.. automethod:: get_directory
 
-   .. automethod:: add_message
+   .. automethod:: index_file
 
.. automethod:: remove_message
 
diff --git a/bindings/python/notmuch/database.py 
b/bindings/python/notmuch/database.py
index 8f918069..a2c025eb 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -285,7 +285,7 @@ class Database(object):
 """Does this database need to be upgraded before writing to it?
 
 If this function returns `True` then no functions that modify the
-database (:meth:`add_message`,
+database (:meth:`index_file`,
 :meth:`Message.add_tag`, :meth:`Directory.set_mtime`,
 etc.) will work unless :meth:`upgrade` is called successfully first.
 
@@ -399,12 +399,13 @@ class Database(object):
 # return the Directory, init it with the absolute path
 return Directory(abs_dirpath, dir_p, self)
 
-_add_message = nmlib.notmuch_database_add_message
-_add_message.argtypes = [NotmuchDatabaseP, c_char_p,
+_index_file = nmlib.notmuch_database_index_file
+_index_file.argtypes = [NotmuchDatabaseP, c_char_p,
+ c_void_p,
  POINTER(NotmuchMessageP)]
-_add_message.restype = c_uint
+_index_file.restype = c_uint
 
-def add_message(self, filename, sync_maildir_flags=False):
+def index_file(self, filename, sync_maildir_flags=False):
 """Adds a new message to the database
 
 :param filename: should be a path relative to the path of the
@@ -455,7 +456,7 @@ class Database(object):
 """
 self._assert_db_is_initialized()
 msg_p = NotmuchMessageP()
-status = self._add_message(self._db, _str(filename), byref(msg_p))
+status = self._index_file(self._db, _str(filename), c_void_p(None), 
byref(msg_p))
 
 if not status in [STATUS.SUCCESS, STATUS.DUPLICATE_MESSAGE_ID]:
 raise NotmuchError(status)
@@ -467,6 +468,11 @@ class Database(object):
 msg.maildir_flags_to_tags()
 return (msg, status)
 
+def add_message(self, filename, sync_maildir_flags=False):
+"""Deprecated alias for :meth:`index_file`
+"""
+sel