[PATCH 2 of 5] bugzilla: keep bug IDs in set
Jim Hague
jim.hague at acm.org
Wed Mar 30 08:54:18 UTC 2011
# HG changeset patch
# User Jim Hague <jim.hague at acm.org>
# Date 1301474985 -3600
# Node ID ac78587e904c6539858110203061c24211fbc564
# Parent 414a4bc47ce5e062db657c8fe8973fce34d29935
bugzilla: keep bug IDs in set.
Bug IDs are collected into a set, and then silently converted in
filter_real_bug_ids() into a list. For consistency, keep them in
a set throughout and update the docstrings to say that.
diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -190,22 +190,21 @@
return ids[0][0]
def filter_real_bug_ids(self, ids):
- '''filter not-existing bug ids from list.'''
+ '''filter not-existing bug ids from set.'''
self.run('select bug_id from bugs where bug_id in %s' % buglist(ids))
- return sorted([c[0] for c in self.cursor.fetchall()])
+ return set([c[0] for c in self.cursor.fetchall()])
def filter_cset_known_bug_ids(self, node, ids):
- '''filter bug ids from list that already refer to this changeset.'''
+ '''filter bug ids that already refer to this changeset from set.'''
self.run('''select bug_id from longdescs where
bug_id in %s and thetext like "%%%s%%"''' %
(buglist(ids), short(node)))
- unknown = set(ids)
for (id,) in self.cursor.fetchall():
self.ui.status(_('bug %d already knows about changeset %s\n') %
(id, short(node)))
- unknown.discard(id)
- return sorted(unknown)
+ ids.discard(id)
+ return ids
def notify(self, ids, committer):
'''tell bugzilla to send mail.'''
@@ -353,10 +352,12 @@
_split_re = None
def find_bug_ids(self, ctx):
- '''find valid bug ids that are referred to in changeset
- comments and that do not already have references to this
- changeset.'''
+ '''return set of integer bug IDs from commit comment.
+ Extract bug IDs from changeset comments. Filter out any that are
+ not known to Bugzilla, and any that already have a reference to
+ the given changeset in their comments.
+ '''
if bugzilla._bug_re is None:
bugzilla._bug_re = re.compile(
self.ui.config('bugzilla', 'regexp', bugzilla._default_bug_re),
More information about the Mercurial-devel
mailing list