From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 31611429E25 for ; Sat, 29 Oct 2011 10:27:46 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.3 X-Spam-Level: X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id G4lj7XMJQsFO for ; Sat, 29 Oct 2011 10:27:45 -0700 (PDT) Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 851A0431FB6 for ; Sat, 29 Oct 2011 10:27:45 -0700 (PDT) Received: from zancas.localnet (fctnnbsc36w-156034064058.pppoe-dynamic.High-Speed.nb.bellaliant.net [156.34.64.58]) (authenticated bits=0) by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id p9THRfJ6026102 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Sat, 29 Oct 2011 14:27:42 -0300 Received: from bremner by zancas.localnet with local (Exim 4.76) (envelope-from ) id 1RKCh3-0003fA-8l; Sat, 29 Oct 2011 14:27:41 -0300 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v2] contrib/nmbug: new script for sharing tags with prefix notmuch:: Date: Sat, 29 Oct 2011 14:27:33 -0300 Message-Id: <1319909253-14045-1-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.6.3 In-Reply-To: <1319906707-10141-1-git-send-email-david@tethera.net> References: <1319906707-10141-1-git-send-email-david@tethera.net> Cc: David Bremner X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2011 17:27:46 -0000 From: David Bremner In this initial version, we take care of import and export of the appropriate tags in line oriented format amenable to easy merging. We also provide (not very robust/clever) commands commit/push/pull to deal with a git repo that as already been set up. --- fixed silly debugging output. add some convenience commands. contrib/nmbug | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 77 insertions(+), 0 deletions(-) create mode 100755 contrib/nmbug diff --git a/contrib/nmbug b/contrib/nmbug new file mode 100755 index 0000000..a449d60 --- /dev/null +++ b/contrib/nmbug @@ -0,0 +1,77 @@ +#!/bin/bash +# Copyright (c) 2011 David Bremner +# License: same as notmuch + +NMHOME=${HOME}/.nmbug + +NMTAGS=($(notmuch search --output=tags "*"|grep "^notmuch::")) + +function dump() { + notmuch dump -- $(printf " tag:%s" ${NMTAGS[*]}) |\ + while read -r msgid rest + do + outfile=$NMHOME/tags/$(echo $msgid | sha1sum - | cut -f1 -d' ') + printf "msg-id: %s\n" $msgid > $outfile + tmp=${rest#\(} + read -r -a tags <<<${tmp%\)}; + for tag in "${tags[@]}"; do + case $tag in + notmuch::*) + echo "tag: $tag" >> $outfile + ;; + *) + # nothing + esac + done + done + +} + +function cat_file() { + tags="" + id="" + cat $1 |\ + while read -r what data + do + case $what in + msg-id:) + printf "%s (" $data + ;; + tag:) + printf "%s " $data + ;; + *) + echo "Syntax error $what" + exit 1 + esac + done + echo ")" +} + +function restore() { + find $NMHOME/tags -type f |\ + while read -r filename + do + cat_file $filename + done | notmuch restore --match=notmuch:: +} +case $1 in + dump) + dump + ;; + restore) + restore + ;; + commit) + (cd $NMHOME && git add tags && git commit) + ;; + push) + (cd $NMHOME && git push) + ;; + pull) + (cd $NMHOME && git pull) + ;; + *) + echo unknown command $1; +esac + -- 1.7.6.3