~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Alexander Belchenko
  • Date: 2006-11-13 15:30:42 UTC
  • mto: This revision was merged to the branch mainline in revision 637.
  • Revision ID: bialix@ukr.net-20061113153042-0c1706b144ba51e7
Prepare to list tips of branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        for parents in g.values():
68
68
            not_heads.update(set(parents))
69
69
        
70
 
        heads = possible_heads.difference(not_heads)
 
70
        self.heads = possible_heads.difference(not_heads)
71
71
 
72
72
        # TODO: use different sorting schemes instead of alphabetical sort
73
 
        heads = list(heads)
74
 
        heads.sort()
 
73
        self.heads = list(self.heads)
 
74
        self.heads.sort()
75
75
 
76
76
        self._print_elapsed_time('get heads:')
77
77
 
78
 
        # sorting by date
79
 
        if by_date:
80
 
            dates = {}
81
 
            for head in heads:
82
 
                rev = repo.get_revision(head)
83
 
                timestamp = rev.timestamp
84
 
                dates[timestamp] = head
85
 
            keys = dates.keys()
86
 
            keys.sort()
87
 
            keys.reverse()
88
 
            heads = []
89
 
            for k in keys:
90
 
                heads.append(dates[k])
91
 
            self._print_elapsed_time('sort by date:')
92
 
 
93
78
        ## mark heads as dead or alive
94
79
        # mark all heads as dead
95
80
        self.head_mark = {}
96
 
        for head in heads:
 
81
        self.tips = []
 
82
        for head in self.heads:
97
83
            self.head_mark[head] = 'dead'
98
84
        # give the list of live branches in repository or current branch tip
99
85
        if not branch:
106
92
            if repo_base == branch_base:
107
93
                # standalone branch
108
94
                last_revid = branch.last_revision()
109
 
                self.head_mark[last_revid] = 'alive'
 
95
                if last_revid in self.heads:
 
96
                    self.head_mark[last_revid] = 'alive'
 
97
                else:
 
98
                    self.head_mark[last_revid] = 'tip'
 
99
                    self.tips.append(last_revid)
110
100
            else:
111
101
                # repo
112
102
                from bzrlib.urlutils import (dirname, local_path_from_url)
114
104
                self._iter_branches_update_marks(repo_root)
115
105
        self._print_elapsed_time('make head marks:')
116
106
 
 
107
        # sorting by date
 
108
        if by_date:
 
109
            dates = {}
 
110
            for head in self.heads:
 
111
                rev = repo.get_revision(head)
 
112
                timestamp = rev.timestamp
 
113
                dates[timestamp] = head
 
114
            keys = dates.keys()
 
115
            keys.sort()
 
116
            keys.reverse()
 
117
            self.heads = []
 
118
            for k in keys:
 
119
                self.heads.append(dates[k])
 
120
            self._print_elapsed_time('sort by date:')
 
121
 
 
122
 
117
123
        # show time
118
124
        indent = ' '*2
119
125
        show_timezone = 'original'
120
126
        
121
 
        for head in heads:
 
127
        for head in self.heads:
122
128
 
123
129
            mark = self.head_mark[head]
124
130
            if not all:
156
162
            self._print_elapsed_time('print head:')
157
163
            print
158
164
 
159
 
        if not heads:
 
165
        if not self.heads:
160
166
            print >>to_file, 'No heads found'
161
167
            return 1
162
168
 
173
179
            except errors.NotBranchError:
174
180
                continue
175
181
            last_revid = b.last_revision()
176
 
            self.head_mark[last_revid] = 'alive'
177
 
#                self._print_elapsed_time('proceed branch ' + str(b)+':')
 
182
            if last_revid in self.heads:
 
183
                self.head_mark[last_revid] = 'alive'
 
184
            else:
 
185
                self.head_mark[last_revid] = 'tip'
 
186
                self.tips.append(last_revid)
178
187
        os.chdir(cwd)
179
188
 
180
189
    def _init_elapsed_time(self, debug_time=False):