/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 bzrlib/help_topics.py

  • Committer: Robert Collins
  • Date: 2007-04-23 02:29:35 UTC
  • mfrom: (2441 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: robertc@robertcollins.net-20070423022935-9hhongamvk6bfdso
Resolve conflicts with bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
190
190
branch, which could be slow if a network connection is involved. Also, as you
191
191
don't have a local branch, then you cannot commit locally.
192
192
 
193
 
Lightwieght checkouts work best when you have fast reliable access to the
 
193
Lightweight checkouts work best when you have fast reliable access to the
194
194
master branch. This means that if the master branch is on the same disk or LAN
195
195
a lightweight checkout will be faster than a heavyweight one for any commands
196
196
that modify the revision history (as only one copy branch needs to be updated).
199
199
then there wont be a noticeable difference.
200
200
 
201
201
Another possible use for a checkout is to use it with a treeless repository
202
 
containing your branches, where you maintain only only one working tree by
 
202
containing your branches, where you maintain only one working tree by
203
203
switching the master branch that the checkout points to when you want to 
204
204
work on a different branch.
205
205
 
206
206
Obviously to commit on a checkout you need to be able to write to the master
207
 
branch. This means that the master branch must be accessable over a writeable
 
207
branch. This means that the master branch must be accessible over a writeable
208
208
protocol , such as sftp://, and that you have write permissions at the other
209
209
end. Checkouts also work on the local file system, so that all that matters is
210
210
file permissions.
243
243
topic_registry.register('checkouts', _checkouts,
244
244
                        'Information on what a checkout is')
245
245
 
 
246
 
 
247
class HelpTopicIndex(object):
 
248
    """A index for bzr help that returns topics."""
 
249
 
 
250
    def __init__(self):
 
251
        self.prefix = ''
 
252
 
 
253
    def get_topics(self, topic):
 
254
        """Search for topic in the HelpTopicRegistry.
 
255
 
 
256
        :param topic: A topic to search for. None is treated as 'basic'.
 
257
        :return: A list which is either empty or contains a single
 
258
            RegisteredTopic entry.
 
259
        """
 
260
        if topic is None:
 
261
            topic = 'basic'
 
262
        if topic in topic_registry:
 
263
            return [RegisteredTopic(topic)]
 
264
        else:
 
265
            return []
 
266
 
 
267
 
 
268
class RegisteredTopic(object):
 
269
    """A help topic which has been registered in the HelpTopicRegistry.
 
270
 
 
271
    These topics consist of nothing more than the name of the topic - all
 
272
    data is retrieved on demand from the registry.
 
273
    """
 
274
 
 
275
    def __init__(self, topic):
 
276
        """Constructor.
 
277
 
 
278
        :param topic: The name of the topic that this represents.
 
279
        """
 
280
        self.topic = topic
 
281
 
 
282
    def get_help_text(self, additional_see_also=None):
 
283
        """Return a string with the help for this topic.
 
284
 
 
285
        :param additional_see_also: Additional help topics to be
 
286
            cross-referenced.
 
287
        """
 
288
        result = topic_registry.get_detail(self.topic)
 
289
        # there is code duplicated here and in bzrlib/plugin.py's 
 
290
        # matching Topic code. This should probably be factored in
 
291
        # to a helper function and a common base class.
 
292
        if additional_see_also is not None:
 
293
            see_also = sorted(set(additional_see_also))
 
294
        else:
 
295
            see_also = None
 
296
        if see_also:
 
297
            result += '\nSee also: '
 
298
            result += ', '.join(see_also)
 
299
            result += '\n'
 
300
        return result
 
301
 
 
302
    def get_help_topic(self):
 
303
        """Return the help topic this can be found under."""
 
304
        return self.topic