Handle Launchpad duplicates better
This commit is contained in:
parent
a7f415defd
commit
53451ef83f
|
@ -404,9 +404,9 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||||
if self.registryValue('replyWhenNotFound'):
|
if self.registryValue('replyWhenNotFound'):
|
||||||
irc.error("%s bug %d could not be found" % (tracker.description, bugid))
|
irc.error("%s bug %d could not be found" % (tracker.description, bugid))
|
||||||
except BugtrackerError, e:
|
except BugtrackerError, e:
|
||||||
if 'private' in str(e):
|
# if 'private' in str(e):
|
||||||
irc.reply("Bug %d on http://launchpad.net/bugs/%d is private" % (bugid, bugid))
|
# irc.reply("Bug %d on http://launchpad.net/bugs/%d is private" % (bugid, bugid))
|
||||||
return
|
# return
|
||||||
if not sure_bug and bugid < 30:
|
if not sure_bug and bugid < 30:
|
||||||
return
|
return
|
||||||
irc.error(str(e))
|
irc.error(str(e))
|
||||||
|
@ -760,6 +760,12 @@ class Launchpad(IBugtracker):
|
||||||
if bugdata.private:
|
if bugdata.private:
|
||||||
raise BugtrackerError, "This bug is private"
|
raise BugtrackerError, "This bug is private"
|
||||||
dup = bugdata.duplicate_of
|
dup = bugdata.duplicate_of
|
||||||
|
summary_prefix = '' # Used to made dups easier
|
||||||
|
while dup:
|
||||||
|
summary_prefix = 'duplicate for #%d ' % id
|
||||||
|
bugdata = dup
|
||||||
|
dup = bugdata.duplicate_of
|
||||||
|
|
||||||
affected = bugdata.users_affected_count_with_dupes
|
affected = bugdata.users_affected_count_with_dupes
|
||||||
heat = bugdata.heat
|
heat = bugdata.heat
|
||||||
tasks = bugdata.bug_tasks
|
tasks = bugdata.bug_tasks
|
||||||
|
@ -780,23 +786,24 @@ class Launchpad(IBugtracker):
|
||||||
assignee = ''
|
assignee = ''
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
#NOTE: The LP API will raise a lazr.restfulclient.errors.HTTPError with private bugs, so bugdata.private is useless..., do the checking here instead
|
if type(e).__name__ == 'HTTPError': # messy, but saves trying to import lazr.restfulclient.errors.HTPError
|
||||||
if e.__class__.__name__ == 'HTTPError': # messy, but meh
|
if e.response.status == 404:
|
||||||
raise BugtrackerError, e.content # should be 'Bug nnnnn is private'
|
bugNo = e.content.split(None)[-1][2:-1] # extract the real bug number
|
||||||
|
if bugNo != str(id): # A duplicate of a private bug, at least we know it exists
|
||||||
|
raise BugtrackerError, 'Bug #%s is a duplicate of bug #%s, but it is private (%s/bugs/%s)' % (id, bugNo, self.url, bugNo)
|
||||||
|
raise BugtrackerError, "Bug #%s (%s/bugs/%d) is private or doesn't exist" % (id, self.url, id) # Could be private, could just not exist
|
||||||
|
|
||||||
|
supylog.exception("Error gathering bug data for %s bug #%d" % (self.description, id))
|
||||||
|
raise BugtrackerError, "Could not gather data from %s for bug #%s (%s/bugs/%s). The error has been logged" % (self.description, id, self.url, id)
|
||||||
elif isinstance(e, KeyError):
|
elif isinstance(e, KeyError):
|
||||||
raise BugNotFoundError
|
raise BugNotFoundError
|
||||||
supylog.exception("Error gathering bug data for %s bug %d" % (self.description, id))
|
supylog.exception("Error gathering bug data for %s bug %d" % (self.description, id))
|
||||||
s = 'Could not parse data returned by %s: %s (%s/bugs/%d)' % (self.description, e, self.url, id)
|
raise BugtrackerError, "Could not gather data from %s for bug #%s (%s/bugs/%s). The error has been logged" % (self.description, id, self.url, id)
|
||||||
raise BugtrackerError, s
|
|
||||||
|
|
||||||
extinfo = "(affected: %d, heat: %d)" % (affected, heat)
|
extinfo = "(affected: %d, heat: %d)" % (affected, heat)
|
||||||
|
|
||||||
if dup:
|
return [(bugdata.id, t, summary_prefix + bugdata.title, taskdata.importance, taskdata.status,
|
||||||
dupbug = self.get_bug(dup.id)
|
assignee, "%s/bugs/%s" % (self.url, bugdata.id), extinfo)]
|
||||||
return [(id, t, bugdata.title + (' (dup-of: %d)' % dup.id), taskdata.importance,
|
|
||||||
taskdata.status, assignee, "%s/bugs/%s" % (self.url, id))] + dupbug
|
|
||||||
return [(id, t, bugdata.title, taskdata.importance, taskdata.status,
|
|
||||||
assignee, "%s/bugs/%s" % (self.url, id), extinfo)]
|
|
||||||
|
|
||||||
def get_bug_old(self, id): #Depricated
|
def get_bug_old(self, id): #Depricated
|
||||||
if id == 1:
|
if id == 1:
|
||||||
|
@ -832,10 +839,16 @@ class Launchpad(IBugtracker):
|
||||||
t = taskdata['task']
|
t = taskdata['task']
|
||||||
if '(' in t:
|
if '(' in t:
|
||||||
t = t[:t.rfind('(') -1]
|
t = t[:t.rfind('(') -1]
|
||||||
if bugdata['duplicate-of']:
|
if bugdata['duplicate-of']: # This will suck if for dup of dups..., but +text is pure suck anyway
|
||||||
dupbug = self.get_bug(int(bugdata['duplicate-of']))
|
bugNo = bugdata['duplicate-of']
|
||||||
return [(id, t, bugdata['title'] + (' (dup-of: %d)' % dupbug[0][0]), taskdata['importance'],
|
try:
|
||||||
taskdata['status'], taskdata['assignee'], "%s/bugs/%s" % (self.url, id))] + dupbug
|
data = self.get_bug(int(bugdata['duplicate-of']))
|
||||||
|
except Exception, e:
|
||||||
|
if '404' in str(e):
|
||||||
|
raise BugtrackerError, 'Bug #%s is a duplicate of Bug #%s, but it is private. (%s/bugs/%s)' % (id, bugNo, self.url, bugNo)
|
||||||
|
data = list(data[0])
|
||||||
|
data[2] = ('duplicate for #%d ' % id) + data[2]
|
||||||
|
return [tuple(data)]
|
||||||
return [(id, t, bugdata['title'], taskdata['importance'],
|
return [(id, t, bugdata['title'], taskdata['importance'],
|
||||||
taskdata['status'], taskdata['assignee'], "%s/bugs/%s" % (self.url, id))]
|
taskdata['status'], taskdata['assignee'], "%s/bugs/%s" % (self.url, id))]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue