/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to commands.py

Add convenience command for accessing virtual git refs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
                    self.outf.write("%s\n" % sha1)
166
166
        finally:
167
167
            repo.unlock()
 
168
 
 
169
 
 
170
class cmd_git_refs(Command):
 
171
    """Output all of the virtual refs for a repository.
 
172
 
 
173
    """
 
174
 
 
175
    hidden = True
 
176
 
 
177
    takes_options = [Option('directory',
 
178
        short_name='d',
 
179
        help='Location of repository.', type=unicode)]
 
180
 
 
181
    @display_command
 
182
    def run(self, directory="."):
 
183
        from bzrlib.bzrdir import (
 
184
            BzrDir,
 
185
            )
 
186
        from bzrlib.plugins.git.refs import (
 
187
            BazaarRefsContainer,
 
188
            )
 
189
        from bzrlib.plugins.git.object_store import (
 
190
            get_object_store,
 
191
            )
 
192
        bzrdir, _ = BzrDir.open_containing(directory)
 
193
        repo = bzrdir.find_repository()
 
194
        repo.lock_read()
 
195
        try:
 
196
            object_store = get_object_store(repo)
 
197
            refs = BazaarRefsContainer(bzrdir, object_store)
 
198
            for k, v in refs.as_dict().iteritems():
 
199
                self.outf.write("%s -> %s\n" % (k, v))
 
200
        finally:
 
201
            repo.unlock()