| Submitter | David Bremner |
|---|---|
| Date | 2011-10-29 03:04:51 |
| Message ID | <1319857491-12298-5-git-send-email-david@tethera.net> |
| Download | mbox | patch |
| Permalink | /patch/1431/ |
| State | New |
| Headers | show |
Comments
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
OK, here is my rough and ready attempt at tag sharing. I figure we
can smooth out the rough edges if/when we agree on a set of tags and
preferably on an on-disk format.
How to play?
- - Apply all the patches in this thread (starting
id:"1319383133-11006-1-git-send-email-david@tethera.net")
- - to git master git clone git://pivot.cs.unb.ca/nmbug.git $HOME/.nmbug
- - put the script nmbug somewhere
# suck in the tags
$ nmbug restore
[ do some tagging ]
$ nmbug dump
$ cd $HOME/.nmbug && git add tags && git commit
now you have to get the changes into the "master" repo. I think
hosting this on git.notmuchmail.org in a seperate repo will make
sense, but for now, if you want to participate in the experiment, send
me your public key (ideally in a gpg signed mail, but if not, oh well),
and you can push to my repo at
git@pivot.cs.unb.ca:pub/nmbug
Probably the most crucial thing is that we agree on some set of tags.
Here is the set of tags I am working with (output from
notmuch search --output=tags "*" | grep ^notmuch::
)
notmuch::bug is a bug report
notmuch::feature provides a new feature
notmuch::fix fixes a bug
notmuch::obsolete replaced by some other patch
notmuch::patch
notmuch::portability improves portability
notmuch::pushed is pushed to master
notmuch::review is a review
notmuch::reviewed has been (well reviewed)
notmuch::test provides a new test/or improves testing
The prefix "notmuch::" is hardcoded into the script, but everything
else is easy to change with the usual notmuch operations. Of course
we can change the prefix too. I decided on :: because it needed less
escaping.
On think I'm not sure about is how to handle ideas like "voting", and
"signing off" with tags. I suspect we can come up with some
conventions like "notmuch::review1", or
"notmuch::vote1".."notmuch::vote5". But maybe people have less kludgy
ideas.
Remember, perfect is the enemy of good ;)
David
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iJwEAQECAAYFAk6sLWQACgkQTiiN/0Um85k5JQP+PZ0ycrNTTZZ72PyXbDQzrv4+
dDKopxh+WpeORjWu8gvj+LNMM3A8n0t4/A12mxrG9cUJxg2HTPUtRo9Zi7dFQzct
uGvSOvQ6GocUretW0BaK/yp53v0R7b00qxvxAvUeoZPgIWGtqp52fXW8d0I2yAUn
079okQwPYdbowaPAX1A=
=+E8F
-----END PGP SIGNATURE-----
On Sat, 29 Oct 2011 13:45:06 -0300, David Bremner <david@tethera.net> wrote: > OK, here is my rough and ready attempt at tag sharing. I figure we > can smooth out the rough edges if/when we agree on a set of tags and > preferably on an on-disk format. Great! Thank you so much for working on this, David. This is very exciting work. Comments below. > How to play? > > - - Apply all the patches in this thread (starting > id:"1319383133-11006-1-git-send-email-david@tethera.net") These patches did not apply cleanly for me from the list. I was able to get them from bremner's "nmbug" branch [0], though. [0] git://pivot.cs.unb.ca/git/notmuch > $ nmbug dump > $ cd $HOME/.nmbug && git add tags && git commit This last command seems to be included in nmbug as "commit". Fwiw, I don't like having to do two separate operations for dump and commit. Could they be merged into a single operation? > now you have to get the changes into the "master" repo. I think > hosting this on git.notmuchmail.org in a seperate repo will make > sense, but for now, if you want to participate in the experiment, send > me your public key (ideally in a gpg signed mail, but if not, oh well), > and you can push to my repo at > > git@pivot.cs.unb.ca:pub/nmbug While I think having a central shared tag repo is ok to get started, I would really like to see this work in a distributed way. I don't think it's impossible to extend this model you have here to work in a distributed way, though, so that will be something good to work on down the line. > Probably the most crucial thing is that we agree on some set of tags. > Here is the set of tags I am working with (output from > notmuch search --output=tags "*" | grep ^notmuch:: > ) > > notmuch::bug is a bug report > notmuch::feature provides a new feature > notmuch::fix fixes a bug > notmuch::obsolete replaced by some other patch > notmuch::patch > notmuch::portability improves portability > notmuch::pushed is pushed to master > notmuch::review is a review > notmuch::reviewed has been (well reviewed) > notmuch::test provides a new test/or improves testing > > The prefix "notmuch::" is hardcoded into the script, but everything > else is easy to change with the usual notmuch operations. Of course > we can change the prefix too. I decided on :: because it needed less > escaping. I think these are a fine set to start with. It might be nice to let the user configure what prefix they use (ie. what goes before the "::" (currently "notmuch")). Does this system support the removing of tags? I guess I need to see the documentation for the restore --match option... It's too bad there's not a way to do scoped tag searches in notmuch (ie. notmuch search tag:"notmuch::*"). Any idea how hard it would be to support something like that? > On think I'm not sure about is how to handle ideas like "voting", and > "signing off" with tags. I suspect we can come up with some > conventions like "notmuch::review1", or > "notmuch::vote1".."notmuch::vote5". But maybe people have less kludgy > ideas. What issue are you trying to solve here? Whatever it is, I don't think I like enumerating tags as the solution. Again, thanks so much for working on this, David. This is going to be very cool. I really look forward to fleshing it out, and using it! jamie.
On Sat, 29 Oct 2011 17:44:56 -0700, Jameson Graef Rollins <jrollins@finestructure.net> wrote: > On Sat, 29 Oct 2011 13:45:06 -0300, David Bremner <david@tethera.net> wrote: > > These patches did not apply cleanly for me from the list. I was able to > get them from bremner's "nmbug" branch [0], though. > [0] git://pivot.cs.unb.ca/git/notmuch I did resend the one patch that we figured out was corrupted, but for the moment I will just rebase the nmbug branch that jrollins mentioned. > > $ nmbug dump > > $ cd $HOME/.nmbug && git add tags && git commit [snip] > Could they be merged into a single operation? Yes, "commit" now (in my git repo) does both the dump and the git commit. > While I think having a central shared tag repo is ok to get started, I > would really like to see this work in a distributed way. So far I don't see any technical issues with working in a distributed way, just social ones. Whatever organization we set up, I think it is important for there to be a way to submit and manage bug reports for "outsiders". Of course, requiring a notmuch install is already a burden. > It might be nice to let the user configure what prefix they use > (ie. what goes before the "::" (currently "notmuch")). There are two simple-matters-of-programming here. One is how to do the configuration; probably "nmbug config" can be an alias for "git config nmbug.$1" or something. The other is translating between prefixes. Neither is hard, I guess. > Does this system support the removing of tags? I guess I need to see > the documentation for the restore --match option... Yes, barring bugs, removing a tag in notmuch and running "nmbug commit" should remove from the files in ~/.nmbug/tags > It's too bad there's not a way to do scoped tag searches in notmuch > (ie. notmuch search tag:"notmuch::*"). Any idea how hard it would be to > support something like that? I don't know. Carl thought it should work, but it doesn't seem to. My uneducated guess is it has something to do with query parsing. > > On think I'm not sure about is how to handle ideas like "voting", and > > "signing off" with tags. I suspect we can come up with some > What issue are you trying to solve here? Whatever it is, I don't think > I like enumerating tags as the solution. I'm trying to handle the issue of sharing non-boolean data. For example, - how can we record priorities bugs/patches - how can we conveniently find all of the emacs patches (b.t.w I started using notmuch::emacs for those) that jrollins has endorsed but are not pushed. Of course, nmbug could share more metadata than tags. OTOH I'd like to avoid completely reinventing a distributed [0] bug tracker. David [0] well, at least potentially distributed, depending on definitions.
Patch
diff --git a/notmuch-restore.c b/notmuch-restore.c index e5ac162..a1b6b81 100644 --- a/notmuch-restore.c +++ b/notmuch-restore.c @@ -64,7 +64,7 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) break; case 'm': match_enabled = TRUE; - if ( xregcomp (&match_regex, optarg, REG_EXTENDED) ) + if ( xregcomp (&match_regex, optarg, REG_EXTENDED|REG_NOSUB) ) return 1; break; case '?': @@ -147,6 +147,10 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) { const char *tag = notmuch_tags_get (db_tags); + if (match_enabled && !accumulate && + !regexec (&match_regex, tag, 0, NULL, 0) ) + notmuch_message_remove_tag (message, tag); + if (db_tags_str) db_tags_str = talloc_asprintf_append (db_tags_str, " %s", tag); else @@ -155,14 +159,15 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) if (((file_tags == NULL || *file_tags == '\0') && (db_tags_str == NULL || *db_tags_str == '\0')) || - (file_tags && db_tags_str && strcmp (file_tags, db_tags_str) == 0)) + (!match_enabled && file_tags && db_tags_str && + strcmp (file_tags, db_tags_str) == 0)) { goto NEXT_LINE; } notmuch_message_freeze (message); - if (!accumulate) + if (!accumulate && !match_enabled) notmuch_message_remove_all_tags (message); next = file_tags; @@ -170,6 +175,11 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[]) tag = strsep (&next, " "); if (*tag == '\0') continue; + + if (match_enabled && + regexec (&match_regex, tag, 0, NULL, 0)) + continue; + status = notmuch_message_add_tag (message, tag); if (status) { fprintf (stderr, diff --git a/test/dump-restore b/test/dump-restore index 18925a4..a4517f6 100755 --- a/test/dump-restore +++ b/test/dump-restore @@ -72,7 +72,6 @@ test_expect_success 'Restoring with trivial match' \ sed 's/inbox\|unread\|signed//g' < dump-ABC_DEF.expected > dump-ABC_DEF-only -test_subtest_known_broken test_expect_success 'Simulate accumulate with match' \ 'notmuch restore < dump.expected && notmuch restore --match="(ABC|DEF)" < dump-ABC_DEF-only && @@ -80,7 +79,6 @@ test_expect_success 'Simulate accumulate with match' \ notmuch restore < dump.expected && test_cmp dump-ABC_DEF.expected dump-simulate.actual' -test_subtest_known_broken test_expect_success 'clear only matched tags' \ 'notmuch restore < dump-ABC_DEF.expected && notmuch restore --match="(ABC|DEF)" < clear.expected && @@ -88,7 +86,6 @@ test_expect_success 'clear only matched tags' \ notmuch restore < dump.expected && test_cmp dump.expected dump-clear-match.actual' -test_subtest_known_broken test_expect_success 'import only matched tags' \ 'notmuch restore < dump.expected && notmuch restore --match="(inbox|unread)" < dump-ABC_DEF.expected && @@ -99,7 +96,6 @@ test_expect_success 'import only matched tags' \ sed 's/inbox\|unread\|signed\|ABC//g' < dump-ABC_DEF.expected > dump-DEF-only sed 's/inbox\|unread\|signed\|DEF//g' < dump-ABC_DEF.expected > dump-ABC-only -test_subtest_known_broken test_expect_success 'combine --match and --accumulate' \ 'notmuch restore < dump.expected && notmuch restore --match="(ABC|DEF)" < dump-ABC-only &&
From: David Bremner <bremner@debian.org> notmuch restore --match=<regex> will for each message in the dump file, delete any tags from the database matching <regex> and add any from the dump file matching <regex>. I tried to keep this simple, so in particular turning on regex matching disables one of the optimizations. --- notmuch-restore.c | 16 +++++++++++++--- test/dump-restore | 4 ---- 2 files changed, 13 insertions(+), 7 deletions(-)