source: mergebot/trunk/mergebot/Actor.py @ 17

Last change on this file since 17 was 17, checked in by retracile, 15 years ago

Mergebot: redesigned implementation. Still has rough edges.

File size: 1.9 KB
Line 
1import os
2
3class Actor(object):
4    def __init__(self, work_dir, repo_url, repo_dir, ticket, component,
5                 version, summary, requestor):
6        self.work_dir = work_dir
7        self.repo_url = repo_url
8        self.repo_dir = repo_dir
9        self.ticket = ticket
10        self.component = component
11        self.version = version
12        self.summary = summary
13        self.requestor = requestor
14
15    def execute(self):
16        """To be overridden by subclasses.
17        Returns a tuple containing:
18        a dictionary of fields to update in the ticket
19        a comment string
20        True on success, False on failure
21        """
22        raise NotImplementedError
23
24    def logfilename(self):
25        return os.path.abspath(os.path.join(os.path.dirname(self.work_dir),
26            'ticket-%s.log' % self.ticket))
27
28    def public_url(self):
29        return '%s/%s' % (self.repo_url, self.component)
30
31    def branch_public_url(self):
32        """Returns the public svn url of the branch for this ticket.
33        """
34        return '%s/branches/ticket-%s' % (self.public_url(), self.ticket)
35
36    def local_url(self):
37        return 'file://%s/%s' % (self.repo_dir, self.component)
38
39    def baseline_local_url(self):
40        """Returns the local svn url this ticket branches from.
41        """
42        return '%s/%s' % (self.local_url(), self.version_subdir())
43
44    def branch_local_url(self):
45        """Returns the local svn url of the branch for this ticket.
46        """
47        return '%s/branches/ticket-%s' % (self.local_url(), self.ticket)
48
49    def version_subdir(self):
50        if self.version == 'trunk':
51            subdir = 'trunk'
52        elif self.version.startswith('#'):
53            # branched from another ticket
54            subdir = 'branches/ticket-%s' % self.version.lstrip('#')
55        else:
56            # assume release branch
57            subdir = 'branches/release-%s' % self.version
58        return subdir
59
Note: See TracBrowser for help on using the repository browser.