def help(self, *args):
return '\n\n'.join([self._usage(),
self._option_help(),
- self._long_help()])
+ self._long_help().rstrip('\n')])
def _usage(self):
usage = 'usage: be %s [options]' % self.name
>>> import sys
>>> import libbe.bugdir
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
- >>> cmd = Subscribe()
+ >>> cmd = Diff()
>>> cmd._storage = bd.storage
>>> cmd._setup_io = lambda i_enc,o_enc : None
>>> cmd.stdout = sys.stdout
>>> original = bd.storage.commit('Original status')
>>> bug = bd.bug_from_uuid('a')
>>> bug.status = 'closed'
- >>> changed = bd.vcs.commit('Closed bug a')
- >>> if bd.vcs.versioned == True:
+ >>> changed = bd.storage.commit('Closed bug a')
+ >>> if bd.storage.versioned == True:
... ret = cmd.run(args=[original])
... else:
... print 'Modified bugs:\\n a:cm: Bug A\\n Changed bug settings:\\n status: open -> closed'
a:cm: Bug A
Changed bug settings:
status: open -> closed
- >>> if bd.vcs.versioned == True:
+ >>> if bd.storage.versioned == True:
... ret = cmd.run({'subscribe':'%(bugdir_id)s:mod', 'uuids':True}, [original])
... else:
... print 'a'
a
- >>> if bd.vcs.versioned == False:
+ >>> if bd.storage.versioned == False:
... ret = cmd.run(args=[original])
... else:
... raise libbe.command.UserError('This repository not revision-controlled.')
def _long_help(self):
return """
-Uses the VCS to compare the current tree with a previous tree, and
-prints a pretty report. If REVISION is given, it is a specifier for
-the particular previous tree to use. Specifiers are specific to their
-VCS.
+Uses the storage backend to compare the current tree with a previous
+tree, and prints a pretty report. If REVISION is given, it is a
+specifier for the particular previous tree to use. Specifiers are
+specific to their storage backend.
For Arch your specifier must be a fully-qualified revision name.
>>> cmd._setup_io = lambda i_enc,o_enc : None
>>> cmd.stdout = sys.stdout
+ >>> uuid_gen = libbe.util.id.uuid_gen
>>> libbe.util.id.uuid_gen = lambda: 'X'
>>> ret = cmd.run(args=['this is a test',])
Created bug with ID abc/X
+ >>> libbe.util.id.uuid_gen = uuid_gen
>>> bd.flush_reload()
>>> bug = bd.bug_from_uuid('X')
>>> print bug.summary
setattr(bugdir, attr, params['value'])
return 0
+ def _long_help(self):
+ return """
+Show or change per-tree settings.
+
+If name and value are supplied, the name is set to a new value.
+If no value is specified, the current value is printed.
+If no arguments are provided, all names and values are listed.
+
+To unset a setting, set it to "none".
+
+Allowed settings are:
+
+%s""" % ('\n'.join(get_bugdir_settings()),)
+
def get_bugdir_settings():
settings = []
for s in libbe.bugdir.BugDir.settings_properties:
documented_settings.append('%s\n%s' % (s, '\n'.join(doc)))
return documented_settings
-longhelp="""
-Show or change per-tree settings.
-
-If name and value are supplied, the name is set to a new value.
-If no value is specified, the current value is printed.
-If no arguments are provided, all names and values are listed.
-
-To unset a setting, set it to "none".
-
-Allowed settings are:
-
-%s""" % ('\n'.join(get_bugdir_settings()),)
-
-
def _value_string(bugdir, setting):
val = bugdir.settings.get(setting, EMPTY)
if val == EMPTY:
>>> import libbe.bugdir
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> cmd = Subscribe()
- >>> cmd._storage = bd.storage
+ >>> cmd._bugdir = bd
>>> cmd._setup_io = lambda i_enc,o_enc : None
>>> cmd.stdout = sys.stdout
>>> a = bd.bug_from_uuid('a')
>>> print a.extra_strings
[]
- >>> ret = cmd.run({'subscriber':'John Doe <j@doe.com>'], ['/a']) # doctest: +NORMALIZE_WHITESPACE
+ >>> ret = cmd.run({'subscriber':'John Doe <j@doe.com>'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE
Subscriptions for abc/a:
John Doe <j@doe.com> all *
>>> bd.flush_reload()
Subscriptions for a:
Jane Doe <J@doe.com> all a.com,a.edu,b.net
John Doe <j@doe.com> all *
- >>> ret = cmd.run({'-u', 'subscriber':'Jane Doe <J@doe.com>', 'servers':'a.com'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE
+ >>> ret = cmd.run({'unsubscribe':True, 'subscriber':'Jane Doe <J@doe.com>', 'servers':'a.com'}, ['/a']) # doctest: +NORMALIZE_WHITESPACE
Subscriptions for a:
Jane Doe <J@doe.com> all a.edu,b.net
John Doe <j@doe.com> all *
Subscriptions for a:
John Doe <j@doe.com> all *
>>> ret = cmd.run({'unsubscribe':True, 'subscriber':'John Doe <j@doe.com>'}, ['/a'])
- >>> ret = cmd.run({'subscriber':'Jane Doe <J@doe.com>', '-t':'new'}, 'DIR']) # doctest: +NORMALIZE_WHITESPACE
+ >>> ret = cmd.run({'subscriber':'Jane Doe <J@doe.com>', 'types':'new'}, ['DIR']) # doctest: +NORMALIZE_WHITESPACE
Subscriptions for bug directory:
Jane Doe <J@doe.com> new *
>>> ret = cmd.run({'subscriber':'Jane Doe <J@doe.com>'}, ['DIR']) # doctest: +NORMALIZE_WHITESPACE
blacklisted_values = set(string[1:].split(','))
for value in blacklisted_values:
if value not in possible_values:
- raise UserError('Invalid %s %s\n %s'
+ raise libbe.command.UserError('Invalid %s %s\n %s'
% (name, value, possible_values))
possible_values.remove(value)
else:
def comment_body_change_string(self, bodies):
old_body,new_body = bodies
return difflib.unified_diff(old_body, new_body)
-
-
-if libbe.TESTING == True:
- suite = doctest.DocTestSuite()