~nmb/bzr-colo/colo-in-core

« back to all changes in this revision

Viewing changes to colocated.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2011-05-06 02:21:15 UTC
  • mfrom: (107.1.6 hide-branch-status)
  • Revision ID: nmb@wartburg.edu-20110506022115-amb4g0zfpam699yh
Hide branches based on the option bzr.branch.status

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
        """The shared repository object."""
92
92
        return repository.Repository.open(self.repo_location)
93
93
 
 
94
    HIDDEN_STATUSES = ['merged',
 
95
                       'abandoned',
 
96
                       'hidden',
 
97
                      ]
 
98
 
 
99
    def _should_display_branch(self, br_to_display, name=None):
 
100
        if name is None:
 
101
            name = self._name_from_branch(br_to_display)
 
102
        for p in name.split('/'):
 
103
            if p.startswith('.'):
 
104
                return False
 
105
 
 
106
        status = br_to_display.get_config().get_user_option('bzr.branch.status')
 
107
        if status is not None:
 
108
            if status.lower() in self.HIDDEN_STATUSES:
 
109
                return False
 
110
 
 
111
        return True
 
112
 
94
113
    def branch_names(self, all=True):
95
114
        """A generator of the names of the branches."""
96
115
        current_name = self.current_branch_name()
97
116
        for b in self.branches():
98
117
            name = self._name_from_branch(b)
99
118
            if not all and name != current_name:
100
 
                for p in name.split('/'):
101
 
                    if p.startswith('.'):
102
 
                        break
 
119
                if self._should_display_branch(b, name):
 
120
                    yield name
103
121
                else:
104
 
                    yield name
105
 
                continue
 
122
                    continue
106
123
            else:
107
124
                yield name
108
125