source: mergebot/trunk/mergebot/action_logic.py

Last change on this file was 32, checked in by retracile, 14 years ago

Mergebot: handle tickets with a 'None' mergebotstate, such as those that exist before the plugin is installed

File size: 1.3 KB
Line 
1def _get_mergebotstate(ticket):
2    if hasattr(ticket, '_old') and 'mergebotstate' in ticket._old:
3        state = ticket._old['mergebotstate']
4    else:
5        try:
6            state = ticket['mergebotstate']
7        except KeyError:
8            state = ""
9    if state == "--":
10        state = ""
11    return state
12
13# FIXME: If a ticket has another ticket as its version (#123), then we need to
14# make sure that the other ticket has an existing branch ('branched' mergebot
15# state) before we allow any actions.
16# More accurately, we need to determine if, after all queued actions upon which
17# it would depend complete successfully, that these operations would be
18# allowed.
19def is_branchable(ticket):
20    state = _get_mergebotstate(ticket)
21    return state in [None, '', 'merged']
22
23def is_rebranchable(ticket):
24    # TODO: we should be able to tell if trunk (or version) has had commits
25    # since we branched, and only mark it as rebranchable if there have
26    # been.
27    state = _get_mergebotstate(ticket)
28    return state in ["branched", "conflicts"]
29
30def is_mergeable(ticket):
31    state = _get_mergebotstate(ticket)
32    return state == "branched"
33
34def is_checkmergeable(ticket):
35    state = _get_mergebotstate(ticket)
36    return state == "branched" or state == "conflicts"
37
Note: See TracBrowser for help on using the repository browser.