aboutsummaryrefslogtreecommitdiffstats
path: root/libbe
diff options
context:
space:
mode:
Diffstat (limited to 'libbe')
-rw-r--r--libbe/command/comment.py11
-rw-r--r--libbe/command/list.py15
-rw-r--r--libbe/command/subscribe.py2
-rw-r--r--libbe/command/target.py2
-rw-r--r--libbe/comment.py11
-rw-r--r--libbe/diff.py5
6 files changed, 33 insertions, 13 deletions
diff --git a/libbe/command/comment.py b/libbe/command/comment.py
index 16b0e77..cb46398 100644
--- a/libbe/command/comment.py
+++ b/libbe/command/comment.py
@@ -32,6 +32,7 @@ class Comment (libbe.command.Command):
>>> import time
>>> import libbe.bugdir
+ >>> import libbe.util.id
>>> bd = libbe.bugdir.SimpleBugDir(memory=False)
>>> io = libbe.command.StringInputOutput()
>>> io.stdout = sys.stdout
@@ -39,8 +40,12 @@ class Comment (libbe.command.Command):
>>> ui.storage_callbacks.set_storage(bd.storage)
>>> cmd = Comment(ui=ui)
+ >>> uuid_gen = libbe.util.id.uuid_gen
+ >>> libbe.util.id.uuid_gen = lambda: 'X'
>>> ui._user_id = u'Fran\\xe7ois'
>>> ret = ui.run(cmd, args=['/a', 'This is a comment about a'])
+ Created comment with ID abc/a/X
+ >>> libbe.util.id.uuid_gen = uuid_gen
>>> bd.flush_reload()
>>> bug = bd.bug_from_uuid('a')
>>> bug.load_comments(load_full=False)
@@ -65,7 +70,10 @@ class Comment (libbe.command.Command):
UserError: No comment supplied, and EDITOR not specified.
>>> os.environ['EDITOR'] = "echo 'I like cheese' > "
+ >>> libbe.util.id.uuid_gen = lambda: 'Y'
>>> ret = ui.run(cmd, args=['/b'])
+ Created comment with ID abc/b/Y
+ >>> libbe.util.id.uuid_gen = uuid_gen
>>> bd.flush_reload()
>>> bug = bd.bug_from_uuid('b')
>>> bug.load_comments(load_full=False)
@@ -142,7 +150,8 @@ class Comment (libbe.command.Command):
new = parent.new_reply(body=body)
for key in ['alt-id', 'author', 'content-type']:
if params[key] != None:
- setattr(new, key, params[key])
+ setattr(new, new._setting_name_to_attr_name(key), params[key])
+ print >> self.stdout, 'Created comment with ID %s' % new.id.user()
return 0
def _long_help(self):
diff --git a/libbe/command/list.py b/libbe/command/list.py
index 73c60a9..3803257 100644
--- a/libbe/command/list.py
+++ b/libbe/command/list.py
@@ -104,6 +104,8 @@ class List (libbe.command.Command):
arg=libbe.command.Argument(
name='severity', metavar='SEVERITY', default='all',
completion_callback=libbe.command.util.complete_severity)),
+ libbe.command.Option(name='important',
+ help='List bugs with >= "serious" severity'),
libbe.command.Option(name='assigned', short_name='a',
help='Only show bugs matching ASSIGNED',
arg=libbe.command.Argument(
@@ -133,7 +135,6 @@ class List (libbe.command.Command):
# help="Adjust bug-sort criteria with comma-separated list SORT-BY. e.g. \"--sort creator,time\". Available criteria: %s" % ','.join(AVAILABLE_CMPS), default=None)
# # boolean options. All but ids and xml are special cases of long forms
# ("w", "wishlist", "List bugs with 'wishlist' severity"),
-# ("i", "important", "List bugs with >= 'serious' severity"),
# ("A", "active", "List all active bugs"),
# ("U", "unconfirmed", "List unconfirmed bugs"),
# ("o", "open", "List open bugs"),
@@ -202,7 +203,7 @@ class List (libbe.command.Command):
severity.append(list(libbe.bug.severity_values[serious:]))
else:
severity = libbe.command.util.select_values(
- params['severity'], bug.severity_values)
+ params['severity'], libbe.bug.severity_values)
# select assigned
if params['assigned'] == None:
if params['mine'] == True:
@@ -245,12 +246,12 @@ class List (libbe.command.Command):
def _long_help(self):
return """
This command lists bugs. Normally it prints a short string like
- 576:om: Allow attachments
+ bea/576:om: Allow attachments
Where
- 576 the bug id
- o the bug status is 'open' (first letter)
- m the bug severity is 'minor' (first letter)
- Allo... the bug summary string
+ bea/576 the bug id
+ o the bug status is 'open' (first letter)
+ m the bug severity is 'minor' (first letter)
+ Allo... the bug summary string
You can optionally (-u) print only the bug ids.
diff --git a/libbe/command/subscribe.py b/libbe/command/subscribe.py
index bd36639..d1cf72e 100644
--- a/libbe/command/subscribe.py
+++ b/libbe/command/subscribe.py
@@ -92,7 +92,7 @@ class Subscribe (libbe.command.Command):
libbe.command.Option(name='list', short_name='l',
help='List subscribers (read only action).'),
libbe.command.Option(name='subscriber', short_name='s',
- help='Email address of the subscriber (defaults to bugdir.user_id).',
+ help='Email address of the subscriber (defaults to your user id).',
arg=libbe.command.Argument(
name='subscriber', metavar='EMAIL')),
libbe.command.Option(name='servers', short_name='S',
diff --git a/libbe/command/target.py b/libbe/command/target.py
index 6bb348f..f8a956b 100644
--- a/libbe/command/target.py
+++ b/libbe/command/target.py
@@ -112,7 +112,7 @@ class Target (libbe.command.Command):
def usage(self):
return 'usage: be %(name)s BUG-ID [TARGET]\nor: be %(name)s --resolve [TARGET]' \
- % vars(self)
+ % vars(self.__class__)
def _long_help(self):
return """
diff --git a/libbe/comment.py b/libbe/comment.py
index accd4df..21118f0 100644
--- a/libbe/comment.py
+++ b/libbe/comment.py
@@ -26,6 +26,13 @@ import os.path
import sys
import time
import types
+try:
+ from email.mime.base import MIMEBase
+ from email.encoders import encode_base64
+except ImportError:
+ # adjust to old python 2.4
+ from email.MIMEBase import MIMEBase
+ from email.Encoders import encode_base64
try: # import core module, Python >= 2.5
from xml.etree import ElementTree
except ImportError: # look for non-core module
@@ -289,9 +296,9 @@ class Comment (Tree, settings_object.SavedSettingsObject):
body = (self.body or '').rstrip('\n')
else:
maintype,subtype = self.content_type.split('/',1)
- msg = email.mime.base.MIMEBase(maintype, subtype)
+ msg = MIMEBase(maintype, subtype)
msg.set_payload(self.body or '')
- email.encoders.encode_base64(msg)
+ encode_base64(msg)
body = base64.encodestring(self.body or '')
info = [('uuid', self.uuid),
('alt-id', self.alt_id),
diff --git a/libbe/diff.py b/libbe/diff.py
index 94a2dc3..35e2151 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -671,4 +671,7 @@ class Diff (object):
return self._comment_summary_string(new_comment)
def comment_body_change_string(self, bodies):
old_body,new_body = bodies
- return difflib.unified_diff(old_body, new_body)
+ return ''.join(difflib.unified_diff(
+ old_body.splitlines(True),
+ new_body.splitlines(True),
+ 'before', 'after'))