# HG changeset patch # User Dmitriy Morozov # Date 1199021921 18000 # Node ID 74cbd53bf7d8848de328b94b3fd87388f929c185 # Parent 11cab59302582ee20895cd64335ea6a1e2efff8b Implemented basic filters functionality in ilist (fixing 8e4) diff -r 11cab5930258 -r 74cbd53bf7d8 .issues/8e4d2c2d12eb0169 --- a/.issues/8e4d2c2d12eb0169 Sat Dec 29 23:19:03 2007 -0500 +++ b/.issues/8e4d2c2d12eb0169 Sun Dec 30 08:38:41 2007 -0500 @@ -1,7 +1,7 @@ From artemis Sat Dec 29 07:57:17 2007 From: Dmitriy Morozov Date: Sat, 29 Dec 2007 02:52:52 EST -State: new +State: fixed Subject: filters Message-Id: 8e4d2c2d12eb0169-0-artemis@metatron @@ -18,3 +18,12 @@ Then hg ilist -f critical-1.0 would show only issues with properties due-in and priority set to 1.0 and critical in the respective headers. + +From MAILER-DAEMON Sun Dec 30 13:37:54 2007 +From: Dmitriy Morozov +Date: Sun, 30 Dec 2007 08:37:54 EST +Subject: properties changes (state) +Message-Id: 8e4d2c2d12eb0169-1-artemis@metatron +References: 8e4d2c2d12eb0169-0-artemis@metatron + +state=fixed diff -r 11cab5930258 -r 74cbd53bf7d8 artemis.py --- a/artemis.py Sat Dec 29 23:19:03 2007 -0500 +++ b/artemis.py Sun Dec 30 08:38:41 2007 -0500 @@ -4,13 +4,13 @@ from mercurial import hg, util from mercurial.i18n import _ -import os, time, random, mailbox, glob, socket +import os, time, random, mailbox, glob, socket, ConfigParser state = {'new': 'new', 'fixed': 'fixed'} state['default'] = state['new'] issues_dir = ".issues" -filter_filename = ".filters" +filter_prefix = ".filter" date_format = '%a, %d %b %Y %H:%M:%S %Z' @@ -19,7 +19,7 @@ # Process options show_all = opts['all'] - properties = _get_properties(opts['property']) + properties = [] date_match = lambda x: True if opts['date']: date_match = util.matchdate(opts['date']) @@ -30,6 +30,18 @@ issues = glob.glob(os.path.join(issues_path, '*')) + # Process filter + if opts['filter']: + filters = glob.glob(os.path.join(issues_path, filter_prefix + '*')) + config = ConfigParser.SafeConfigParser() + config.read(filters) + if not config.has_section(opts['filter']): + ui.warning('No filter %s defined\n', opts['filter']) + else: + properties += config.items(opts['filter']) + + _get_properties(opts['property']) + for issue in issues: mbox = mailbox.mbox(issue) property_match = True @@ -238,7 +250,7 @@ ('p', 'property', [], 'list issues with specific field values (e.g., -p state=fixed)'), ('d', 'date', '', 'restrict to issues matching the date (e.g., -d ">12/28/2007)"'), - ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s)' % (issues_dir, filter_filename))], + ('f', 'filter', '', 'restrict to pre-defined filter (in %s/%s*)' % (issues_dir, filter_prefix))], _('hg ilist [OPTIONS]')), 'iadd': (iadd, [],