summaryrefslogtreecommitdiffstats
path: root/change.py
blob: 3e44e44e39d3950b4330597aa0ddb9b9cdb82fc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
class Change(object):
    '''
    Class representing a change to be made in Bugzilla.

    Somewhat analogous to a patch to be applied to a source tree.

    Currently only supports printing, but eventually ought to support being
    applied to the bug.

    I want to capture a change as an entity so that you can always do human
    review of the change, rather than automatically pushing blindly via XML-RPC
    '''
    def __init__(self,
                 bug,
                 newsummary=None,
                 newcomponent=None,
                 comment=None,
                 duplicate_id=None,
                 status=None,
                 resolution=None):
        self.bug = bug
        self.comment = comment
        self.newsummary = newsummary
        self.newcomponent = newcomponent
        self.duplicate_id = duplicate_id
        self.status = status
        self.resolution = resolution

    def __str__(self):
        result = ''
        if self.newsummary:
            result += '---- BEGIN SUMMARY ----\n'
            result += self.newsummary
            result += '\n---- END SUMMARY ----\n'

        if self.newcomponent:
            result += '---- BEGIN COMPONENT ----\n'
            result += '"python" -> "%s"\n' % self.newcomponent # is there a way to do this via XML-RPC?
            result += '---- END COMPONENT ----\n'

        if self.comment:
            result += '---- BEGIN COMMENT ----\n'
            result += self.comment
            result += '\n---- END COMMENT ----\n'

        if self.duplicate_id:
            result += '---- MARK AS DUPLICATE OF: %i ----\n' % self.duplicate_id

        if self.status:
            result += '---- SET status: %s ----\n' % self.status

        if self.resolution:
            result += '---- SET resolution: %s ----\n' % self.resolution

        return result

class Duplicate(Change):
    def __init__(self, bug, other_bug_id):
        Change.__init__(self,
                        bug,
                        comment=(
'''Thank you for the bug report.

This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.'''),
                        duplicate_id = other_bug_id
                        )