* [PATCH] bindings/python: add bindings for notmuch_database_get_revision
@ 2017-03-06 16:37 Gaute Hope
2017-03-09 12:32 ` David Bremner
2017-03-09 13:32 ` [PATCH] bindings/python: test python Database.get_revision () Gaute Hope
0 siblings, 2 replies; 4+ messages in thread
From: Gaute Hope @ 2017-03-06 16:37 UTC (permalink / raw)
To: notmuch
Database.get_revision () returns a tuple with the current database
revision and the UUID string representing the database.
---
bindings/python/notmuch/database.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/bindings/python/notmuch/database.py b/bindings/python/notmuch/database.py
index 67fb1c41..8f918069 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -86,6 +86,11 @@ class Database(object):
_get_version.argtypes = [NotmuchDatabaseP]
_get_version.restype = c_uint
+ """notmuch_database_get_revision"""
+ _get_revision = nmlib.notmuch_database_get_revision
+ _get_revision.argtypes = [NotmuchDatabaseP, POINTER(c_char_p)]
+ _get_revision.restype = c_uint
+
"""notmuch_database_open"""
_open = nmlib.notmuch_database_open
_open.argtypes = [c_char_p, c_uint, POINTER(NotmuchDatabaseP)]
@@ -261,6 +266,17 @@ class Database(object):
self._assert_db_is_initialized()
return Database._get_version(self._db)
+ def get_revision (self):
+ """Returns the committed database revison and UUID
+
+ :returns: (revison, uuid) The database revision as a positive integer
+ and the UUID of the database.
+ """
+ self._assert_db_is_initialized()
+ uuid = c_char_p ()
+ revision = Database._get_revision(self._db, byref (uuid))
+ return (revision, uuid.value.decode ('utf-8'))
+
_needs_upgrade = nmlib.notmuch_database_needs_upgrade
_needs_upgrade.argtypes = [NotmuchDatabaseP]
_needs_upgrade.restype = bool
--
2.11.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bindings/python: add bindings for notmuch_database_get_revision
2017-03-06 16:37 [PATCH] bindings/python: add bindings for notmuch_database_get_revision Gaute Hope
@ 2017-03-09 12:32 ` David Bremner
2017-03-09 13:32 ` [PATCH] bindings/python: test python Database.get_revision () Gaute Hope
1 sibling, 0 replies; 4+ messages in thread
From: David Bremner @ 2017-03-09 12:32 UTC (permalink / raw)
To: Gaute Hope, notmuch
Gaute Hope <eg@gaute.vetsj.com> writes:
> Database.get_revision () returns a tuple with the current database
> revision and the UUID string representing the database.
It would be great if you could add a test for the new API to
T390-python.sh. Probably just translating the C example from
T570-revision-tracking.sh into python would work.
d
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] bindings/python: test python Database.get_revision ()
2017-03-06 16:37 [PATCH] bindings/python: add bindings for notmuch_database_get_revision Gaute Hope
2017-03-09 12:32 ` David Bremner
@ 2017-03-09 13:32 ` Gaute Hope
2017-03-10 11:43 ` David Bremner
1 sibling, 1 reply; 4+ messages in thread
From: Gaute Hope @ 2017-03-09 13:32 UTC (permalink / raw)
To: notmuch
Here is a test for Database.get_revision (), based on
the first part of T570-revision-tracking.sh.
---
test/T390-python.sh | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/test/T390-python.sh b/test/T390-python.sh
index 4726bc36..b27f0740 100755
--- a/test/T390-python.sh
+++ b/test/T390-python.sh
@@ -38,4 +38,23 @@ print (db.find_message_by_filename("i-dont-exist"))
EOF
test_expect_equal "$(cat OUTPUT)" "None"
+test_begin_subtest "get revision"
+test_python ${MAIL_DIR} <<'EOF'
+import notmuch
+db = notmuch.Database(mode=notmuch.Database.MODE.READ_ONLY)
+(revision, uuid) = db.get_revision()
+print ("%s\t%lu" % (uuid, revision))
+EOF
+notmuch_uuid_sanitize < OUTPUT > CLEAN
+cat <<'EOF' >EXPECTED
+UUID 53
+EOF
+test_expect_equal_file EXPECTED CLEAN
+
+grep '^[0-9a-f]' OUTPUT > INITIAL_OUTPUT
+
+test_begin_subtest "output of count matches test code"
+notmuch count --lastmod '*' | cut -f2-3 > OUTPUT
+test_expect_equal_file INITIAL_OUTPUT OUTPUT
+
test_done
--
2.11.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] bindings/python: test python Database.get_revision ()
2017-03-09 13:32 ` [PATCH] bindings/python: test python Database.get_revision () Gaute Hope
@ 2017-03-10 11:43 ` David Bremner
0 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2017-03-10 11:43 UTC (permalink / raw)
To: Gaute Hope, notmuch
Gaute Hope <eg@gaute.vetsj.com> writes:
> Here is a test for Database.get_revision (), based on
> the first part of T570-revision-tracking.sh.
pushed this and the previous patch to master
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-10 11:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-06 16:37 [PATCH] bindings/python: add bindings for notmuch_database_get_revision Gaute Hope
2017-03-09 12:32 ` David Bremner
2017-03-09 13:32 ` [PATCH] bindings/python: test python Database.get_revision () Gaute Hope
2017-03-10 11:43 ` David Bremner
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).