~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/branch.py

[r=Edwin][ui=None] BranchUpgradeJob refactoring for 2.0 changes,
        UI for requesting an upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
    IStoreSelector, MAIN_STORE, SLAVE_FLAVOR)
43
43
 
44
44
from lp.code.bzr import (
45
 
    BranchFormat, BRANCH_FORMAT_UPGRADE_PATH, ControlFormat, RepositoryFormat,
46
 
    REPOSITORY_FORMAT_UPGRADE_PATH)
 
45
    BranchFormat, ControlFormat, CURRENT_BRANCH_FORMATS,
 
46
    CURRENT_REPOSITORY_FORMATS, RepositoryFormat)
47
47
from lp.code.enums import (
48
48
    BranchLifecycleStatus, BranchMergeControlStatus,
49
49
    BranchMergeProposalStatus, BranchType)
998
998
    @property
999
999
    def needs_upgrading(self):
1000
1000
        """See `IBranch`."""
1001
 
        if (REPOSITORY_FORMAT_UPGRADE_PATH.get(self.repository_format, None)
1002
 
            or BRANCH_FORMAT_UPGRADE_PATH.get(self.branch_format, None)):
1003
 
            return True
1004
 
        return False
 
1001
        if self.upgrade_pending:
 
1002
            return False
 
1003
        return not (
 
1004
            self.branch_format in CURRENT_BRANCH_FORMATS and
 
1005
            self.repository_format in CURRENT_REPOSITORY_FORMATS)
 
1006
 
 
1007
    @property
 
1008
    def upgrade_pending(self):
 
1009
        """See `IBranch`."""
 
1010
        from lp.code.model.branchjob import BranchJob, BranchJobType
 
1011
        store = Store.of(self)
 
1012
        jobs = store.find(
 
1013
            BranchJob,
 
1014
            BranchJob.branch == self,
 
1015
            BranchJob.job_type == BranchJobType.UPGRADE_BRANCH)
 
1016
        return jobs.count() > 0
1005
1017
 
1006
1018
    def requestUpgrade(self):
1007
1019
        """See `IBranch`."""