~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Alexander Belchenko
  • Date: 2006-11-13 16:01:46 UTC
  • mto: This revision was merged to the branch mainline in revision 637.
  • Revision ID: bialix@ukr.net-20061113160146-f1d369c27004b1f7
Added new flag --tips to show tips (last revid) of all branches in repo

Also for head shown branch(es) where this head exist

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    takes_options = [Option('by-date', help='Sort heads by date (descending)'),
34
34
                     Option('all', help='Show all heads (dead and alive)'),
35
35
                     Option('dead-only', help='Show only dead heads'),
 
36
                     Option('tips', help='Show tips of all branches'),
36
37
                     Option('debug-time', help='Enable debug print of operations times'),
37
38
                    ]
38
39
 
39
40
    encoding_type = "replace"
40
41
 
41
42
    @display_command
42
 
    def run(self, by_date=False, all=False, dead_only=False, debug_time=False):
 
43
    def run(self, by_date=False, all=False, dead_only=False, tips=False, debug_time=False):
43
44
        from bzrlib.osutils import format_date
44
45
        import bzrlib.repository
45
46
 
78
79
        ## mark heads as dead or alive
79
80
        # mark all heads as dead
80
81
        self.head_mark = {}
81
 
        self.tips = []
 
82
        self.tips = {}
82
83
        for head in self.heads:
83
84
            self.head_mark[head] = 'dead'
84
85
        # give the list of live branches in repository or current branch tip
86
87
            # runs from shared repo root
87
88
            self._iter_branches_update_marks(u'.')
88
89
        else:
 
90
            from bzrlib.urlutils import (dirname, local_path_from_url)
89
91
            # runs from branch
90
92
            repo_base = repo.bzrdir.transport.base
91
93
            branch_base = branch.bzrdir.transport.base
96
98
                    self.head_mark[last_revid] = 'alive'
97
99
                else:
98
100
                    self.head_mark[last_revid] = 'tip'
99
 
                    self.tips.append(last_revid)
 
101
                self.tips.setdefault(last_revid, []).\
 
102
                    append(local_path_from_url(dirname(branch_base)))
100
103
            else:
101
104
                # repo
102
 
                from bzrlib.urlutils import (dirname, local_path_from_url)
103
105
                repo_root = local_path_from_url(dirname(repo_base))
104
106
                self._iter_branches_update_marks(repo_root)
105
107
        self._print_elapsed_time('make head marks:')
106
108
 
 
109
        if tips:
 
110
            heads_tips = set(self.heads)
 
111
            heads_tips.update(set(self.tips.keys()))
 
112
            self.heads = list(heads_tips)
 
113
 
107
114
        # sorting by date
108
115
        if by_date:
109
116
            dates = {}
133
140
                        continue
134
141
                else:
135
142
                    if mark != 'alive':
136
 
                        continue
137
 
                    
 
143
                        if not tips or mark != 'tip':
 
144
                            continue
 
145
 
 
146
            # tips
 
147
            if mark in ('alive', 'tip'):
 
148
                t = self.tips[head]
 
149
                if len(t) > 1:
 
150
                    print >>to_file, 'TIP of branches:',
 
151
                    print >>to_file, '[', ', '.join(t), ']'
 
152
                else:
 
153
                    print >>to_file, 'TIP of branch:', t[0]
 
154
 
 
155
            if mark in ('alive', 'dead'):
 
156
                print >>to_file, 'HEAD:',
 
157
 
138
158
            print >>to_file, "revision-id:", head,
139
159
            if mark == 'dead':  print >>to_file, '(dead)'
140
160
            else:               print >>to_file
183
203
                self.head_mark[last_revid] = 'alive'
184
204
            else:
185
205
                self.head_mark[last_revid] = 'tip'
186
 
                self.tips.append(last_revid)
 
206
            self.tips.setdefault(last_revid, []).append(directory)
187
207
        os.chdir(cwd)
188
208
 
189
209
    def _init_elapsed_time(self, debug_time=False):