From d4f2581e5cb6fa11b9510c2e0a3ea6e52411fec4 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Fri, 15 Aug 2008 12:43:27 -0400 Subject: Modify _updatedeps slightly (it wasn't being used by anything anyway) and implement it for bz32 and rhbz --- bugzilla/base.py | 7 ++++--- bugzilla/bugzilla3.py | 16 +++++++++++----- bugzilla/rhbugzilla.py | 26 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/bugzilla/base.py b/bugzilla/base.py index 59c505f..8158998 100644 --- a/bugzilla/base.py +++ b/bugzilla/base.py @@ -476,10 +476,11 @@ class BugzillaBase(object): def _setassignee(self,id,**data): '''IMPLEMENT ME: set the assignee of the given bug ID''' raise NotImplementedError - def _updatedeps(self,id,deplist): + def _updatedeps(self,id,blocked,dependson,action): '''IMPLEMENT ME: update the deps (blocked/dependson) for the given bug. - updateDepends($bug_id,$data,$username,$password,$nodependencyemail) - #data: 'blocked'=>id,'dependson'=>id,'action' => ('add','remove')''' + blocked, dependson: list of bug ids/aliases + action: 'add' or 'remove' + ''' raise NotImplementedError def _updatecc(self,id,cclist,action,comment='',nomail=False): '''IMPLEMENT ME: Update the CC list using the action and account list diff --git a/bugzilla/bugzilla3.py b/bugzilla/bugzilla3.py index 8ff42d1..c64c43f 100644 --- a/bugzilla/bugzilla3.py +++ b/bugzilla/bugzilla3.py @@ -207,11 +207,17 @@ class Bugzilla32(Bugzilla3): update = dict([(k,v) for k,v in data.iteritems() if v != '']) return self._update_bug(ids=[id],updates=data) - def _updatedeps(self,id,deplist): - '''IMPLEMENT ME: update the deps (blocked/dependson) for the given bug. - updateDepends($bug_id,$data,$username,$password,$nodependencyemail) - #data: 'blocked'=>id,'dependson'=>id,'action' => ('add','remove')''' - raise NotImplementedError, "wwoods needs to port this method." + def _updatedeps(self,id,blocked,dependson,action): + '''Update the deps (blocked/dependson) for the given bug. + blocked, dependson: list of bug ids/aliases + action: 'add' or 'delete' + ''' + if action not in ('add','delete'): + raise ValueError, "action must be 'add' or 'delete'" + update={'%s_blocked' % action: blocked, + '%s_dependson' % action: dependson} + self._update_bug(ids=id,updates=update) + def _updatecc(self,id,cclist,action,comment='',nomail=False): '''Updates the CC list using the action and account list specified. cclist must be a list (not a tuple!) of addresses. diff --git a/bugzilla/rhbugzilla.py b/bugzilla/rhbugzilla.py index d19c863..984787b 100644 --- a/bugzilla/rhbugzilla.py +++ b/bugzilla/rhbugzilla.py @@ -185,11 +185,29 @@ class RHBugzilla(bugzilla.base.BugzillaBase): data: 'assigned_to','reporter','qa_contact','comment' returns: [$id, $mailresults]''' return self._proxy.bugzilla.changeAssignment(id,data) - def _updatedeps(self,id,deplist): - '''IMPLEMENT ME: update the deps (blocked/dependson) for the given bug. + def _updatedeps(self,id,blocked,dependson,action): + '''update the deps (blocked/dependson) for the given bug. + blocked/dependson: list of bug ids/aliases + action: 'add' or 'delete' + + RHBZ call: updateDepends($bug_id,$data,$username,$password,$nodependencyemail) - #data: 'blocked'=>id,'dependson'=>id,'action' => ('add','remove')''' - raise NotImplementedError + #data: 'blocked'=>id,'dependson'=>id,'action' => ('add','remove') + + RHBZ only does one bug at a time, so this method will loop through + the blocked/dependson lists. This may be slow. + ''' + r = [] + if action == 'delete': + action == 'remove' + data = {'id':id, 'action':action, 'blocked':'', 'dependson':''} + for b in blocked: + data['blocked'] = b + self._proxy.bugzilla.updateDepends(id,data) + data['blocked'] = '' + for d in dependson: + data['dependson'] = d + self._proxy.bugzilla.updateDepends(id,data) def _updatecc(self,id,cclist,action,comment='',nomail=False): '''Updates the CC list using the action and account list specified. cclist must be a list (not a tuple!) of addresses. -- cgit