~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Andrew Bennetts
  • Date: 2007-08-30 08:11:54 UTC
  • mfrom: (2766 +trunk)
  • mto: (2535.3.55 repo-refactor)
  • mto: This revision was merged to the branch mainline in revision 2772.
  • Revision ID: andrew.bennetts@canonical.com-20070830081154-16hebp2xwr15x2hc
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
    [<RevisionSpec_branch branch:../../branch2>]
87
87
    >>> _parse_revision_str('branch:../../branch2..23')
88
88
    [<RevisionSpec_branch branch:../../branch2>, <RevisionSpec_revno 23>]
 
89
    >>> _parse_revision_str('branch:..\\\\branch2')
 
90
    [<RevisionSpec_branch branch:..\\branch2>]
 
91
    >>> _parse_revision_str('branch:..\\\\..\\\\branch2..23')
 
92
    [<RevisionSpec_branch branch:..\\..\\branch2>, <RevisionSpec_revno 23>]
89
93
    """
90
94
    # TODO: Maybe move this into revisionspec.py
91
95
    revs = []
92
 
    # split on the first .. that is not followed by a / ?
93
 
    sep = re.compile("\\.\\.(?!/)")
 
96
    # split on .. that is not followed by a / or \
 
97
    sep = re.compile(r'\.\.(?![\\/])')
94
98
    for x in sep.split(revstr):
95
99
        revs.append(revisionspec.RevisionSpec.from_string(x or None))
96
100
    return revs
197
201
            argname = argname.upper()
198
202
        yield self.name, self.short_name(), argname, self.help
199
203
 
 
204
    def is_hidden(self, name):
 
205
        return False
 
206
 
200
207
 
201
208
class ListOption(Option):
202
209
    """Option used to provide a list of values.
300
307
        if self.value_switches:
301
308
            for key in self.registry.keys():
302
309
                option_strings = ['--%s' % key]
303
 
                if getattr(self.registry.get_info(key), 'hidden', False):
 
310
                if self.is_hidden(key):
304
311
                    help = optparse.SUPPRESS_HELP
305
312
                else:
306
313
                    help = self.registry.get_help(key)
325
332
            for key in sorted(self.registry.keys()):
326
333
                yield key, None, None, self.registry.get_help(key)
327
334
 
 
335
    def is_hidden(self, name):
 
336
        if name == self.name:
 
337
            return Option.is_hidden(self, name)
 
338
        return getattr(self.registry.get_info(name), 'hidden', False)
 
339
 
328
340
 
329
341
class OptionParser(optparse.OptionParser):
330
342
    """OptionParser that raises exceptions instead of exiting"""