aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--becommands/assign.py1
-rw-r--r--becommands/close.py2
-rw-r--r--becommands/comment.py6
-rw-r--r--becommands/depend.py4
-rw-r--r--becommands/merge.py4
-rw-r--r--becommands/open.py2
-rw-r--r--becommands/remove.py4
-rw-r--r--becommands/severity.py2
-rw-r--r--becommands/show.py2
-rw-r--r--becommands/status.py2
-rw-r--r--becommands/tag.py2
-rw-r--r--becommands/target.py2
-rw-r--r--libbe/bugdir.py8
-rw-r--r--libbe/cmdutil.py9
-rw-r--r--libbe/rcs.py12
15 files changed, 43 insertions, 19 deletions
diff --git a/becommands/assign.py b/becommands/assign.py
index ba79aac..7b32bdd 100644
--- a/becommands/assign.py
+++ b/becommands/assign.py
@@ -55,6 +55,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError("Too many arguments.")
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
+ bug = cmdutil.bug_from_shortname(bd, args[0])
bug = bd.bug_from_shortname(args[0])
if len(args) == 1:
bug.assigned = bd.user_id
diff --git a/becommands/close.py b/becommands/close.py
index 05bdc10..12848b2 100644
--- a/becommands/close.py
+++ b/becommands/close.py
@@ -43,7 +43,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError("Too many arguments.")
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
bug.status = "closed"
bd.save()
diff --git a/becommands/comment.py b/becommands/comment.py
index 7bbee2c..14872a3 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -32,7 +32,7 @@ def execute(args, manipulate_encodings=True):
>>> os.chdir(bd.root)
>>> execute(["a", "This is a comment about a"], manipulate_encodings=False)
>>> bd._clear_bugs()
- >>> bug = bd.bug_from_shortname("a")
+ >>> bug = cmdutil.bug_from_shortname(bd, "a")
>>> bug.load_comments(load_full=False)
>>> comment = bug.comment_root[0]
>>> print comment.body
@@ -54,7 +54,7 @@ def execute(args, manipulate_encodings=True):
>>> os.environ["EDITOR"] = "echo 'I like cheese' > "
>>> execute(["b"], manipulate_encodings=False)
>>> bd._clear_bugs()
- >>> bug = bd.bug_from_shortname("b")
+ >>> bug = cmdutil.bug_from_shortname(bd, "b")
>>> bug.load_comments(load_full=False)
>>> comment = bug.comment_root[0]
>>> print comment.body
@@ -82,7 +82,7 @@ def execute(args, manipulate_encodings=True):
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(bugname)
+ bug = cmdutil.bug_from_shortname(bd, bugname)
bug.load_comments(load_full=False)
if is_reply:
parent = bug.comment_root.comment_from_shortname(shortname,
diff --git a/becommands/depend.py b/becommands/depend.py
index 201c2ea..fd38bd1 100644
--- a/becommands/depend.py
+++ b/becommands/depend.py
@@ -49,9 +49,9 @@ def execute(args, manipulate_encodings=True):
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bugA = bd.bug_from_shortname(args[0])
+ bugA = cmdutil.bug_from_shortname(bd, args[0])
if len(args) == 2:
- bugB = bd.bug_from_shortname(args[1])
+ bugB = cmdutil.bug_from_shortname(bd, args[1])
estrs = bugA.extra_strings
depend_string = "BLOCKED-BY:%s" % bugB.uuid
if options.remove == True:
diff --git a/becommands/merge.py b/becommands/merge.py
index 8e1fd50..6651869 100644
--- a/becommands/merge.py
+++ b/becommands/merge.py
@@ -135,9 +135,9 @@ def execute(args, manipulate_encodings=True):
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bugA = bd.bug_from_shortname(args[0])
+ bugA = cmdutil.bug_from_shortname(bd, args[0])
bugA.load_comments()
- bugB = bd.bug_from_shortname(args[1])
+ bugB = cmdutil.bug_from_shortname(bd, args[1])
bugB.load_comments()
mergeA = bugA.new_comment("Merged from bug %s" % bugB.uuid)
newCommTree = copy.deepcopy(bugB.comment_root)
diff --git a/becommands/open.py b/becommands/open.py
index b98463d..bfb54ea 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -42,7 +42,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError, "Too many arguments."
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
bug.status = "open"
def get_parser():
diff --git a/becommands/remove.py b/becommands/remove.py
index 884b792..bc7b5ed 100644
--- a/becommands/remove.py
+++ b/becommands/remove.py
@@ -30,7 +30,7 @@ def execute(args, manipulate_encodings=True):
>>> bd._clear_bugs()
>>> try:
... bd.bug_from_shortname("b")
- ... except KeyError:
+ ... except bugdir.NoBugMatches:
... print "Bug not found"
Bug not found
"""
@@ -42,7 +42,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError, "Please specify a bug id."
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
bd.remove_bug(bug)
print "Removed bug %s" % bug.uuid
diff --git a/becommands/severity.py b/becommands/severity.py
index d125789..a14a96b 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -41,7 +41,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
if len(args) == 1:
print bug.severity
elif len(args) == 2:
diff --git a/becommands/show.py b/becommands/show.py
index b7bfe78..bb16fe5 100644
--- a/becommands/show.py
+++ b/becommands/show.py
@@ -73,7 +73,7 @@ def execute(args, manipulate_encodings=True):
is_comment = False
if is_comment == True and options.comments == False:
continue
- bug = bd.bug_from_shortname(bugname)
+ bug = cmdutil.bug_from_shortname(bd, bugname)
if is_comment == False:
if options.XML:
print bug.xml(show_comments=options.comments)
diff --git a/becommands/status.py b/becommands/status.py
index 56cb505..e4db787 100644
--- a/becommands/status.py
+++ b/becommands/status.py
@@ -38,7 +38,7 @@ def execute(args, manipulate_encodings=True):
raise cmdutil.UsageError
bd = bugdir.BugDir(from_disk=True,
manipulate_encodings=manipulate_encodings)
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
if len(args) == 1:
print bug.status
else:
diff --git a/becommands/tag.py b/becommands/tag.py
index 5c4b7a6..e749a31 100644
--- a/becommands/tag.py
+++ b/becommands/tag.py
@@ -93,7 +93,7 @@ def execute(args, manipulate_encodings=True):
if len(tags) > 0:
print '\n'.join(tags)
return
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
if len(args) == 2:
given_tag = args[1]
estrs = bug.extra_strings
diff --git a/becommands/target.py b/becommands/target.py
index 541918c..5d0453a 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -54,7 +54,7 @@ def execute(args, manipulate_encodings=True):
if target and isinstance(target,str):
print target
return
- bug = bd.bug_from_shortname(args[0])
+ bug = cmdutil.bug_from_shortname(bd, args[0])
if len(args) == 1:
if bug.target is None:
print "No target assigned."
diff --git a/libbe/bugdir.py b/libbe/bugdir.py
index e9854c9..1bb307c 100644
--- a/libbe/bugdir.py
+++ b/libbe/bugdir.py
@@ -63,6 +63,12 @@ class MultipleBugMatches(ValueError):
self.shortname = shortname
self.matches = matches
+class NoBugMatches(KeyError):
+ def __init__(self, shortname):
+ msg = "No bug matches %s" % shortname
+ KeyError.__init__(self, msg)
+ self.shortname = shortname
+
class DiskAccessRequired (Exception):
def __init__(self, goal):
msg = "Cannot %s without accessing the disk" % goal
@@ -595,7 +601,7 @@ settings easy. Don't set this attribute. Set .rcs instead, and
raise MultipleBugMatches(shortname, matches)
if len(matches) == 1:
return self.bug_from_uuid(matches[0])
- raise KeyError("No bug matches %s" % shortname)
+ raise NoBugMatches(shortname)
def bug_from_uuid(self, uuid):
if not self.has_bug(uuid):
diff --git a/libbe/cmdutil.py b/libbe/cmdutil.py
index 548c255..94a6856 100644
--- a/libbe/cmdutil.py
+++ b/libbe/cmdutil.py
@@ -207,6 +207,15 @@ def underlined(instring):
return "%s\n%s" % (instring, "="*len(instring))
+def bug_from_shortname(bugdir, shortname):
+ """
+ Exception translation for the command-line interface.
+ """
+ try:
+ bug = bugdir.bug_from_shortname(shortname)
+ except (bugdir.MultipleBugMatches, bugdir.NoBugMatches), e:
+ raise UserError(e.message)
+ return bug
def _test():
import doctest
diff --git a/libbe/rcs.py b/libbe/rcs.py
index fdbb01a..0206bf6 100644
--- a/libbe/rcs.py
+++ b/libbe/rcs.py
@@ -408,14 +408,22 @@ class RCS(object):
temp_file = os.fdopen(descriptor, 'wb')
temp_file.write(summary)
temp_file.flush()
+ self.precommit()
revision = self._rcs_commit(filename, allow_empty=allow_empty)
temp_file.close()
+ self.postcommit()
finally:
os.remove(filename)
return revision
- def precommit(self, directory):
+ def precommit(self):
+ """
+ Executed before all attempted commits.
+ """
pass
- def postcommit(self, directory):
+ def postcommit(self):
+ """
+ Only executed after successful commits.
+ """
pass
def revision_id(self, index=None):
"""